postgresql

package
v0.16.8 Latest Latest
Warning

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

Go to latest
Published: May 12, 2021 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TODO(sgotti) for now we assume wal size is the default 16MiB size
	WalSegSize = (16 * 1024 * 1024) // 16MiB
)

Variables

View Source
var (
	ErrUnknownState = errors.New("unknown postgres state")
)
View Source
var (
	ValidReplSlotName = regexp.MustCompile("^[a-z0-9_]+$")
)

Functions

func IsValidReplSlotName

func IsValidReplSlotName(name string) bool

func IsWalFileName

func IsWalFileName(name string) bool

func PGLsnToInt

func PGLsnToInt(lsn string) (uint64, error)

func ParseBinaryVersion

func ParseBinaryVersion(v string) (int, int, error)

func ParseVersion

func ParseVersion(v string) (int, int, error)

func SetLogger

func SetLogger(l *zap.SugaredLogger)

func WalFileNameNoTimeLine

func WalFileNameNoTimeLine(name string) (string, error)

func XlogPosToWalFileNameNoTimeline

func XlogPosToWalFileNameNoTimeline(XLogPos uint64) string

Types

type ConnParams

type ConnParams map[string]string

func ParseConnString

func ParseConnString(name string) (ConnParams, error)

ParseConnString parses the options from name and adds them to the values.

The parsing code is based on conninfo_parse from libpq's fe-connect.c

func URLToConnParams

func URLToConnParams(urlStr string) (ConnParams, error)

URLToConnParams creates the connParams from the url.

func (ConnParams) ConnString

func (p ConnParams) ConnString() string

ConnString returns a connection string, its entries are sorted so the returned string can be reproducible and comparable

func (ConnParams) Copy

func (cp ConnParams) Copy() ConnParams

func (ConnParams) Del

func (cp ConnParams) Del(k string)

func (ConnParams) Equals

func (cp ConnParams) Equals(cp2 ConnParams) bool

func (ConnParams) Get

func (cp ConnParams) Get(k string) (v string)

func (ConnParams) Isset

func (cp ConnParams) Isset(k string) bool

func (ConnParams) Set

func (cp ConnParams) Set(k, v string)

type InitConfig

type InitConfig struct {
	Locale        string
	Encoding      string
	DataChecksums bool
}

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(pgBinPath string, dataDir string, localConnParams, replConnParams ConnParams, suAuthMethod, suUsername, suPassword, replAuthMethod, replUsername, replPassword string, requestTimeout time.Duration) *Manager

func (*Manager) BinaryVersion

func (p *Manager) BinaryVersion() (int, int, error)

func (*Manager) CreateReplicationSlot

func (p *Manager) CreateReplicationSlot(name string) error

func (*Manager) CurHba

func (p *Manager) CurHba() []string

func (*Manager) CurParameters

func (p *Manager) CurParameters() common.Parameters

func (*Manager) CurRecoveryOptions added in v0.16.7

func (p *Manager) CurRecoveryOptions() *RecoveryOptions

func (*Manager) DropReplicationSlot

func (p *Manager) DropReplicationSlot(name string) error

func (*Manager) GetConfigFilePGParameters

func (p *Manager) GetConfigFilePGParameters() (common.Parameters, error)

func (*Manager) GetReplicationSlots

func (p *Manager) GetReplicationSlots() ([]string, error)

func (*Manager) GetRole

func (p *Manager) GetRole() (common.Role, error)

GetRole return the current instance role

func (*Manager) GetSyncStandbys added in v0.12.0

func (p *Manager) GetSyncStandbys() ([]string, error)

func (*Manager) GetSystemData

func (p *Manager) GetSystemData() (*SystemData, error)

func (*Manager) GetSystemdID

func (p *Manager) GetSystemdID() (string, error)

func (*Manager) GetTimelinesHistory

func (p *Manager) GetTimelinesHistory(timeline uint64) ([]*TimelineHistory, error)

func (*Manager) Init

func (p *Manager) Init(initConfig *InitConfig) error

