Versions in this module Expand all Collapse all v1 v1.8.2 Jan 3, 2022 Changes in this version + const DefaultHeartbeatFrequency + const DefaultLeaseDuration + const DefaultTableName + var ErrDurationTooSmall = errors.New(...) + var ErrLockAlreadyReleased = errors.New("lock is already released") + var ErrLockNotFound = &NotExistError + var ErrNotAcquired = errors.New("cannot acquire lock") + var ErrNotPostgreSQLDriver = errors.New("this is not a PostgreSQL connection") + type Client struct + func New(db *sql.DB, opts ...ClientOption) (_ *Client, err error) + func UnsafeNew(db *sql.DB, opts ...ClientOption) (_ *Client, err error) + func (c *Client) Acquire(name string, opts ...LockOption) (*Lock, error) + func (c *Client) AcquireContext(ctx context.Context, name string, opts ...LockOption) (*Lock, error) + func (c *Client) CreateTable() error + func (c *Client) Do(ctx context.Context, name string, f func(context.Context, *Lock) error, ...) error + func (c *Client) Get(name string) (*Lock, error) + func (c *Client) GetContext(ctx context.Context, name string) (*Lock, error) + func (c *Client) GetData(name string) ([]byte, error) + func (c *Client) GetDataContext(ctx context.Context, name string) ([]byte, error) + func (c *Client) Release(l *Lock) error + func (c *Client) ReleaseContext(ctx context.Context, l *Lock) error + func (c *Client) SendHeartbeat(ctx context.Context, l *Lock) error + type ClientOption func(*Client) + func WithCustomTable(tableName string) ClientOption + func WithHeartbeatFrequency(d time.Duration) ClientOption + func WithLeaseDuration(d time.Duration) ClientOption + func WithLogger(l Logger) ClientOption + func WithOwner(owner string) ClientOption + type FailedPreconditionError struct + func (err *FailedPreconditionError) Error() string + func (err *FailedPreconditionError) Unwrap() error + type Lock struct + func (l *Lock) Close() error + func (l *Lock) Data() []byte + func (l *Lock) IsReleased() bool + func (l *Lock) Owner() string + func (l *Lock) RecordVersionNumber() int64 + type LockOption func(*Lock) + func FailIfLocked() LockOption + func KeepOnRelease() LockOption + func ReplaceData() LockOption + func WithCustomHeartbeatContext(ctx context.Context) LockOption + func WithData(data []byte) LockOption + type Logger interface + Println func(v ...interface{}) + type NotExistError struct + func (err *NotExistError) Error() string + func (err *NotExistError) Unwrap() error + type OtherError struct + func (err *OtherError) Error() string + func (err *OtherError) Unwrap() error + type UnavailableError struct + func (err *UnavailableError) Error() string + func (err *UnavailableError) Unwrap() error