pgbouncer

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2018 License: MIT Imports: 14 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) ExecContext

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

func (AuthorizedExecutor) QueryContext

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

type Database

type Database struct {
	Name, Host, Port string
}

type HostChanger

type HostChanger struct {
	PGBouncer reloader
	Timeout   time.Duration
}

func (HostChanger) Run

func (h HostChanger) Run(_, host string) error

Run receives new PGBouncer host values and will reload PGBouncer to point at the new host

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) 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)

ShowDatabase extracts information from the SHOW DATABASE 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.

Jump to

Keyboard shortcuts

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