Documentation
¶
Index ¶
Constants ¶
View Source
const ( DriverNamePgx = "pgx" DefaultConnectionTimeout = 5 DefaultMaxIdleConnections = 50 DefaultMinOpenConnections = 0 )
Variables ¶
View Source
var ( DefaultMinReconnectInterval = config_types.Duration{Duration: 10 * time.Second} DefaultMaxReconnectInterval = config_types.Duration{Duration: 60 * time.Second} DefaultMaxConnectionLifetime = config_types.Duration{Duration: time.Hour} DefaultMaxConnectionLifetimeJitter = config_types.Duration{Duration: 1 * time.Minute} DefaultHealthCheckInterval = config_types.Duration{Duration: 30 * time.Second} DefaultMaxConnectionIdleTime = config_types.Duration{Duration: 30 * time.Minute} )
Functions ¶
This section is empty.
Types ¶
type PostgresStoreConfig ¶
type PostgresStoreConfig struct {
config.BaseConfig
// Host of the Postgres DB
Host string `json:"host" envconfig:"kuma_store_postgres_host"`
// Port of the Postgres DB
Port int `json:"port" envconfig:"kuma_store_postgres_port"`
// User of the Postgres DB
User string `json:"user" envconfig:"kuma_store_postgres_user"`
// Password of the Postgres DB
Password string `json:"password" envconfig:"kuma_store_postgres_password"`
// Database name of the Postgres DB
DbName string `json:"dbName" envconfig:"kuma_store_postgres_db_name"`
// Driver to use, one of: pgx, postgres
DriverName string `json:"driverName" envconfig:"kuma_store_postgres_driver_name"`
// Connection Timeout to the DB in seconds
ConnectionTimeout int `json:"connectionTimeout" envconfig:"kuma_store_postgres_connection_timeout"`
// MaxConnectionIdleTime (applied only when driverName=pgx) is the duration after which an idle connection will be automatically closed by the health check.
MaxConnectionIdleTime config_types.Duration `json:"maxConnectionIdleTime" envconfig:"kuma_store_postgres_max_connection_idle_time"`
// MaxConnectionLifetime (applied only when driverName=pgx) is the duration since creation after which a connection will be automatically closed
MaxConnectionLifetime config_types.Duration `json:"maxConnectionLifetime" envconfig:"kuma_store_postgres_max_connection_lifetime"`
// MaxConnectionLifetimeJitter (applied only when driverName=pgx) is the duration after MaxConnectionLifetime to randomly decide to close a connection.
// This helps prevent all connections from being closed at the exact same time, starving the pool.
MaxConnectionLifetimeJitter config_types.Duration `json:"maxConnectionLifetimeJitter" envconfig:"kuma_store_postgres_max_connection_lifetime_jitter"`
// HealthCheckInterval (applied only when driverName=pgx) is the duration between checks of the health of idle connections.
HealthCheckInterval config_types.Duration `json:"healthCheckInterval" envconfig:"kuma_store_postgres_health_check_interval"`
// MinOpenConnections (applied only when driverName=pgx) is the minimum number of open connections to the database
MinOpenConnections int `json:"minOpenConnections" envconfig:"kuma_store_postgres_min_open_connections"`
// MaxOpenConnections is the maximum number of open connections to the database
// `0` value means number of open connections is unlimited
MaxOpenConnections int `json:"maxOpenConnections" envconfig:"kuma_store_postgres_max_open_connections"`
// MaxIdleConnections is the maximum number of connections in the idle connection pool
// <0 value means no idle connections and 0 means default max idle connections
MaxIdleConnections int `json:"maxIdleConnections" envconfig:"kuma_store_postgres_max_idle_connections"`
// TLS settings
TLS TLSPostgresStoreConfig `json:"tls"`
// MaxListQueryElements defines maximum number of changed elements before requesting full list of elements from the store.
MaxListQueryElements uint32 `json:"maxListQueryElements" envconfig:"kuma_store_postgres_max_list_query_elements"`
// ReadReplica is a setting for a DB replica used only for read queries
ReadReplica ReadReplica `json:"readReplica"`
}
PostgresStoreConfig defines Postgres store configuration
func DefaultPostgresStoreConfig ¶
func DefaultPostgresStoreConfig() *PostgresStoreConfig
func (PostgresStoreConfig) ConnectionString ¶
func (cfg PostgresStoreConfig) ConnectionString() (string, error)
func (*PostgresStoreConfig) Sanitize ¶
func (p *PostgresStoreConfig) Sanitize()
func (*PostgresStoreConfig) Validate ¶
func (p *PostgresStoreConfig) Validate() error
type ReadReplica ¶
type ReadReplica struct {
// Host of the Postgres DB read replica. If not set, read replica is not used.
Host string `json:"host" envconfig:"kuma_store_postgres_read_replica_host"`
// Port of the Postgres DB read replica
Port uint `json:"port" envconfig:"kuma_store_postgres_read_replica_port"`
// Ratio in [0-100] range. How many SELECT queries (out of 100) will use read replica.
Ratio uint `json:"ratio" envconfig:"kuma_store_postgres_read_replica_ratio"`
}
func (ReadReplica) Validate ¶
func (cfg ReadReplica) Validate() error
type TLSMode ¶
type TLSMode string
TLSMode modes available here https://godoc.org/github.com/lib/pq
const ( Disable TLSMode = "disable" // VerifyNone represents Always TLS (skip verification) VerifyNone TLSMode = "verifyNone" // VerifyCa represents Always TLS (verify that the certificate presented by the server was signed by a trusted CA) VerifyCa TLSMode = "verifyCa" // VerifyFull represents Always TLS (verify that the certification presented by the server was signed by a trusted CA and the server host name matches the one in the certificate) VerifyFull TLSMode = "verifyFull" )
type TLSPostgresStoreConfig ¶
type TLSPostgresStoreConfig struct {
config.BaseConfig
// Mode of TLS connection. Available values (disable, verifyNone, verifyCa, verifyFull)
Mode TLSMode `json:"mode" envconfig:"kuma_store_postgres_tls_mode"`
// Path to TLS Certificate of the client. Required when server has METHOD=cert
CertPath string `json:"certPath" envconfig:"kuma_store_postgres_tls_cert_path"`
// Path to TLS Key of the client. Required when server has METHOD=cert
KeyPath string `json:"keyPath" envconfig:"kuma_store_postgres_tls_key_path"`
// Path to the root certificate. Used in verifyCa and verifyFull modes.
CAPath string `json:"caPath" envconfig:"kuma_store_postgres_tls_ca_path"`
// Whether to disable SNI the postgres `sslsni` option.
DisableSSLSNI bool `json:"disableSSLSNI" envconfig:"kuma_store_postgres_tls_disable_sslsni"`
}
func DefaultTLSPostgresStoreConfig ¶
func DefaultTLSPostgresStoreConfig() TLSPostgresStoreConfig
func (TLSPostgresStoreConfig) Validate ¶
func (s TLSPostgresStoreConfig) Validate() error
Click to show internal directories.
Click to hide internal directories.