Documentation
¶
Overview ¶
Package postgres provides persistent server-time fenced leases.
Index ¶
- type Migration
- type Store
- func (store *Store) Acquire(ctx context.Context, key string, owner string, ttl time.Duration, _ time.Time) (lease.Lease, error)
- func (*Store) Capabilities() lease.Capabilities
- func (store *Store) Heartbeat(ctx context.Context, owned lease.Lease, ttl time.Duration, _ time.Time) (lease.Lease, error)
- func (store *Store) Inspect(ctx context.Context, key string) (lease.Lease, error)
- func (store *Store) Recover(ctx context.Context, key string, fencingToken uint64) error
- func (store *Store) Release(ctx context.Context, owned lease.Lease) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Migration ¶
Migration contains the versioned lease-table schema transition.
func SchemaMigration ¶
func SchemaMigration() Migration
SchemaMigration returns the PostgreSQL lease-table migration.
func SchemaMigrationFor ¶
SchemaMigrationFor returns the lease-table migration for a caller-owned schema. The schema itself must already exist.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store persists fenced leases in PostgreSQL server time.
func NewWithSchema ¶
NewWithSchema constructs a PostgreSQL lease store in a caller-owned schema. Schema must be a lower-case PostgreSQL identifier no longer than 63 bytes.
func (*Store) Acquire ¶
func (store *Store) Acquire( ctx context.Context, key string, owner string, ttl time.Duration, _ time.Time, ) (lease.Lease, error)
Acquire creates or takes over an inactive or expired lease.
func (*Store) Capabilities ¶
func (*Store) Capabilities() lease.Capabilities
Capabilities reports the PostgreSQL store's safety properties.
func (*Store) Heartbeat ¶
func (store *Store) Heartbeat( ctx context.Context, owned lease.Lease, ttl time.Duration, _ time.Time, ) (lease.Lease, error)
Heartbeat extends a lease when owner and fencing token remain current.