postgres

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DialectPostgres = sqlutil.DialectPostgres
	DialectSQLite   = sqlutil.DialectSQLite
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Dialect

type Dialect = sqlutil.Dialect

Dialect controls SQL placeholder formatting.

type Option

type Option func(*Store)

Option configures the postgres idempotency store.

func WithClock

func WithClock(now func() time.Time) Option

WithClock overrides the time source.

func WithDialect

func WithDialect(dialect Dialect) Option

WithDialect sets the SQL placeholder style.

func WithTableName

func WithTableName(name string) Option

WithTableName sets the table name.

func WithUseForUpdate

func WithUseForUpdate(enabled bool) Option

WithUseForUpdate toggles row locking in transactions.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store implements idempotency.Store backed by SQL.

func NewStore

func NewStore(db *sql.DB, opts ...Option) *Store

NewStore builds a postgres idempotency store.

func (*Store) Acquire

func (s *Store) Acquire(ctx context.Context, key string, ttl time.Duration) (idempotency.Record, bool, error)

Acquire creates or returns an existing record.

func (*Store) Cleanup

func (s *Store) Cleanup(ctx context.Context) error

Cleanup drops the idempotency table (for tests).

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, key string) error

Delete removes a record.

func (*Store) Get

func (s *Store) Get(ctx context.Context, key string) (idempotency.Record, bool, error)

Get retrieves a record.

func (*Store) Migrate

func (s *Store) Migrate(ctx context.Context) error

Migrate creates the idempotency table.

func (*Store) Update

func (s *Store) Update(ctx context.Context, key string, update idempotency.Update) error

Update applies a partial update.

Jump to

Keyboard shortcuts

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