Documentation
¶
Index ¶
- Constants
- Variables
- func IsErrLockAlreadyLeased(err error) bool
- func IsErrNoExistingLockLeaseFound(err error) bool
- func IsErrShouldWait(err error) bool
- func RunHttpBackendServer(ip, port string, backend DistributedLockerBackend) error
- type AcquireOptions
- type AcquireRequest
- type AcquireResponse
- type DistributedLocker
- type DistributedLockerBackend
- type HttpBackend
- type HttpBackendHandler
- type LeaseRenewWorkerDescriptor
- type LockLeaseRecord
- type OptimisticLockingStorageBasedBackend
- func (backend *OptimisticLockingStorageBasedBackend) Acquire(lockName string, opts AcquireOptions) (lockgate.LockHandle, error)
- func (backend *OptimisticLockingStorageBasedBackend) Release(handle lockgate.LockHandle) error
- func (backend *OptimisticLockingStorageBasedBackend) RenewLease(handle lockgate.LockHandle) error
- type ReleaseRequest
- type ReleaseResponse
- type RenewLeaseRequest
- type RenewLeaseResponse
Constants ¶
View Source
const ( DistributedLockLeaseTTLSeconds = 10 DistributedLockPollRetryPeriodSeconds = 2 DistributedOptimisticLockingRetryPeriodSeconds = 1 DistributedLockLeaseRenewPeriodSeconds = 3 )
Variables ¶
Functions ¶
func IsErrLockAlreadyLeased ¶
func IsErrShouldWait ¶
func RunHttpBackendServer ¶
func RunHttpBackendServer(ip, port string, backend DistributedLockerBackend) error
Types ¶
type AcquireOptions ¶
type AcquireOptions struct {
}
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 (l *DistributedLocker) Acquire(lockName string, opts lockgate.AcquireOptions) (bool, lockgate.LockHandle, error)
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 ¶
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{}
}
type LockLeaseRecord ¶
type LockLeaseRecord struct {
lockgate.LockHandle
ExpireAtTimestamp int64
}
func NewLockLeaseRecord ¶
func NewLockLeaseRecord(lockName string, isShared bool) *LockLeaseRecord
type OptimisticLockingStorageBasedBackend ¶
type OptimisticLockingStorageBasedBackend struct {
Store optimistic_locking_store.OptimisticLockingStore
}
func NewOptimisticLockingStorageBasedBackend ¶
func NewOptimisticLockingStorageBasedBackend(store optimistic_locking_store.OptimisticLockingStore) *OptimisticLockingStorageBasedBackend
func (*OptimisticLockingStorageBasedBackend) Acquire ¶
func (backend *OptimisticLockingStorageBasedBackend) Acquire(lockName string, opts AcquireOptions) (lockgate.LockHandle, error)
func (*OptimisticLockingStorageBasedBackend) Release ¶
func (backend *OptimisticLockingStorageBasedBackend) Release(handle lockgate.LockHandle) error
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"`
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.