dbconn

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 23 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package dbconn is the engine's database connectivity layer: pgx pool construction with safe session defaults (lock_timeout, statement_timeout), RDS/Aurora TLS, bounded retries for transient errors, and a helper to terminate backends blocking a session's lock acquisition.

Index

Constants

View Source
const (
	DefaultLockTimeout      = 3 * time.Second
	DefaultStatementTimeout = 30 * time.Second
	// DefaultConnectTimeout bounds each dial attempt.
	DefaultConnectTimeout = 10 * time.Second
)

Defaults for the session timeouts every pooled connection runs under. Every statement the engine issues is bounded: lock_timeout keeps the engine from sitting at the head of the lock queue (the lock-queue pile-up), and statement_timeout bounds runaway work.

View Source
const TableLockClassID int32 = 0x70677370

TableLockClassID is the high half of every pg-sprite table lock. The two-argument advisory lock form puts it in pg_locks.classid, which gives pg-sprite a keyspace of its own inside the database's shared advisory keyspace: an unrelated application's single-argument key can never equal a table lock, so a spurious contention refusal can only come from two tables whose names hash alike. The value spells "pgsp".

Variables

View Source
var ErrCACertWithSSLModeDisable = errors.New("a CA bundle (--ca-cert, PGSPRITE_CA_CERT, or Config.CACertPath) requires TLS but the connection string selects sslmode=disable; remove sslmode=disable or the CA bundle")

ErrCACertWithSSLModeDisable reports a connection string that selects sslmode=disable alongside a CA bundle: the bundle asks for a verified encrypted session and the mode asks for none, and neither is safe to guess.

View Source
var ErrInvalidTimeout = errors.New("invalid session timeout")

ErrInvalidTimeout reports a session timeout the server cannot hold as asked. PostgreSQL counts these settings in whole milliseconds, reads 0 as no timeout, and holds at most a 32-bit count. A duration below one millisecond would be sent as 0 and leave the session unbounded; one above the maximum would be refused by the server at connect.

View Source
var ErrInvariantViolation = errors.New("invariant violation")

ErrInvariantViolation is returned when a dbconn proof cannot be constructed safely.

View Source
var ErrMixedRDSAndOtherHosts = errors.New("the connection string lists an RDS/Aurora endpoint alongside a host that is not one, so the embedded RDS CA bundle cannot verify every host")

ErrMixedRDSAndOtherHosts reports a connection string that names no sslmode and lists an RDS/Aurora endpoint alongside a host that is not one. The embedded RDS bundle verifies only the endpoint, and leaving the other host on pgx's default would let it fall back to an unverified or plaintext session, so neither is chosen silently.

View Source
var ErrNoSessionAffinity = errors.New("the connection does not keep one PostgreSQL session")

ErrNoSessionAffinity reports a connection that does not keep one server session, so nothing set on it — least of all an execution bound — can be relied on to still be there for the next statement.

View Source
var ErrRDSBundleDoesNotCoverHost = errors.New("the embedded RDS CA bundle has no roots for this endpoint's partition")

ErrRDSBundleDoesNotCoverHost reports an RDS/Aurora endpoint whose partition has no roots in the embedded bundle, so the connection cannot be verified without a caller-supplied CA (Config.CACertPath, or sslrootcert alongside an explicit verifying sslmode).

View Source
var ErrSessionSettingsDiscarded = errors.New("the connection does not keep pg-sprite's session settings")

ErrSessionSettingsDiscarded reports a connection that did not keep the session settings the pool asked for. The engine's execution bounds are session settings, so a connection that drops them removes the bounds without removing the work they were bounding.

View Source
var ErrTableLockLost = errors.New("table lock lost")

ErrTableLockLost reports that a table lock session lost its lock while work it protected was running. An engine stage wraps it, alongside ErrInvariantViolation, into the LK-1 error it returns for the loss, so a caller can tell the loss — stop, reacquire, resume from the checkpoint — from a breach that must fail closed, without reading the message.

View Source
var ErrTableLockNotHeld = errors.New("no session holds the table lock")

ErrTableLockNotHeld reports that no session holds a table's advisory lock at the moment a working transaction asked the server to confirm it. The lock session believed it held the table, so the caller about to write treats it as its own invariant violation.

Functions

func ConnectReplication added in v0.4.0

