Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectRetry ¶
func ConnectRetry(ctx context.Context, conf Config, maxDuration time.Duration, errChan chan<- error) (conn *pgxpool.Pool, err error)
ConnectRetry tries to connect to the database given by Config. If the connection can't be established, it will retry periodically for maxDuration, using a fibonacci backoff starting with 500ms. It also uses a jitter of +/-50ms to avoid all instances trying to connect at the very same time. All errors not returned immediately (retryable errors) will be sent through errChan
Types ¶
type Config ¶
type Config struct { Host string `mapstructure:"host" envconfig:"HOST" default:"127.0.0.1"` Port int `mapstructure:"port" envconfig:"PORT" default:"5432"` Database string `mapstructure:"database" envconfig:"DATABASE" default:"postgres"` User string `mapstructure:"user" envconfig:"USER" default:"postgres"` Password string `mapstructure:"password" envconfig:"PASSWORD" default:"postgres"` Params map[string]string `mapstructure:"params" envconfig:"PARAMS" default:"sslmode:require"` }
Click to show internal directories.
Click to hide internal directories.