pg

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package pg implements lease.Provider in terms of a PostgresQL database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Provider)

Option is the type of an option that can be passed to New.

func WithClock

func WithClock(c lease.Clock) Option

WithClock is an Option that sets the clock used by the provider.

type Provider

type Provider struct {
	lease.Clock
	// contains filtered or unexported fields
}

Provider is a lease.Provider implemented in terms of a PostgresQL database.

func New

func New(ctx context.Context, db *sql.DB, table string, opts ...Option) (*Provider, error)

New creates a new PostgresQL lease provider. Leases are stored in a table with the given name. The table is created if it does not already exist.

func (*Provider) Acquire

func (p *Provider) Acquire(ctx context.Context, name string, exp time.Time) (string, error)

func (*Provider) Close

func (p *Provider) Close()

Close releases resources held by the provider. However, it does _not_ close the underlying database connection.

func (*Provider) Release

func (p *Provider) Release(ctx context.Context, name, secret string) error

func (*Provider) Renew

func (p *Provider) Renew(ctx context.Context, name, secret string, exp time.Time) error

Jump to

Keyboard shortcuts

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