Skip to main content

internal/infra/pg/connectionslots.go

internal/infra/pg · 49 lines · 2 declarations · source

Declarations

var ErrNoConnectionSlots

var ErrNoConnectionSlots = errors.New("the database has no connection slot available")

ErrNoConnectionSlots is the substrate having no session left to give.

source

func NoConnectionSlots

func NoConnectionSlots(err error) bool

NoConnectionSlots reports whether an error is the server refusing a new session for want of slots.

Two forms, because the same condition arrives two ways. A server that answered gives SQLSTATE 53300 in a PgError. A pool that could not hand out a connection at all wraps the same message without a code surviving — pgxpool returns the connect error, and the driver's text is what is left. Matching the code alone would miss the second, which is the common one under a full pool.

The text match is deliberately narrow and is a second chance rather than the first: the code is checked first and answers on its own wherever it survives.

source