pgx

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Namespace is used to separate locks from different applications.
	Namespace int32
}

Config holds the configuration for the pgx lock service.

type Option

type Option interface {
	Apply(*Config)
}

Option configures a lock service instance.

func WithNamespace

func WithNamespace(value int32) Option

WithNamespace returns an option that sets the namespace for locks. The namespace is used as the first key in PostgreSQL advisory locks.

type OptionFunc

type OptionFunc func(*Config)

OptionFunc is a function that configures a lock config.

func (OptionFunc) Apply

func (f OptionFunc) Apply(config *Config)

Apply calls f(config).

type Service

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

Service implements lock.Service using PostgreSQL advisory locks.

func New

func New(pool *pgxpool.Pool, options ...Option) *Service

New creates a new lock service using pgxpool.

func NewStdLib

func NewStdLib(db *sql.DB, options ...Option) *Service

NewStdLib creates a new lock service using database/sql.

func (*Service) NewLock

func (s *Service) NewLock(key string) lock.Locker

NewLock creates a new lock with the given key.

Jump to

Keyboard shortcuts

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