Documentation
¶
Index ¶
- func DSN(opts Opts) string
- type Client
- func (c *Client) CheckConnection(ctx context.Context) error
- func (c *Client) Select(ctx context.Context, dest interface{}, sql string, args ...interface{}) error
- func (db *Client) SelectPgLocks(ctx context.Context) ([]*PgLock, error)
- func (db *Client) SelectPgStatActivity(ctx context.Context) ([]*PgStatActivity, error)
- func (db *Client) SelectPgStatUserTables(ctx context.Context) ([]*PgStatUserTable, error)
- type Opts
- type PgLock
- type PgStatActivity
- type PgStatUserTable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client to PostgreSQL server.
func (*Client) CheckConnection ¶
CheckConnection acquires a connection from the pool and executes an empty sql statement over it.
func (*Client) Select ¶
func (c *Client) Select(ctx context.Context, dest interface{}, sql string, args ...interface{}) error
Select executes a statement that fetches rows in a transaction.
func (*Client) SelectPgLocks ¶
SelectPgLocks selects stats on locks held.
func (*Client) SelectPgStatActivity ¶
func (db *Client) SelectPgStatActivity(ctx context.Context) ([]*PgStatActivity, error)
SelectPgStatActivity selects stats on user tables.
func (*Client) SelectPgStatUserTables ¶
func (db *Client) SelectPgStatUserTables(ctx context.Context) ([]*PgStatUserTable, error)
SelectPgStatUserTables selects stats on user tables.
type Opts ¶
type Opts struct {
//
Host string `long:"postgres_host" env:"POSTGRES_HOST" default:"localhost" description:"Postgres host"`
Port int `long:"postgres_port" env:"POSTGRES_PORT" default:"5432" description:"Postgres port"`
User string `long:"postgres_user" env:"POSTGRES_USER" default:"postgres" description:"Postgres username"`
Password string `long:"postgres_password" env:"POSTGRES_PASSWORD" default:"postgres" description:"Postgres password"`
Database string `long:"postgres_database" env:"POSTGRES_DATABASE" default:"postgres" description:"Postgres database"`
AuthMechanism string `` /* 175-byte string literal not displayed */
ApplicationName string `long:"application_name" env:"APP_NAME" required:"true"`
// Connection parameters.
ConnectTimeout time.Duration `long:"connect_timeout" env:"CONNECT_TIMEOUT" default:"10s" description:"Postgres connection timeout"`
MaxConnectionRetries int `` /* 239-byte string literal not displayed */
// Client connection optional parameters.
DefaultIsolationLevel string `` /* 215-byte string literal not displayed */
StatementTimeout time.Duration `` /* 274-byte string literal not displayed */
LockTimeout time.Duration `` /* 489-byte string literal not displayed */
IdleInTransactionSessionTimeout time.Duration `` /* 446-byte string literal not displayed */
// Transaction options.
TotalTransactionTimeout time.Duration `` /* 202-byte string literal not displayed */
InitialTransactionRetryDelay time.Duration `` /* 180-byte string literal not displayed */
BaseTransactionRetryDelay time.Duration `` /* 166-byte string literal not displayed */
MaxTransactionAttempts int `` /* 194-byte string literal not displayed */
ReadOnly bool `` /* 128-byte string literal not displayed */
// pgxpool.ConnConfig
PoolMaxConns int `long:"pool_max_conns" env:"MAX_CONNS" default:"10" description:"Max open connections to the database"`
PoolMinConns int `long:"pool_min_conns" env:"MIN_CONNS" default:"2" description:"Min open connections to the database"`
PoolMaxConnLifetime time.Duration `` /* 152-byte string literal not displayed */
PoolMaxConnIdleTime time.Duration `` /* 156-byte string literal not displayed */
PoolHealthCheckPeriod time.Duration `` /* 169-byte string literal not displayed */
// pgx.ConnConfig
StatementCacheCapacity int `` /* 211-byte string literal not displayed */
StatementCacheMode string `` /* 459-byte string literal not displayed */
}
Opts specify the configuration for a postgres client.
type PgStatActivity ¶
type PgStatActivity struct {
DatName string `db:"datname"`
State string `db:"state"`
Count int `db:"count"`
MaxTxDuration float64 `db:"max_tx_duration"`
}
PgStatActivity contains information on tx state.
type PgStatUserTable ¶
type PgStatUserTable struct {
DatName string `db:"datname"`
SchemaName string `db:"schemaname"`
RelName string `db:"relname"`
SeqScan int `db:"seq_scan"`
SeqTupRead int `db:"seq_tup_read"`
IndexScan int `db:"idx_scan"`
IndexTupFetch int `db:"idx_tup_fetch"`
NTupInsert int `db:"n_tup_ins"`
NTupUpdate int `db:"n_tup_upd"`
NTupDelete int `db:"n_tup_del"`
NTupHotUpdate int `db:"n_tup_hot_upd"`
NLiveTup int `db:"n_live_tup"`
NDeadTup int `db:"n_dead_tup"`
NModSinceAnalyze int `db:"n_mod_since_analyze"`
LastVacuum pgtype.Timestamptz `db:"last_vacuum"`
LastAutoVacuum pgtype.Timestamptz `db:"last_autovacuum"`
LastAnalyze pgtype.Timestamptz `db:"last_analyze"`
LastAutoAnalyze pgtype.Timestamptz `db:"last_autoanalyze"`
VacuumCount int `db:"vacuum_count"`
AutoVacuumCount int `db:"autovacuum_count"`
AnalyzeCount int `db:"analyze_count"`
AutoAnalyzeCount int `db:"autoanalyze_count"`
}
PgStatUserTable contiains information on user tables.
Click to show internal directories.
Click to hide internal directories.