MCPcopy
hub / github.com/jackc/pgx / OptionShouldPing

Function OptionShouldPing

stdlib/sql.go:139–141  ·  view source on GitHub ↗

OptionShouldPing controls whether stdlib should issue a liveness ping before reusing a connection. If the function returns true, stdlib will ping. If it returns false, stdlib will skip the ping. If not provided, default is ping only when IdleDuration > 1s.

(f func(context.Context, ShouldPingParams) bool)

Source from the content-addressed store, hash-verified

137// If it returns false, stdlib will skip the ping.
138// If not provided, default is ping only when IdleDuration > 1s.
139func OptionShouldPing(f func(context.Context, ShouldPingParams) bool) OptionOpenDB {
140 return func(dc *connector) { dc.ShouldPing = f }
141}
142
143// OptionBeforeConnect provides a callback for before connect. It is passed a shallow copy of the ConnConfig that will
144// be used to connect, so only its immediate members should be modified. Used only if db is opened with *pgx.ConnConfig.

Calls

no outgoing calls

Tested by 1