Versions in this module Expand all Collapse all v1 v1.4.1 Sep 15, 2020 Changes in this version + var ErrCannotReleaseNullLock = errors.New("cannot release null lock item") + var ErrClientClosed = errors.New("client already closed") + var ErrLockAlreadyReleased = errors.New("lock is already released") + var ErrOwnerMismatched = errors.New("lock owner mismatched") + var ErrSessionMonitorNotSet = errors.New("session monitor is not set") + type AcquireLockOption func(*acquireLockOptions) + func FailIfLocked() AcquireLockOption + func ReplaceData() AcquireLockOption + func WithAdditionalAttributes(attr map[string]*dynamodb.AttributeValue) AcquireLockOption + func WithAdditionalTimeToWaitForLock(d time.Duration) AcquireLockOption + func WithData(b []byte) AcquireLockOption + func WithDeleteLockOnRelease() AcquireLockOption + func WithRefreshPeriod(d time.Duration) AcquireLockOption + func WithSessionMonitor(safeTime time.Duration, callback func()) AcquireLockOption + type Client struct + func New(dynamoDB dynamodbiface.DynamoDBAPI, tableName string, opts ...ClientOption) (*Client, error) + func (c *Client) AcquireLock(key string, opts ...AcquireLockOption) (*Lock, error) + func (c *Client) AcquireLockWithContext(ctx context.Context, key string, opts ...AcquireLockOption) (*Lock, error) + func (c *Client) Close() error + func (c *Client) CloseWithContext(ctx context.Context) error + func (c *Client) CreateTable(tableName string, opts ...CreateTableOption) (*dynamodb.CreateTableOutput, error) + func (c *Client) CreateTableWithContext(ctx context.Context, tableName string, opts ...CreateTableOption) (*dynamodb.CreateTableOutput, error) + func (c *Client) Get(key string) (*Lock, error) + func (c *Client) GetWithContext(ctx context.Context, key string) (*Lock, error) + func (c *Client) ReleaseLock(lockItem *Lock, opts ...ReleaseLockOption) (bool, error) + func (c *Client) ReleaseLockWithContext(ctx context.Context, lockItem *Lock, opts ...ReleaseLockOption) (bool, error) + func (c *Client) SendHeartbeat(lockItem *Lock, opts ...SendHeartbeatOption) error + func (c *Client) SendHeartbeatWithContext(ctx context.Context, lockItem *Lock, opts ...SendHeartbeatOption) error + type ClientOption func(*Client) + func DisableHeartbeat() ClientOption + func WithHeartbeatPeriod(d time.Duration) ClientOption + func WithLeaseDuration(d time.Duration) ClientOption + func WithLogger(l Logger) ClientOption + func WithOwnerName(s string) ClientOption + func WithPartitionKeyName(s string) ClientOption + type CreateTableOption func(*createDynamoDBTableOptions) + func WithCustomPartitionKeyName(s string) CreateTableOption + func WithProvisionedThroughput(provisionedThroughput *dynamodb.ProvisionedThroughput) CreateTableOption + func WithTags(tags []*dynamodb.Tag) CreateTableOption + type Lock struct + func (l *Lock) AdditionalAttributes() map[string]*dynamodb.AttributeValue + func (l *Lock) Close() error + func (l *Lock) Data() []byte + func (l *Lock) IsAlmostExpired() (bool, error) + func (l *Lock) IsExpired() bool + func (l *Lock) OwnerName() string + type LockNotGrantedError struct + func (e *LockNotGrantedError) Error() string + func (e *LockNotGrantedError) Unwrap() error + type Logger interface + Println func(v ...interface{}) + type ReleaseLockOption func(*releaseLockOptions) + func WithDataAfterRelease(data []byte) ReleaseLockOption + func WithDeleteLock(deleteLock bool) ReleaseLockOption + type SendHeartbeatOption func(*sendHeartbeatOptions) + func DeleteData() SendHeartbeatOption + func ReplaceHeartbeatData(data []byte) SendHeartbeatOption + type TimeoutError struct + Age time.Duration + func (e *TimeoutError) Error() string