pgbouncer

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const AlreadyPausedError = "already suspended/paused"
View Source
const AlreadyResumedError = "pooler is not paused/suspended"
View Source
const PoolerError = "08P01"

These error codes are returned whenever PgBouncer is asked to PAUSE/RESUME, but is already in the given state.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorizedExecutor

type AuthorizedExecutor struct {
	User, Password, Database, SocketDir, Port string
}

func (AuthorizedExecutor) Connection

func (e AuthorizedExecutor) Connection() (*pgx.Conn, error)

func (AuthorizedExecutor) Execute

func (e AuthorizedExecutor) Execute(ctx context.Context, query string, params ...interface{}) error

func (AuthorizedExecutor) Query

func (e AuthorizedExecutor) Query(ctx context.Context, query string, params ...interface{}) (*pgx.Rows, error)

type Database

type Database struct {
	Name, Host, Port   string
	CurrentConnections int64
}

type PgBouncer

type PgBouncer struct {
	ConfigFile         string
	ConfigTemplateFile string // template that can be rendered with Host value
	Executor           executor
}

func (*PgBouncer) Config

func (b *PgBouncer) Config() (map[string]string, error)

Config generates a key value map of config parameters from the PgBouncer config template file

func (*PgBouncer) Connect

func (b *PgBouncer) Connect(ctx context.Context) error

Connect runs the most basic of commands (SHOW VERSION) against PgBouncer to ensure the connection is alive.

func (*PgBouncer) Disable

func (b *PgBouncer) Disable(ctx context.Context, databases ...string) error

Disable causes PgBouncer to reject all new client connections on the given databases. If no databases are supplied then this operation will apply to all PgBouncer databases.

func (*PgBouncer) GenerateConfig

func (b *PgBouncer) GenerateConfig(host string) error

GenerateConfig writes new configuration to PgBouncer.ConfigFile

func (*PgBouncer) Pause

func (b *PgBouncer) Pause(ctx context.Context) error

Pause causes PgBouncer to buffer incoming queries while waiting for those currently processing to finish executing. The supplied timeout is applied to the Postgres connection.

func (*PgBouncer) Reload

func (b *PgBouncer) Reload(ctx context.Context) error

Reload will cause PgBouncer to reload configuration and live apply setting changes

func (*PgBouncer) Resume

func (b *PgBouncer) Resume(ctx context.Context) error

Resume will remove any applied pauses to PgBouncer

func (*PgBouncer) ShowDatabases

func (b *PgBouncer) ShowDatabases(ctx context.Context) ([]Database, error)

ShowDatabases extracts information from the SHOW DATABASES PgBouncer command, selecting columns about database host details. This is quite cumbersome to write, due to the inability to query select fields for database information, and the lack of guarantees about the ordering of the columns returned from the command.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL