Documentation
¶
Index ¶
- type Driver
- func (d *Driver) ApplyPrimary(ctx context.Context) error
- func (d *Driver) ApplyReplica(ctx context.Context, primary dbdriver.PrimaryRef) error
- func (d *Driver) Demote(ctx context.Context) error
- func (d *Driver) Postgresql() *Postgresql
- func (d *Driver) Promotable(ctx context.Context) (bool, string)
- func (d *Driver) ReplicationLagBytes(ctx context.Context) (int64, error)
- func (d *Driver) SetFailoverPolicy(p clusterconfig.FailoverPolicy)
- func (d *Driver) SetupBootstrap(ctx context.Context) error
- func (d *Driver) Start()
- func (d *Driver) Status(ctx context.Context) (dbdriver.Health, error)
- func (d *Driver) Stop()
- func (d *Driver) Type() dbdriver.Engine
- type Postgresql
- func (p *Postgresql) ApplyStreamingReplica(ctx context.Context, primary dbdriver.PrimaryRef, memberName string, ...) error
- func (p *Postgresql) BuildPrimaryConninfo(primary dbdriver.PrimaryRef) string
- func (p *Postgresql) BuildRewindConninfo(primary dbdriver.PrimaryRef) string
- func (p *Postgresql) Close()
- func (p *Postgresql) ConnectHostPort() (string, int)
- func (p *Postgresql) ControlTimeline(ctx context.Context) (uint32, error)
- func (p *Postgresql) EnsurePhysicalSlotOnPrimary(ctx context.Context, primary dbdriver.PrimaryRef, slotName string) error
- func (p *Postgresql) IsAlive() bool
- func (p *Postgresql) IsInRecovery(ctx context.Context) (bool, error)
- func (p *Postgresql) MaybePgRewind(ctx context.Context, primary dbdriver.PrimaryRef) error
- func (p *Postgresql) NeedsPgRewind(ctx context.Context, primary dbdriver.PrimaryRef) (bool, error)
- func (p *Postgresql) PingDB(ctx context.Context) error
- func (p *Postgresql) PrimaryTimeline(ctx context.Context, primary dbdriver.PrimaryRef) (uint32, error)
- func (p *Postgresql) Promote(ctx context.Context) error
- func (p *Postgresql) ReloadConf(ctx context.Context) error
- func (p *Postgresql) ReplicationLagBytes(ctx context.Context) (int64, error)
- func (p *Postgresql) RunPgRewind(ctx context.Context, primary dbdriver.PrimaryRef) error
- func (p *Postgresql) SetDefaultReadOnly(ctx context.Context, readOnly bool) error
- func (p *Postgresql) SetRecoveryPrimaryConninfo(ctx context.Context, conninfo string) error
- func (p *Postgresql) SetRecoveryPrimarySlotName(ctx context.Context, slotName string) error
- func (p *Postgresql) WaitReady(ctx context.Context) error
- type Postgresql14
- type Postgresql15
- type PostgresqlBase
- type PostgresqlHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Driver ¶ added in v0.2.0
type Driver struct {
// contains filtered or unexported fields
}
Driver implements dbdriver.Driver for PostgreSQL (streaming replication path).
func NewDriver ¶ added in v0.2.0
func NewDriver(pg *Postgresql, conf *config.PostgresqlConfig, log *nlog.Log) *Driver
NewDriver wraps *Postgresql as dbdriver.Driver.
func (*Driver) ApplyPrimary ¶ added in v0.2.0
func (*Driver) ApplyReplica ¶ added in v0.2.0
func (*Driver) Postgresql ¶ added in v0.2.0
func (d *Driver) Postgresql() *Postgresql
Postgresql returns the underlying instance for legacy callers.
func (*Driver) Promotable ¶ added in v0.2.0
func (*Driver) ReplicationLagBytes ¶ added in v0.2.0
func (*Driver) SetFailoverPolicy ¶ added in v0.3.0
func (d *Driver) SetFailoverPolicy(p clusterconfig.FailoverPolicy)
func (*Driver) SetupBootstrap ¶ added in v0.2.0
type Postgresql ¶
type Postgresql struct {
// contains filtered or unexported fields
}
Postgresql tuple.
func NewPostgresql ¶
func NewPostgresql(conf *config.PostgresqlConfig, queryTimeout int, log *nlog.Log) *Postgresql
NewPostgresql creates the new Postgresql.
func (*Postgresql) ApplyStreamingReplica ¶ added in v0.2.0
func (p *Postgresql) ApplyStreamingReplica(ctx context.Context, primary dbdriver.PrimaryRef, memberName string, useSlots bool) error
ApplyStreamingReplica configures this node to follow primary (standby must already be in recovery or restart pending).
func (*Postgresql) BuildPrimaryConninfo ¶ added in v0.2.0
func (p *Postgresql) BuildPrimaryConninfo(primary dbdriver.PrimaryRef) string
BuildPrimaryConninfo builds a libpq conninfo string for streaming replication.
func (*Postgresql) BuildRewindConninfo ¶ added in v0.2.0
func (p *Postgresql) BuildRewindConninfo(primary dbdriver.PrimaryRef) string
BuildRewindConninfo builds libpq conninfo for pg_rewind --source-server.
func (*Postgresql) Close ¶ added in v0.2.0
func (p *Postgresql) Close()
Close closes the database pool.
func (*Postgresql) ConnectHostPort ¶ added in v0.2.0
func (p *Postgresql) ConnectHostPort() (string, int)
ConnectHostPort returns host/port parsed from connect_address.
func (*Postgresql) ControlTimeline ¶ added in v0.2.0
func (p *Postgresql) ControlTimeline(ctx context.Context) (uint32, error)
ControlTimeline returns the local timeline from pg_control_checkpoint().
func (*Postgresql) EnsurePhysicalSlotOnPrimary ¶ added in v0.2.0
func (p *Postgresql) EnsurePhysicalSlotOnPrimary(ctx context.Context, primary dbdriver.PrimaryRef, slotName string) error
EnsurePhysicalSlotOnPrimary creates the replication slot on the primary if missing.
func (*Postgresql) IsAlive ¶ added in v0.2.0
func (p *Postgresql) IsAlive() bool
func (*Postgresql) IsInRecovery ¶ added in v0.2.0
func (p *Postgresql) IsInRecovery(ctx context.Context) (bool, error)
IsInRecovery reports pg_is_in_recovery().
func (*Postgresql) MaybePgRewind ¶ added in v0.2.0
func (p *Postgresql) MaybePgRewind(ctx context.Context, primary dbdriver.PrimaryRef) error
MaybePgRewind stops postgres, runs pg_rewind if needed, and restarts.
func (*Postgresql) NeedsPgRewind ¶ added in v0.2.0
func (p *Postgresql) NeedsPgRewind(ctx context.Context, primary dbdriver.PrimaryRef) (bool, error)
NeedsPgRewind reports whether pg_rewind should run before rejoining as replica.
func (*Postgresql) PingDB ¶ added in v0.2.0
func (p *Postgresql) PingDB(ctx context.Context) error
PingDB checks PostgreSQL connectivity.
func (*Postgresql) PrimaryTimeline ¶ added in v0.2.0
func (p *Postgresql) PrimaryTimeline(ctx context.Context, primary dbdriver.PrimaryRef) (uint32, error)
PrimaryTimeline returns the primary's current timeline.
func (*Postgresql) Promote ¶ added in v0.2.0
func (p *Postgresql) Promote(ctx context.Context) error
Promote runs pg_promote() on a standby.
func (*Postgresql) ReloadConf ¶ added in v0.2.0
func (p *Postgresql) ReloadConf(ctx context.Context) error
ReloadConf runs pg_reload_conf().
func (*Postgresql) ReplicationLagBytes ¶ added in v0.2.0
func (p *Postgresql) ReplicationLagBytes(ctx context.Context) (int64, error)
ReplicationLagBytes returns replay lag on a standby (receive LSN minus replay LSN).
func (*Postgresql) RunPgRewind ¶ added in v0.2.0
func (p *Postgresql) RunPgRewind(ctx context.Context, primary dbdriver.PrimaryRef) error
RunPgRewind executes pg_rewind against primary (postgres must be stopped).
func (*Postgresql) SetDefaultReadOnly ¶ added in v0.2.0
func (p *Postgresql) SetDefaultReadOnly(ctx context.Context, readOnly bool) error
SetDefaultReadOnly sets default_transaction_read_only for new sessions.
func (*Postgresql) SetRecoveryPrimaryConninfo ¶ added in v0.2.0
func (p *Postgresql) SetRecoveryPrimaryConninfo(ctx context.Context, conninfo string) error
SetRecoveryPrimaryConninfo writes primary_conninfo via ALTER SYSTEM on the local instance.
func (*Postgresql) SetRecoveryPrimarySlotName ¶ added in v0.2.0
func (p *Postgresql) SetRecoveryPrimarySlotName(ctx context.Context, slotName string) error
SetRecoveryPrimarySlotName writes primary_slot_name via ALTER SYSTEM.