lock

package
v1.19.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 3 Imported by: 5 modules, 13 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metadata

type Metadata struct {
	metadata.Base `json:",inline"`
}

Metadata contains a lock store specific set of metadata property.

type Status

type Status int32
const (
	Success             Status = 0
	LockDoesNotExist    Status = 1
	LockBelongsToOthers Status = 2
	InternalError       Status = 3
)

lock status.

type Store

type Store interface {
	metadata.ComponentWithMetadata

	// Init this component.
	InitLockStore(ctx context.Context, metadata Metadata) error

	// TryLock tries to acquire a lock.
	TryLock(ctx context.Context, req *TryLockRequest) (*TryLockResponse, error)

	// Unlock tries to release a lock.
	Unlock(ctx context.Context, req *UnlockRequest) (*UnlockResponse, error)

	io.Closer
}

type TryLockRequest

type TryLockRequest struct {
	ResourceID      string            `json:"resourceId"`
	LockOwner       string            `json:"lockOwner"`
	ExpiryInSeconds int32             `json:"expiryInSeconds"`
	Metadata        map[string]string `json:"metadata"`
}

TryLockRequest is a lock acquire request.

type TryLockResponse

type TryLockResponse struct {
	Success  bool              `json:"success"`
	Metadata map[string]string `json:"metadata"`
}

Lock acquire request was successful or not.

type UnlockRequest

type UnlockRequest struct {
	ResourceID string            `json:"resourceId"`
	LockOwner  string            `json:"lockOwner"`
	Metadata   map[string]string `json:"metadata"`
}

UnlockRequest is a lock release request.

type UnlockResponse

type UnlockResponse struct {
	Status   Status            `json:"status"`
	Metadata map[string]string `json:"metadata"`
}

Status when releasing the lock.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL