pg

package
v0.0.0-...-d2b48f3 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	*sqlx.DB
	Hostname string
	Database string
}

func MustConnect

func MustConnect(uri string, poolSize int) *DB

Tries to establish connection with database using given Connection URI and returns a wrapped sqlx.DB structure with few more fields. If it doesn't succeed to connect then it causes to exit with code 1.

func (*DB) CurrentWalLsn

func (db *DB) CurrentWalLsn() (string, error)

Returns the current write-ahead log write location as a string. When no replication exists it will return an error.

func (*DB) Publications

func (db *DB) Publications() ([]Publication, error)

Returns a list of postgres publications that already have replication slot created, i.e. there is a subscription on standby instance side.

func (*DB) ReplicationSlots

func (db *DB) ReplicationSlots() ([]ReplicationSlot, error)

Returns a list of postgres replication slots.

func (*DB) Subscriptions

func (db *DB) Subscriptions() ([]Subscription, error)

Returns a list of postgres subscriptions.

type Publication

type Publication struct {
	Active  bool          `db:"active"`
	Name    string        `db:"application_name"`
	Pid     sql.NullInt64 `db:"pid"`
	SentLsn string        `db:"sent_lsn"`
	State   string        `db:"state"`
	Tmp     bool          `db:"temporary"`
}

type ReplicationSlot

type ReplicationSlot struct {
	Name              string `db:"slot_name"`
	RestartLsn        string `db:"restart_lsn"`
	ConfirmedFlushLsn string `db:"confirmed_flush_lsn"`
	Active            bool   `db:"active"`
}

type Subscription

type Subscription struct {
	Pid                sql.NullInt64  `db:"pid"`
	Name               string         `db:"subname"`
	Relname            sql.NullString `db:"relname"`
	ReceivedLsn        string         `db:"received_lsn"`
	LastMsgReceiptTime string         `db:"last_msg_receipt_time"`
}

Jump to

Keyboard shortcuts

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