pgrepl

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT, Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column struct {
	Name  string          `json:"name"`
	Type  string          `json:"type"`
	Value json.RawMessage `json:"value"`
}

Column contains column information.

type Conn

type Conn struct {
	*pgx.Conn
}

Conn adds more methods to pgx.Conn.

func (*Conn) ConfirmedFlushLSN

func (c *Conn) ConfirmedFlushLSN(ctx context.Context, slot string) (pglogrepl.LSN, error)

ConfirmedFlushLSN fetches the confirmed flush LSN.

func (*Conn) GetPublicationTables added in v0.0.12

func (c *Conn) GetPublicationTables(ctx context.Context, p Publication) ([]string, error)

GetPublicationTables checks if the publication exists for a given table.

type PgReplicator

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

PgReplicator is a component that replicates Postgres data.

func New

func New(connStr string, publication Publication) (*PgReplicator, error)

New creates a new Postgres replicator.

func (*PgReplicator) Commit

func (r *PgReplicator) Commit(ctx context.Context, lsn pglogrepl.LSN) error

Commit send a signal to Postgres that the lsn was consumed.

func (*PgReplicator) Shutdown

func (r *PgReplicator) Shutdown()

Shutdown stops the replication by closing the Postgres connection and the feed channel.

func (*PgReplicator) StartReplication

func (r *PgReplicator) StartReplication(ctx context.Context) (chan *Tx, []string, error)

StartReplication starts replicattion.

type PrimaryKey

type PrimaryKey struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

PrimaryKey contains primary key information.

type Publication

type Publication string

Publication is the name a publication. Currently it corresponds to a table's name.

func (Publication) FullName

func (p Publication) FullName() string

FullName is the name used to create a publication in Postgres.

type Record

type Record struct {
	Action     string       `json:"action"`
	XID        int64        `json:"xid"`
	Lsn        string       `json:"lsn"`
	EndLsn     string       `json:"nextlsn"`
	Timestamp  string       `json:"timestamp"`
	Schema     string       `json:"schema"`
	Table      string       `json:"table"`
	Columns    []Column     `json:"columns"`
	PrimaryKey []PrimaryKey `json:"pk"`
}

Record is the WAL record information encoded in JSON.

type Tx

type Tx struct {
	CommitLSN pglogrepl.LSN `json:"commit_lsn"`
	Records   []Record      `json:"records"`
}

Tx is an slice of records.

Jump to

Keyboard shortcuts

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