func ConnectReplication(ctx context.Context, cfg Config, opts ...ReplicationOption) (*pgconn.PgConn, error)

ConnectReplication opens one dedicated connection in logical replication mode (replication=database) on cfg's database, for the replication commands that no ordinary connection accepts: CREATE_REPLICATION_SLOT, DROP_REPLICATION_SLOT, START_REPLICATION. It dials exactly as a pooled connection would — the same TLS posture, connect timeout, startup parameters including application_name, and BeforeConnect hook for short-lived credentials — so a caller never assembles a DSN of its own. The one session setting it owns is client_min_messages: once connected it runs SET client_min_messages = warning itself, so a walsender's warning that it will withhold changes reaches the connection whatever the role, the database, the server, a login event trigger, or the URL says. A client_min_messages in the URL is not honoured; a startup parameter would be, but a login trigger runs after startup parameters and can outrank one, a URL can carry the key in another case and pgx keeps both, and a connection pooler may refuse it or drop it on the floor.

The connection is a bare pgconn, not a pgx.Conn: a walsender accepts only the simple query protocol, so the session preparation a pooled connection receives (the lock_timeout and statement_timeout SET statements and the search_path repair) is not run on it. Neither matters here: a replication connection issues replication commands, which PostgreSQL does not bound by statement_timeout at all, and every read pg-sprite itself runs on it spells its names through pg_catalog (CO-9). A statement a caller of its own runs on it resolves through whatever search_path the connection settings, role and database give it. The caller bounds every command with ctx and closes the connection when it is done; a command's context ending cuts the connection on the client's side only, unless the caller asked for WithServerSideCancel.

func ConnectSession added in v0.4.0

func ConnectSession(ctx context.Context, cfg Config) (*pgx.Conn, error)

ConnectSession opens one dedicated connection on cfg's database, outside any pool, prepared exactly as a pooled connection would be: the same TLS posture, connect timeout, startup parameters, and BeforeConnect hook, and the same session bounds (lock_timeout and statement_timeout, LK-2) and catalog-first search_path applied once connected. It is for work that must not compete with a pool's connections for a seat — a lock held open while the holder draws on the pool — and that is not exclusive to one server session the way a session-level lock is; that one is AcquireTableLock, which also proves the session's affinity. The caller closes the connection; nothing recycles it.

func IsRDSHost

func IsRDSHost(host string) bool

IsRDSHost reports whether host is an Amazon RDS/Aurora endpoint under `rds.amazonaws.com`, with or without a port — a statement about where the server lives, not about whether pg-sprite can verify it. China endpoints (`amazonaws.com.cn`) carry a different suffix and report false.

Whether such a host gets TLS automatically is RDSBundleCovers's question.

func LocalSearchPath added in v0.3.2

func LocalSearchPath(schemas ...string) string

LocalSearchPath returns the SET LOCAL statement that scopes the current transaction's search_path to schemas, in order. SET cannot take bind parameters, so each schema is quoted as an identifier, and the path then receives the same rewrite as every pooled session's: a pg_catalog entry that another schema precedes is dropped. A transaction-local path replaces the session path for the transaction, so it must uphold the same guarantee (INV: CO-9); every transaction-local search_path pg-sprite sets is built here, and TestLocalSearchPathIsTheOnlySearchPathWriter keeps it that way.

func NewPool

func NewPool(ctx context.Context, cfg Config) (*pgxpool.Pool, error)

NewPool builds a pgx pool from cfg, applies the session defaults, and verifies connectivity with a ping before returning. Each physical connection has any pg_catalog entry that another schema precedes removed from its search_path (see unshadowCatalog), so a schema listed ahead of an explicit pg_catalog no longer shadows the catalog while every other entry stays as configured.

It proves session affinity before returning, which needs a second connection to the same server for the length of the proof. The server — or the pooler in front of it — must have one connection to spare beyond this pool's own, or NewPool fails rather than opening a pool whose bounds were never proven to hold.

func ProveSessionAffinity added in v0.3.3

func ProveSessionAffinity(ctx context.Context, conn AdvisoryLockHolder, pinner *pgxpool.Pool, bound time.Duration) error

