lock

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SessionInterestLockKey

func SessionInterestLockKey(sessionID string) string

func SessionLockKey

func SessionLockKey(sessionID string) string

Types

type GlobalLockAppropriator

type GlobalLockAppropriator func(ctx context.Context, lockID string) (Lock, error)

GlobalLockAppropriator can be used to acquire global locks on resources

func NewGlobalLockAppropriator

func NewGlobalLockAppropriator(dynamo *dynamodb.DynamoDB, tableName string, retry time.Duration, maxDuration time.Duration) GlobalLockAppropriator

NewGlobalLockAppropriator returns a fully wired GlobalLockAppropriator. If lock acquisition fails it will be retried based on retry until maxDuration has passed at which point acquisition will fail with an error.

func (GlobalLockAppropriator) DoWithLock

func (a GlobalLockAppropriator) DoWithLock(ctx context.Context, lockID string, action func(ctx context.Context) error) error

type Lock

type Lock interface {
	// Unlock releases the lock
	Unlock(ctx context.Context) error
}

Lock represents a distributed lock

Jump to

Keyboard shortcuts

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