Documentation
¶
Overview ¶
Package retrypool wraps pgxpool.Pool with automatic retry for transient errors.
Index ¶
- Constants
- func IsTransient(err error) bool
- type Option
- type Pool
- func (p *Pool) Close()
- func (p *Pool) Exec(ctx context.Context, sql string, args ...any) (pgconn.CommandTag, error)
- func (p *Pool) Ping(ctx context.Context) error
- func (p *Pool) Pool() *pgxpool.Pool
- func (p *Pool) Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
- func (p *Pool) QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
Constants ¶
View Source
const ( DefaultMaxRetries = 3 DefaultBaseDelay = 100 * time.Millisecond )
Default retry configuration.
Variables ¶
This section is empty.
Functions ¶
func IsTransient ¶
IsTransient returns true if the error is safe to retry. Uses pgconn.SafeToRetry() plus additional network error checks.
Types ¶
type Option ¶
type Option func(*Pool)
Option configures a Pool.
func WithBaseDelay ¶
WithBaseDelay sets the base delay for exponential backoff.
func WithMaxRetries ¶
WithMaxRetries sets the maximum number of retry attempts.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool wraps *pgxpool.Pool with retry for transient errors. Implements the DBTX interface (Exec, Query, QueryRow) expected by sqlc-generated code.
Click to show internal directories.
Click to hide internal directories.