distributed_locker

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2023 License: Apache-2.0 Imports: 13 Imported by: 7

Documentation

Index

Constants

View Source
const (
	DistributedLockLeaseTTLSeconds                 = 10
	DistributedLockPollRetryPeriodSeconds          = 2
	DistributedOptimisticLockingRetryPeriodSeconds = 1
	DistributedLockLeaseRenewPeriodSeconds         = 3
)

Variables

View Source
var (
	ErrShouldWait               = errors.New("should wait")
	ErrLockAlreadyLeased        = errors.New("lock already leased")
	ErrNoExistingLockLeaseFound = errors.New("no existing lock lease found")
)

Functions

func IsErrLockAlreadyLeased

func IsErrLockAlreadyLeased(err error) bool

func IsErrNoExistingLockLeaseFound

func IsErrNoExistingLockLeaseFound(err error) bool

func IsErrShouldWait

func IsErrShouldWait(err error) bool

func RunHttpBackendServer

func RunHttpBackendServer(ip, port string, backend DistributedLockerBackend) error

Types

type AcquireOptions

type AcquireOptions struct {
	Shared bool `json:"shared"`
}

type AcquireRequest

type AcquireRequest struct {
	LockName string         `json:"lockName"`
	Opts     AcquireOptions `json:"opts"`
}

type AcquireResponse

type AcquireResponse struct {
	LockHandle lockgate.LockHandle    `json:"lockHandle"`
	Err        util.SerializableError `json:"err"`
}

type DistributedLocker

type DistributedLocker struct {
	Backend DistributedLockerBackend
	// contains filtered or unexported fields
}

func NewDistributedLocker

func NewDistributedLocker(backend DistributedLockerBackend) *DistributedLocker

func NewHttpLocker

func NewHttpLocker(urlEndpoint string) *DistributedLocker

func NewKubernetesLocker

func NewKubernetesLocker(kubernetesInterface dynamic.Interface, gvr schema.GroupVersionResource, resourceName, namespace string) *DistributedLocker

func (*DistributedLocker) Acquire

func (*DistributedLocker) Release

func (l *DistributedLocker) Release(handle lockgate.LockHandle) error

type DistributedLockerBackend

type DistributedLockerBackend interface {
	Acquire(lockName string, opts AcquireOptions) (lockgate.LockHandle, error)
	RenewLease(handle lockgate.LockHandle) error
	Release(handle lockgate.LockHandle) error
}

type HttpBackend

type HttpBackend struct {
	URLEndpoint string
	HttpClient  *http.Client
}

func NewHttpBackend

func NewHttpBackend(urlEndpoint string) *HttpBackend

func (*HttpBackend) Acquire

func (backend *HttpBackend) Acquire(lockName string, opts AcquireOptions) (lockgate.LockHandle, error)

func (*HttpBackend) Release

func (backend *HttpBackend) Release(handle lockgate.LockHandle) error

func (*HttpBackend) RenewLease

func (backend *HttpBackend) RenewLease(handle lockgate.LockHandle) error

type HttpBackendHandler

type HttpBackendHandler struct {
	*http.ServeMux
	Backend DistributedLockerBackend
}

func NewHttpBackendHandler

func NewHttpBackendHandler(backend DistributedLockerBackend) *HttpBackendHandler

func NewHttpBackendHandlerWithInMemoryStore

func NewHttpBackendHandlerWithInMemoryStore() *HttpBackendHandler

func NewHttpBackendHandlerWithKubernetesStore

func NewHttpBackendHandlerWithKubernetesStore(kubernetesInterface dynamic.Interface, gvr schema.GroupVersionResource, resourceName, namespace string) *HttpBackendHandler

type LeaseRenewWorkerDescriptor

type LeaseRenewWorkerDescriptor struct {
	DoneChan           chan struct{}
	SharedLeaseCounter int64
}

type LockLeaseRecord

type LockLeaseRecord struct {
	lockgate.LockHandle
	ExpireAtTimestamp  int64
	SharedHoldersCount int64
	IsShared           bool
}

func NewLockLeaseRecord

func NewLockLeaseRecord(lockName string, isShared bool) *LockLeaseRecord

type OptimisticLockingStorageBasedBackend

type OptimisticLockingStorageBasedBackend struct {
	Store optimistic_locking_store.OptimisticLockingStore
}

func (*OptimisticLockingStorageBasedBackend) Acquire

func (*OptimisticLockingStorageBasedBackend) Release

func (*OptimisticLockingStorageBasedBackend) RenewLease

func (backend *OptimisticLockingStorageBasedBackend) RenewLease(handle lockgate.LockHandle) error

type ReleaseRequest

type ReleaseRequest struct {
	LockHandle lockgate.LockHandle `json:"lockHandle"`
}

type ReleaseResponse

type ReleaseResponse struct {
	Err util.SerializableError `json:"err"`
}

type RenewLeaseRequest

type RenewLeaseRequest struct {
	LockHandle lockgate.LockHandle `json:"lockHandle"`
}

type RenewLeaseResponse

type RenewLeaseResponse struct {
	Err util.SerializableError `json:"err"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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