ProveSessionAffinity proves on conn the property every session-scoped advisory lock rests on: that this connection keeps one server session, so a lock taken on it is a lock other connections cannot take. It returns an error wrapping ErrNoSessionAffinity when it proves the property does not hold, so a caller fails closed instead of running without the exclusion it believes it has. pinner supplies a second connection to the same server and is not otherwise disturbed.

The proof takes a lock on conn and then makes a second connection hold a transaction open across the check. A transaction-mode pooler pins a backend for a transaction's duration, so the second connection takes the backend conn's single-statement acquire just released, and conn's next statement lands somewhere else. That turns a rebind that would otherwise depend on load into one the proof can observe, and it gives three independent readings of the same failure: the second connection takes a lock conn holds, conn no longer appears in pg_locks as the session holding its own lock, and conn cannot release what it took. A statement-mode pooler refuses the second connection's transaction outright, which is a fourth reading of the same failure.

Against a direct connection, and against a pooler that hands out a session per client connection, every reading is the healthy one. There is no false positive to trade off, because each reading is a fact about the connection in hand rather than a guess about what sits behind it.

bound caps the whole proof; a non-positive bound leaves it on the caller's context alone.

It is one-sided in the other direction: an idle transaction-mode pooler with spare backends can answer every reading the healthy way, so a clean proof is evidence and not certainty. It is a guard against the configuration an operator lands on by following a hosted platform's default connection string, not a substitute for pointing the engine at a direct endpoint.

The probe key is freshly random on every call, so concurrent proofs never contend and a probe lock stranded on an unreachable backend can never block anything later.

INV: LK-2 — every strong lock acquisition is bounded. The bounds are session settings, so they only hold where the session does. An advisory lock is the instrument here rather than the subject: it is the one piece of session state whose loss a client can observe directly, which makes it the way to prove the session is stable enough to carry the timeouts.

func RDSBundleCovers added in v0.4.0

func RDSBundleCovers(host string) bool

RDSBundleCovers reports whether host is an RDS/Aurora endpoint whose partition the embedded global bundle carries roots for, so the connection can be verified with no CA bundle to install (see configureTLS).

GovCloud endpoints report false: the embedded bundle has no roots for that partition, so a verify-full handshake against it fails for a reason the x509 error does not name. Reach them with an explicit CA bundle (Config.CACertPath) holding that partition's roots.

func RestoreSessionSearchPath added in v0.4.0

func RestoreSessionSearchPath(path string) (string, string)

RestoreSessionSearchPath returns the statement, and its one argument, that puts a session's search_path back to path, a value read with current_setting('search_path'). The value is passed as a parameter, so an empty path round-trips, and receives the rewrite every pooled session's does (INV: CO-9).

func Retry

func Retry(ctx context.Context, attempts int, backoff time.Duration, fn func(context.Context) error) error

Retry runs fn up to attempts times with linear backoff, retrying only errors Retryable classifies as transient. Non-transient errors return immediately; context cancellation always wins.

func Retryable

func Retryable(err error) bool

Retryable reports whether err is transient: a bounded lock wait that timed out, a deadlock or serialization failure, or a connection-level error.

func ServerMajor

func ServerMajor(ctx context.Context, pool *pgxpool.Pool) (int, error)

ServerMajor reads the connected server's numeric major version.

INV: CO-9 — as ServerVersion; the division is done here rather than in SQL, where `/` would resolve through the caller's path.

func ServerVersion

func ServerVersion(ctx context.Context, pool *pgxpool.Pool) (string, error)

ServerVersion reads the connected server's server_version setting. Plan reports carry it because classification is version-sensitive: a stored report names the server whose rules produced it.

INV: CO-9 — the pool may be the caller's own, with a path that lists another schema ahead of pg_catalog, so the function is qualified.

func SessionSearchPath added in v0.4.0

func SessionSearchPath(schemas ...string) string

SessionSearchPath returns the SET statement that sets the session's search_path to schemas, in order, with the same quoting and rewrite as LocalSearchPath. It is for statements that refuse to run inside a transaction block, which rules out SET LOCAL: the caller reads the session's path first and puts it back with RestoreSessionSearchPath before the session returns to the pool (INV: CO-9).

func TerminateBlockers

func TerminateBlockers(ctx context.Context, q Querier, pid int) ([]int, error)

TerminateBlockers terminates every backend currently blocking pid's lock acquisition (per pg_blocking_pids) and returns the pids it terminated.

