Documentation ¶
Index ¶
- type DB
- type DynamoDB
- func (d *DynamoDB) InsertNewLock(ctx context.Context, lockId string, ownerName string, leaseUntil time.Time, ...) (*StolenLockInfo, error)
- func (d *DynamoDB) RemoveLock(ctx context.Context, lockId string, leaseUntil time.Time, ownerName string) error
- func (d *DynamoDB) UpdateUntil(ctx context.Context, lockId string, oldUntil time.Time, newUntil time.Time, ...) error
- type DynamoDBWithFencing
- func (d *DynamoDBWithFencing) InsertNewLock(ctx context.Context, lockId string, ownerName string, leaseUntil time.Time, ...) (*StolenLockInfo, *big.Int, error)
- func (d *DynamoDBWithFencing) ReleaseLock(ctx context.Context, lockId string, leaseUntil time.Time, ownerName string) error
- func (d *DynamoDBWithFencing) UpdateUntil(ctx context.Context, lockId string, oldUntil time.Time, newUntil time.Time, ...) error
- type FencingDB
- type StolenLockInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB interface { // Inserts a new lock with the given details iff none exists or the exisiting lock is older than stealLockUntil. In // the latter case the lock is stolen and details about the old lock are returned. // If the lock is taken by someone else and it is not being stolen, a dlock.LockTakenError is returned, but other // errors may be returned. InsertNewLock(ctx context.Context, lockId string, ownerName string, leaseUntil time.Time, stealLockUntil time.Time) (*StolenLockInfo, error) // Remove a lock iff its current leaseUntil and owner is as specified. If the lock is not removed or any other error // occurs, return an error. RemoveLock(ctx context.Context, lockId string, leaseUntil time.Time, ownerName string) error // Update the leaseUntil field of an existing lock iff its current leaseUntil is still oldUntil and the owner is as // specified. If the lock is not updated or any other error occurs, return an error. UpdateUntil(ctx context.Context, lockId string, oldUntil time.Time, newUntil time.Time, ownerName string) error }
Database layer providing serializable compare-and-set operations as required by the Locker.
A lock has a unique identifying lockId and if it is locked a current ownerName and a timestamp until when it is leased by that owner. A lock can be stolen if the existing leaseTime is older than a specific time.
type DynamoDB ¶
type DynamoDB struct {
// contains filtered or unexported fields
}
func (*DynamoDB) InsertNewLock ¶
func (*DynamoDB) RemoveLock ¶
type DynamoDBWithFencing ¶
type DynamoDBWithFencing struct {
// contains filtered or unexported fields
}
func (*DynamoDBWithFencing) InsertNewLock ¶
func (*DynamoDBWithFencing) ReleaseLock ¶
type FencingDB ¶
type FencingDB interface { // Inserts a new lock with the given details iff none exists or the exisiting lock is older than stealLockUntil. In // the latter case the lock is stolen and details about the old lock are returned. The lock fencing token is retruned // always. // If the lock is taken by someone else and it is not being stolen, a dlock.LockTakenError is returned, but other // errors may be returned. // // The big.Int result is the unique fencing token for the new lock. // // A fencing token is guaranteed to be of larger value than all previously acquired locks for the given lockId // (monotonically increasing). It can be used for fencing support in downstream systems as described at // https://martin.kleppmann.com/2016/02/08/how-to-do-distributed-locking.html#making-the-lock-safe-with-fencing. // The actual token will never be negative. InsertNewLock(ctx context.Context, lockId string, ownerName string, leaseUntil time.Time, stealLockUntil time.Time) (*StolenLockInfo, *big.Int, error) // Release a lock iff its current leaseUntil and owner is as specified. If the lock is not released or any other error // occurs, return an error. ReleaseLock(ctx context.Context, lockId string, leaseUntil time.Time, ownerName string) error // Update the leaseUntil field of an existing lock iff its current leaseUntil is still oldUntil and the owner is as // specified. If the lock is not updated or any other error occurs, return an error. UpdateUntil(ctx context.Context, lockId string, oldUntil time.Time, newUntil time.Time, ownerName string) error }
Database layer providing serializable compare-and-set operations as required by the Locker with Fencing support.
A lock has a unique identifying lockId and if it is locked a current ownerName and a timestamp until when it is leased by that owner. A lock can be stolen if the existing leaseTime is older than a specific time.