Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DBConnector ¶
type DBConnector interface {
Connect() error
}
DBConnector is the interface which various Database-specific configuration objects must satisfy to return a usable database connection to the caller
type PostgresConfig ¶
type PostgresConfig struct { ApplicationName string // The name of the application connecting. Useful for attributing db load. Host string // The host where the database is located Port uint16 // The port on which the database is listening Username string // The username for the database Password string // The password for the database Database string // The name of the database ConnectTimeout time.Duration // Amount of time to wait before timing out SSL bool // If true, connect to the database with SSL SSLCert string // Path to the SSL Certificate, if any SSLKey string // Path to the SSL Key, if any SSLRootCert string // Path to the SSL Root Certificate, if any MetricsFrequency time.Duration // How often to export core database metrics Middleware middleware.Middleware // List of SQL Middlewares to apply, if any }
PostgresConfig defines Postgres SQL connection information
func NewDefaultPostgresConfig ¶
func NewDefaultPostgresConfig(appName, dbName string) PostgresConfig
NewDefaultPostgresConfig creates and return a default postgres configuration.
func (PostgresConfig) Connect ¶
func (pc PostgresConfig) Connect(ctx context.Context, registry prometheus.Registerer, mustRegister bool) (*sqlx.DB, func(), error)
Connect uses the given Config struct to establish a connection with the database. Optionally, a prometheus registry may be provided. If no registry is provided, the global registry will be used. Additionally, users may specify that failed metrics registration should result in a panic via the `mustRegister` flag.
The database connection, deferable close function, and error are returned
func (*PostgresConfig) RegisterFlags ¶
func (pc *PostgresConfig) RegisterFlags(flags *pflag.FlagSet)
RegisterFlags registers SQL flags with pflags