postgresql

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

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 (d *Driver) ApplyPrimary(ctx context.Context) error

func (*Driver) ApplyReplica added in v0.2.0

func (d *Driver) ApplyReplica(ctx context.Context, primary dbdriver.PrimaryRef) error

func (*Driver) Demote added in v0.2.0

func (d *Driver) Demote(ctx context.Context) error

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 (d *Driver) Promotable(ctx context.Context) (bool, string)

func (*Driver) ReplicationLagBytes added in v0.2.0

func (d *Driver) ReplicationLagBytes(ctx context.Context) (int64, error)

func (*Driver) SetFailoverPolicy added in v0.3.0

func (d *Driver) SetFailoverPolicy(p clusterconfig.FailoverPolicy)

func (*Driver) SetupBootstrap added in v0.2.0

func (d *Driver) SetupBootstrap(ctx context.Context) error

func (*Driver) Start added in v0.2.0

func (d *Driver) Start()

func (*Driver) Status added in v0.2.0

func (d *Driver) Status(ctx context.Context) (dbdriver.Health, error)

func (*Driver) Stop added in v0.2.0

func (d *Driver) Stop()

func (*Driver) Type added in v0.2.0

func (d *Driver) Type() dbdriver.Engine

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.

func (*Postgresql) WaitReady added in v0.2.0

func (p *Postgresql) WaitReady(ctx context.Context) error

WaitReady polls until PostgreSQL accepts connections or ctx expires.

type Postgresql14

type Postgresql14 struct {
	PostgresqlBase
}

Postgresql14 tuple.

type Postgresql15

type Postgresql15 struct {
	PostgresqlBase
}

Postgresql15 tuple.

type PostgresqlBase

type PostgresqlBase struct {
}

PostgresqlBase tuple.

type PostgresqlHandler

type PostgresqlHandler interface {
}

PostgresqlHandler interface.

Jump to

Keyboard shortcuts

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