replication

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DropSlot added in v0.0.2

func DropSlot(dsn, slot string) error

func PublicationTables added in v0.0.5

func PublicationTables(dsn string) string

func RevertChangeSet added in v0.1.0

func RevertChangeSet(dsn string, changeset []Change) error

Types

type Change

type Change struct {
	ServerTime   time.Time `json:"servertime"`
	Kind         string    `json:"kind"`
	Schema       string    `json:"schema"`
	Table        string    `json:"table"`
	ColumnNames  []string  `json:"columnnames"`
	ColumnValues []any     `json:"columnvalues"`
	OldKeys      struct {
		KeyNames  []string `json:"keynames,omitempty"`
		KeyValues []any    `json:"keyvalues,omitempty"`
	} `json:"oldkeys"`
	SQL string `json:"sql"`
}

func (Change) RevertSQL added in v0.1.0

func (c Change) RevertSQL() (string, []any)

type CheckpointLoader

type CheckpointLoader func() (pglogrepl.LSN, error)

type Config

type Config struct {
	DSN             string
	PublicationName string
	SlotName        string
	Timeout         time.Duration
	// contains filtered or unexported fields
}

type HandleChanges

type HandleChanges func(changeset []Change, currentPosition pglogrepl.LSN) error

type SlotInfo added in v0.1.0

type SlotInfo struct {
	Name         string `json:"name"`
	Plugin       string `json:"plugin"`
	Database     string `json:"database"`
	SnapshotName string `json:"snapshotName"`
	RestartLSN   string `json:"restartLSN"`
}

func CreateSlot added in v0.0.3

func CreateSlot(dsn, slot string) (*SlotInfo, error)

type Subscription

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

func Subscribe added in v0.0.3

func Subscribe(cfg Config, handler HandleChanges, useNamespace bool) (*Subscription, error)

func (*Subscription) DSN

func (s *Subscription) DSN() string

func (*Subscription) LastError

func (s *Subscription) LastError() error

func (*Subscription) PublicationName

func (s *Subscription) PublicationName() string

func (*Subscription) SlotName

func (s *Subscription) SlotName() string

func (*Subscription) Start

func (s *Subscription) Start(logger *slog.Logger, loadCheckpoint CheckpointLoader, retry bool) error

func (*Subscription) Stop

func (s *Subscription) Stop()

type SystemInfo added in v0.1.0

type SystemInfo struct {
	SystemID string `json:"systemid"`
	Timeline int32  `json:"timeline"`
	XLogPos  string `json:"xlogpos"`
	DBName   string `json:"dbname"`
}

func Identify added in v0.0.2

func Identify(dsn string) (*SystemInfo, error)

Jump to

Keyboard shortcuts

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