Documentation ¶
Index ¶
- type LockContext
- type LockContextImp
- type LockExtender
- type LockExtenderImp
- type Locker
- type LockerImp
- func (s *LockerImp) ExtendLock(ctx context.Context, lockCtx LockContext) (newLockCtx LockContext, cancel context.CancelFunc, err error)
- func (s *LockerImp) LockWithWait(ctx context.Context, lock models.Lock) (lockCtx LockContext, cancel context.CancelFunc, err error)
- func (s *LockerImp) Unlock(ctx context.Context, lockCtx LockContext) (err error)
- type StorageProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LockContext ¶
type LockContext interface { context.Context GetLock() models.Lock GetLockRecord() models.LockRecord }
Lock context
type LockContextImp ¶
func NewLockContext ¶
func NewLockContext( ctx context.Context, lock models.Lock, lr models.LockRecord, ) LockContextImp
func (LockContextImp) GetLock ¶
func (ctx LockContextImp) GetLock() models.Lock
func (LockContextImp) GetLockRecord ¶
func (ctx LockContextImp) GetLockRecord() models.LockRecord
type LockExtender ¶
type LockExtender interface { LockWithWait(ctx context.Context) (exCtx context.Context, err error) Unlock(ctx context.Context, wait bool) }
Extends existing lock
type LockExtenderImp ¶
type LockExtenderImp struct {
// contains filtered or unexported fields
}
func NewLockExtender ¶
func NewLockExtender( locker Locker, lock models.Lock, count int, ) *LockExtenderImp
func (*LockExtenderImp) LockWithWait ¶
type Locker ¶
type Locker interface { // Set a lock (and wait for previous) or return ErrNoLuck if no luck or an unexpected error occurs LockWithWait( ctx context.Context, lock models.Lock, ) (lockCtx LockContext, cancel context.CancelFunc, err error) // Extend existing lock ExtendLock( ctx context.Context, lockCtx LockContext, ) (newLockCtx LockContext, cancel context.CancelFunc, err error) // Release lock or return ErrNoLuck if no luck or an unexpected error occurs Unlock( ctx context.Context, lockCtx LockContext, ) (err error) }
Manages locks
type LockerImp ¶
type LockerImp struct {
// contains filtered or unexported fields
}
func NewLocker ¶
func NewLocker( sp StorageProvider, ) *LockerImp
func (*LockerImp) ExtendLock ¶
func (s *LockerImp) ExtendLock( ctx context.Context, lockCtx LockContext, ) (newLockCtx LockContext, cancel context.CancelFunc, err error)
func (*LockerImp) LockWithWait ¶
func (s *LockerImp) LockWithWait( ctx context.Context, lock models.Lock, ) (lockCtx LockContext, cancel context.CancelFunc, err error)
Set a lock (and wait for previous) or return ErrNoLuck if no luck or an unexpected error occurs
type StorageProvider ¶
type StorageProvider interface { // Returns LockRecord or error ErrNotFound if not found or unexpected error. GetLockRecord( ctx context.Context, jobName string, ) (lr models.LockRecord, err error) // Creates LockRecord or returns error ErrDuplicate if already exists or unexpected error. CreateLockRecord( ctx context.Context, lr models.LockRecord, ) (err error) // Updates LockRecord with new values or return error ErrNotFound if not found or unexpected error. // Returns ErrNotSupported in case storage does not support updates (in this case storage must handle ttl) UpdateLockRecord( ctx context.Context, jobName string, version string, patch models.LockRecordPatch, ) (err error) }
Creates lock records in a persistent storage.
Click to show internal directories.
Click to hide internal directories.