Versions in this module Expand all Collapse all v2 v2.0.0 Jun 20, 2026 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 ErrReadOnlyLockHeartbeat = errors.New("cannot send heartbeats to a read-only lock") + var ErrSessionMonitorNotSet = errors.New("session monitor is not set") + type AcquireLockOption func(*acquireLockOptions) + func FailIfLocked() AcquireLockOption + func ReplaceData() AcquireLockOption + func WithAdditionalAttributes(attr map[string]types.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 DynamoDBClient, 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 WithContextLogger(l ContextLogger) 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 + func WithSortKey(name string, value string) ClientOption + type ContextLogger interface + Println func(ctx context.Context, v ...any) + type CreateTableOption func(*createDynamoDBTableOptions) + func WithCustomPartitionKeyName(s string) CreateTableOption + func WithProvisionedThroughput(provisionedThroughput *types.ProvisionedThroughput) CreateTableOption + func WithSortKeyName(s string) CreateTableOption + func WithTags(tags []types.Tag) CreateTableOption + type DynamoDBClient interface + CreateTable func(ctx context.Context, params *dynamodb.CreateTableInput, ...) (*dynamodb.CreateTableOutput, error) + DeleteItem func(ctx context.Context, params *dynamodb.DeleteItemInput, ...) (*dynamodb.DeleteItemOutput, error) + GetItem func(ctx context.Context, params *dynamodb.GetItemInput, ...) (*dynamodb.GetItemOutput, error) + PutItem func(ctx context.Context, params *dynamodb.PutItemInput, ...) (*dynamodb.PutItemOutput, error) + UpdateItem func(ctx context.Context, params *dynamodb.UpdateItemInput, ...) (*dynamodb.UpdateItemOutput, error) + type Lock struct + func (l *Lock) AdditionalAttributes() map[string]types.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 ...any) + type ReleaseLockOption func(*releaseLockOptions) + func WithDataAfterRelease(data []byte) ReleaseLockOption + func WithDeleteLock(deleteLock bool) ReleaseLockOption + type SendHeartbeatOption func(*sendHeartbeatOptions) + func DeleteData() SendHeartbeatOption + func HeartbeatRetries(retries int, wait time.Duration) SendHeartbeatOption + func ReplaceHeartbeatData(data []byte) SendHeartbeatOption + func UnsafeMatchOwnerOnly() SendHeartbeatOption + type TimeoutError struct + Age time.Duration + func (e *TimeoutError) Error() string