This is the bounded-cutover escape hatch: it targets only the backends standing in front of a specific waiting session (e.g. the cutover swap), never a broad sweep. Callers decide whether evicting those backends is acceptable; this function only does the targeted termination.

The statement runs on whatever q the caller passes, under that session's own search_path — a pool not built by NewPool keeps a path that may list another schema ahead of pg_catalog — so every function it calls is qualified: a lookalike pg_terminate_backend(integer) that returns true and signals nothing would otherwise report the blocker evicted while it keeps the lock.

INV: CO-9 — every name resolves to pg_catalog regardless of the session's path.

func WithExtensionSchemas added in v0.5.1

func WithExtensionSchemas(path, extensions []string) []string

WithExtensionSchemas returns path followed by each of extensions that path does not already list, in order. Extension schemas come last, so they widen what an unqualified name can resolve to without shadowing a schema the path already searches. Planning and execution both build the path a desired file runs under with this function, so a name resolves to the same object in the scratch build that planned a statement and in the transaction that runs it.

Types

type AdvisoryLockHolder added in v0.3.3

type AdvisoryLockHolder interface {
	QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
}

AdvisoryLockHolder is the query surface a lock confirmation needs; *pgxpool.Conn and *pgx.Conn both satisfy it. The confirmation must run on the session under test, so this is deliberately not the pool.

type Config

type Config struct {
	// URL is a libpq connection string or URL (postgres://...).
	URL string
	// LockTimeout is applied as the session lock_timeout on every connection.
	// Zero means DefaultLockTimeout; any other value must be at least one
	// millisecond and at most 2147483647ms, or the connection is refused with
	// ErrInvalidTimeout.
	LockTimeout time.Duration
	// StatementTimeout is applied as the session statement_timeout on every
	// connection. Zero means DefaultStatementTimeout; any other value must be
	// at least one millisecond and at most 2147483647ms, or the connection is
	// refused with ErrInvalidTimeout.
	StatementTimeout time.Duration
	// ConnectTimeout bounds each dial attempt. The session affinity proof
	// runs against the same server and opens a connection of its own, so its
	// budget is this plus the proof's own floor. Zero means
	// DefaultConnectTimeout.
	ConnectTimeout time.Duration
	// CACertPath, when set, enables verify-full TLS using the given CA bundle
	// (e.g. the RDS/Aurora global bundle) and overrides whatever sslmode the
	// URL asks for: every connection attempt, including each host of a
	// multi-host URL, is verified against the bundle, and none falls back to
	// an unencrypted or unverified session. The bundle always means
	// verify-full: sslmode=verify-ca is promoted to verify the host name as
	// well. Each attempt keeps the client certificate (sslcert / sslkey) and
	// ALPN (sslnegotiation=direct) the URL configures, and a unix-domain
	// socket host stays without TLS, which PostgreSQL does not offer over a
	// socket. A URL that selects sslmode=disable alongside it is refused with
	// ErrCACertWithSSLModeDisable. Unset, RDS/Aurora endpoints in
	// the partitions the embedded bundle covers are auto-verified with it
	// (see rds.go), each host of a multi-host URL against its own name; an
	// RDS/Aurora endpoint in any other partition (GovCloud) refuses to open
	// with ErrRDSBundleDoesNotCoverHost unless its connection string selects
	// an sslmode that needs no roots, and a URL with no sslmode that lists an
	// RDS/Aurora endpoint beside another host refuses with
	// ErrMixedRDSAndOtherHosts.
	CACertPath string

	// Pool sizing and lifecycle. Zero values keep pgxpool's defaults.
	//
	// NOTE: the advisory-lock connection (LK-1) must NOT come from this pool:
	// session-scoped locks die with their session, and lifetime/idle
	// recycling would silently release the lock. The lock helper owns a bare
	// dedicated connection exempt from pool recycling.
	MaxConns int32
	// MaxConnsFloor raises the pool's default size to at least this many
	// connections, for a caller that knows how many sessions its work holds
	// at once. It applies only to the default: when MaxConns is zero and the
	// URL carries no pool_max_conns. A size the caller or the URL sets is
	// kept as given, even below the floor, so the work that needs more
	// connections refuses the pool rather than overriding the operator.
	MaxConnsFloor         int32
	MinConns              int32
	MaxConnLifetime       time.Duration
	MaxConnLifetimeJitter time.Duration
	MaxConnIdleTime       time.Duration
	HealthCheckPeriod     time.Duration

	// QueryExecMode overrides pgx's default protocol usage — e.g.
	// pgx.QueryExecModeExec when a transaction-pooling proxy that cannot
	// handle prepared statements sits in front of the pool. Zero keeps pgx's
	// default (statement caching).
	QueryExecMode pgx.QueryExecMode
	// Logger, when set, enables statement-level tracing (pgx tracelog) at
	// debug level through the given slog logger.
	Logger *slog.Logger
	// BeforeConnect, when set, can mutate each new connection's config just
	// before dialing — the hook for short-lived credentials such as RDS IAM
	// authentication tokens.
	BeforeConnect func(context.Context, *pgx.ConnConfig) error
}

