Documentation
¶
Overview ¶
Package pglock holds Postgres session advisory locks outside the holder's pool, so the holder's work may use every connection of it. A free key is taken on one session shared by every lock the process holds through a pool; only a key someone already holds is waited for on a connection of its own, so extra connections follow contention, not the number of locks held.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrContended = errors.New("pglock: acquisition budget expired; retry")
ErrContended asks callers to retry through their existing request or job path.
Functions ¶
func Acquire ¶
func Acquire(ctx context.Context, pool *pgxpool.Pool, key string, wait bool) (release func(), ok bool, err error)
Acquire locks key against every other holder, in this process or another. Without wait it returns ok=false while anyone else holds key; with it, it waits in Postgres's queue for key, where Postgres detects deadlocks.
Types ¶
This section is empty.