func (*Manager) IsInitialized

func (p *Manager) IsInitialized() (bool, error)

func (*Manager) IsRestartRequired added in v0.16.7

func (p *Manager) IsRestartRequired(changedParams []string) (bool, error)

IsRestartRequired returns if a postgres restart is necessary

func (*Manager) IsStarted

func (p *Manager) IsStarted() (bool, error)

func (*Manager) OlderWalFile

func (p *Manager) OlderWalFile() (string, error)

func (*Manager) PGDataVersion

func (p *Manager) PGDataVersion() (int, int, error)

func (*Manager) Ping

func (p *Manager) Ping() error

func (*Manager) Promote

func (p *Manager) Promote() error

func (*Manager) Reload

func (p *Manager) Reload() error

func (*Manager) RemoveAll

func (p *Manager) RemoveAll() error

func (*Manager) Restart

func (p *Manager) Restart(fast bool) error

func (*Manager) Restore

func (p *Manager) Restore(command string) error

func (*Manager) SetHba

func (p *Manager) SetHba(hba []string)

func (*Manager) SetParameters

func (p *Manager) SetParameters(parameters common.Parameters)

func (*Manager) SetRecoveryOptions added in v0.16.7

func (p *Manager) SetRecoveryOptions(recoveryOptions *RecoveryOptions)

func (*Manager) SetupRoles

func (p *Manager) SetupRoles() error

func (*Manager) Start

func (p *Manager) Start() error

func (*Manager) StartTmpMerged

func (p *Manager) StartTmpMerged() error

StartTmpMerged starts postgres with a conf file different than postgresql.conf, including it at the start of the conf if it exists

func (*Manager) Stop

func (p *Manager) Stop(fast bool) error

Stop tries to stop an instance. An error will be returned if the instance isn't started, stop fails or times out (60 second).

func (*Manager) StopIfStarted

func (p *Manager) StopIfStarted(fast bool) error

StopIfStarted checks if the instance is started, then calls stop and then check if the instance is really stopped

func (*Manager) SyncFromFollowed

func (p *Manager) SyncFromFollowed(followedConnParams ConnParams, replSlot string) error

func (*Manager) SyncFromFollowedPGRewind

func (p *Manager) SyncFromFollowedPGRewind(followedConnParams ConnParams, password string) error

func (*Manager) UpdateCurHba

func (p *Manager) UpdateCurHba()

func (*Manager) UpdateCurParameters

func (p *Manager) UpdateCurParameters()

func (*Manager) UpdateCurRecoveryOptions added in v0.16.7

func (p *Manager) UpdateCurRecoveryOptions()

func (*Manager) WaitReady

func (p *Manager) WaitReady(timeout time.Duration) error

func (*Manager) WaitRecoveryDone

func (p *Manager) WaitRecoveryDone(timeout time.Duration) error

type PGManager added in v0.16.7

type PGManager interface {
	GetTimelinesHistory(timeline uint64) ([]*TimelineHistory, error)
}

type RecoveryMode added in v0.16.7

type RecoveryMode int
const (
	RecoveryModeNone RecoveryMode = iota
	RecoveryModeStandby
	RecoveryModeRecovery
)

type RecoveryOptions added in v0.16.7

type RecoveryOptions struct {
	RecoveryMode       RecoveryMode
	RecoveryParameters common.Parameters
}

func NewRecoveryOptions added in v0.16.7

func NewRecoveryOptions() *RecoveryOptions

func (*RecoveryOptions) DeepCopy added in v0.16.7

func (r *RecoveryOptions) DeepCopy() *RecoveryOptions

type SystemData

type SystemData struct {
	SystemID   string
	TimelineID uint64
	XLogPos    uint64
}

func GetSystemData

func GetSystemData(ctx context.Context, replConnParams ConnParams) (*SystemData, error)

type TimelineHistory

type TimelineHistory struct {
	TimelineID  uint64
	SwitchPoint uint64
	Reason      string
}

Jump to

Keyboard shortcuts

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