Config describes a connection target. Zero values keep sensible defaults (ours for the session timeouts, pgxpool's for pool sizing and lifecycle) — decisions, not options.

type IndexBuildProgress

type IndexBuildProgress struct {
	Phase            string
	BlocksDone       uint64
	BlocksTotal      uint64
	TuplesDone       uint64
	TuplesTotal      uint64
	LockersTotal     uint64
	LockersDone      uint64
	CurrentLockerPID uint32
}

IndexBuildProgress is one server observation of a concurrent index build.

func ConcurrentIndexProgress

func ConcurrentIndexProgress(ctx context.Context, session RowQuerier, backendPID uint32) (IndexBuildProgress, bool, error)

ConcurrentIndexProgress reads the active build owned by backendPID. The boolean is false when PostgreSQL has not published the row yet or the build has already left the progress view.

type Querier

type Querier interface {
	Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
}

Querier is the query surface TerminateBlockers needs; *pgxpool.Pool and *pgx.Conn both satisfy it.

type ReplicationOption added in v0.4.0

type ReplicationOption func(*pgconn.Config)

ReplicationOption adjusts how ConnectReplication opens its connection.

func WithServerSideCancel added in v0.4.0

func WithServerSideCancel(grace time.Duration) ReplicationOption

WithServerSideCancel makes a command whose context ends be cancelled on the server before the client gives it up: a cancel request goes to the walsender on a second connection, and the command's call returns once the server has answered it, or after grace with the connection cut. Without the option the client cuts the connection first and sends the cancel request afterwards, in the background on a budget of its own, so the call returns before the server has acted on it: a caller that reads the catalog next, or releases a holder, can find the command it was told ended still waiting or completing on the server — PostgreSQL does not bound a replication command by statement_timeout, and a walsender in a DROP_REPLICATION_SLOT … WAIT or a CREATE_REPLICATION_SLOT comes off its wait only for the cancel or for the holder. With the option, when the call returns the server has ended the command and reported it as query_canceled, which the error carries; the caller folds its context's error back in. Not for a streaming connection: its reads are bounded by per-read contexts that end routinely and must not end the stream.

type RowQuerier

type RowQuerier interface {
	QueryRow(context.Context, string, ...any) pgx.Row
}

RowQuerier is the session capability needed for a progress observation.

type TableLock added in v0.3.2

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

TableLock proves this process holds LK-1's per-table advisory lock on a dedicated session. Its zero value is forgeable; consumers must reject it when Table is empty.

func (TableLock) Key added in v0.3.2

func (l TableLock) Key() TableLockKey

Key returns the advisory lock key as pg_locks reports it.

func (TableLock) Schema added in v0.3.2

func (l TableLock) Schema() string

Schema returns the locked table's schema.

func (TableLock) Table added in v0.3.2

func (l TableLock) Table() string

Table returns the locked table name.

type TableLockHeldError added in v0.4.0

type TableLockHeldError struct {
	Schema string
	Table  string
	Holder TableLockHolder
}

TableLockHeldError reports that another session holds a table's advisory lock. Holder names that session when the catalog answered the lookup; its zero value means the lock was released again before the lookup ran, or the lookup itself failed (the failure is joined to this error).

func (*TableLockHeldError) Error added in v0.4.0

func (e *TableLockHeldError) Error() string

type TableLockHolder added in v0.4.0

type TableLockHolder struct {
	PID             uint32
	ApplicationName string
	BackendStart    time.Time
	State           string
}

TableLockHolder describes the session holding a table lock, as pg_locks joined to pg_stat_activity reports it. ApplicationName and State are empty, and BackendStart zero, when pg_stat_activity hides the session's details from the connected role.

func LookupTableLockHolder added in v0.4.0

func LookupTableLockHolder(ctx context.Context, conn AdvisoryLockHolder, schema, table string) (holder TableLockHolder, found bool, err error)

LookupTableLockHolder reports the session holding a table's lock without taking it, so a read-only surface can answer "who holds this table" from any connection to the table's database. found is false when nobody holds the lock there; a lock held in another database of the same server is not reported, because it excludes no run on this one.

type TableLockKey added in v0.4.0

type TableLockKey struct {
	ClassID int32
	ObjID   int32
}

TableLockKey is the (classid, objid) pair pg_locks reports for a table lock, as PostgreSQL's two-argument advisory lock functions take it.

type TableLockOption added in v0.4.0

type TableLockOption func(*tableLockOptions) error

TableLockOption configures lock-session monitoring.

func WithTableLockKeepalive added in v0.4.0

func WithTableLockKeepalive(interval time.Duration) TableLockOption

WithTableLockKeepalive sets the interval between lock confirmations. Each confirmation is bounded by the same interval, so a lost lock is reported on Done within two intervals of the loss. The interval must also stay under any idle_session_timeout the server enforces, since the confirmation traffic is what keeps the dedicated session from being idle.

type TableLockSession added in v0.4.0

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

TableLockSession owns the dedicated PostgreSQL session carrying a TableLock.

func AcquireTableLock added in v0.4.0

func AcquireTableLock(ctx context.Context, cfg Config, schema, table string, options ...TableLockOption) (*TableLockSession, error)

AcquireTableLock opens a dedicated, non-recycling connection, proves it keeps one server session, and tries to acquire the per-table advisory lock. It never retries a held lock: contention returns a TableLockHeldError naming the holder when the catalog reports one, and the ordering policy for a plan that touches several tables belongs to the caller. ctx bounds acquisition only; Release or detected lock loss ends the acquired session. schema and table must be catalog names as stored, including case, rather than unquoted SQL identifiers that PostgreSQL has not yet folded.

func (*TableLockSession) BackendPID added in v0.4.0

func (s *TableLockSession) BackendPID() uint32

BackendPID returns the dedicated session's backend PID.

func (*TableLockSession) BackendStart added in v0.5.5

func (s *TableLockSession) BackendStart() time.Time

BackendStart returns when the dedicated session's backend started, as pg_stat_activity reports it. A PID is unique only within one server, so a caller proving from another connection that it reaches the lock's server matches the holder's PID and BackendStart together.

func (*TableLockSession) Bind added in v0.4.0

Bind derives a context from parent that is also cancelled when this session ends: with Err as the cause when the lock is lost, and with context.Canceled on Release. Work the lock protects runs under the returned context so a lost lock cancels every statement in flight instead of relying on the caller to watch Done. The returned stop function ends the watcher and cancels the context; callers defer it.

func (*TableLockSession) Confirm added in v0.4.0

Confirm re-asserts the session's table lock from inside a working transaction on another connection, before that transaction's first write: pg_locks, read on the connection about to write, must show the lock granted to this session's own backend. The lock and the work are deliberately on different sessions, so this is the one point where the server confirms that the session a transaction trusts is the session that actually holds the table.

A missing lock is ErrTableLockNotHeld naming the table; a lock granted to a different backend is a *TableLockHeldError naming it. Confirm reports what the server said and leaves the fail-closed decision to the caller, which names the invariant it enforces once, in its own words.

func (*TableLockSession) Done added in v0.4.0

func (s *TableLockSession) Done() <-chan struct{}

Done closes when the session is released or loses the lock unexpectedly.

func (*TableLockSession) Err added in v0.4.0

func (s *TableLockSession) Err() error

Err returns nil while held or after a clean release, and the reason after loss.

func (*TableLockSession) Lock added in v0.4.0

func (s *TableLockSession) Lock() TableLock

Lock returns the proof carried by this session.

func (*TableLockSession) Release added in v0.4.0

func (s *TableLockSession) Release(ctx context.Context) error

Release unlocks and closes the dedicated session. Calls after the first return the first call's result.

Jump to

Keyboard shortcuts

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