pg

package
v0.0.0-...-86e4b03 Latest Latest
Warning

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

Go to latest
Published: May 15, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultHost              = "localhost"
	DefaultPort              = 5432
	DefaultDatabase          = "postgres"
	DefaultUser              = "postgres"
	DefaultLoggerName        = "pg"
	DefaultConnectionTimeout = 30 * time.Second
	DefaultPromotionTimeout  = 30 * time.Second
)

Variables

View Source
var (
	DefaultPasswordFile           string = "N/A"
	ReplicationPromoteTriggerFile string = "N/A"
)
View Source
var (
	ErrNotInRecovery    = errors.New("not in recovery")
	ErrPromotionTimeout = errors.New("promotion timeout")
)

Functions

func Handlers

func Handlers(c Cluster) map[string]func(http.ResponseWriter, *http.Request)

Types

type Cluster

type Cluster interface {
	// Version returns Cluster version.
	Version() (major int, minor int, err error)

	// Alive returns Cluster liveness status.
	Alive() (bool, error)

	// InRecovery returns Cluster recovery status.
	InRecovery() (bool, error)

	// MasterInfo returns the master info Cluster is a replica of.
	MasterInfo() (*ConnectionInfo, error)

	// Stop stops Cluster.
	Stop() error

	// Start starts Cluster.
	Start() error

	// Promote promotes standby to master.
	Promote() error

	// Backup backs up Cluster from the host:port.
	Backup(host string, port int) error
}

Cluster provides access to database.

func New

func New(ctx context.Context, opts ...Option) Cluster

New returns new Cluster.

type ConnectionInfo

type ConnectionInfo struct {
	Host string `json:"host"`
	Port int    `json:"port"`
}

ConnectionInfo contains connection info.

type Option

type Option func(*cluster)

Option defines configuration option.

func WithDatabase

func WithDatabase(v string) Option

WithDatabase sets PostgreSQL database to connect.

func WithHost

func WithHost(v string) Option

WithHost sets PostgreSQL host.

func WithLoggerName

func WithLoggerName(v string) Option

WithLoggerName sets logger name.

func WithPassword

func WithPassword(v string) Option

WithPassword sets the user password.

func WithPasswordFile

func WithPasswordFile(v string) Option

WithPasswordFile provides password file.

func WithPort

func WithPort(v int) Option

WithPort sets PostgreSQL host.

func WithUser

func WithUser(v string) Option

WithUser sets the user to connect with.

Jump to

Keyboard shortcuts

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