publication

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReplicaIdentityDefault = "DEFAULT"
	ReplicaIdentityFull    = "FULL"
	ReplicaIdentityIndex   = "INDEX"
	ReplicaIdentityNothing = "NOTHING"
)

Variables

View Source
var (
	ErrTablesNotExist      = errors.New("table does not exist")
	ReplicaIdentityOptions = []string{ReplicaIdentityDefault, ReplicaIdentityFull, ReplicaIdentityIndex, ReplicaIdentityNothing}
	ReplicaIdentityMap     = map[string]string{
		"d": ReplicaIdentityDefault,
		"f": ReplicaIdentityFull,
		"i": ReplicaIdentityIndex,
		"n": ReplicaIdentityNothing,
	}
)
View Source
var ErrPublicationNotExists = errors.New("publication does not exist")
View Source
var OperationOptions = Operations{"INSERT", "UPDATE", "DELETE", "TRUNCATE"}

Functions

This section is empty.

Types

type Config

type Config struct {
	Name              string
	Operations        Operations
	Tables            Tables
	CreateIfNotExists bool
}

func NewConfig

func NewConfig(opts ...Option) Config

func (*Config) Validate

func (c *Config) Validate() error

type Operation

type Operation string
var (
	OperationInsert   Operation = "INSERT"
	OperationUpdate   Operation = "UPDATE"
	OperationDelete   Operation = "DELETE"
	OperationTruncate Operation = "TRUNCATE"
)

func (Operation) Validate

func (op Operation) Validate() error

type Operations

type Operations []Operation

func (Operations) String

func (ops Operations) String() string

func (Operations) Validate

func (ops Operations) Validate() error

type Option

type Option func(*Config)

func WithCreateIfNotExists

func WithCreateIfNotExists(createIfNotExists bool) Option

func WithName

func WithName(name string) Option

func WithOperations

func WithOperations(operations Operations) Option

func WithTables

func WithTables(tables Tables) Option

type Publication

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

func New

func New(cfg Config, conn pg.Connection) *Publication

func (*Publication) AddTable

func (p *Publication) AddTable(ctx context.Context, table Table) error

func (*Publication) AlterTableReplicaIdentity

func (p *Publication) AlterTableReplicaIdentity(ctx context.Context, t Table) error

func (*Publication) Create

func (p *Publication) Create(ctx context.Context) (*Config, error)

func (*Publication) GetReplicaIdentities

func (p *Publication) GetReplicaIdentities(ctx context.Context) ([]Table, error)

func (*Publication) Info

func (p *Publication) Info(ctx context.Context) (*Config, error)

func (*Publication) RemoveTable

func (p *Publication) RemoveTable(ctx context.Context, table Table) error

func (*Publication) SetReplicaIdentities

func (p *Publication) SetReplicaIdentities(ctx context.Context) error

type Table

type Table struct {
	Name            string
	ReplicaIdentity string
	Schema          string
	IndexName       string
}

func NewTable

func NewTable(name string, opts ...TableOption) Table

func (Table) Validate

func (t Table) Validate() error

type TableOption

type TableOption func(*Table)

func WithIndexName

func WithIndexName(indexName string) TableOption

func WithReplicaIdentity

func WithReplicaIdentity(replicaIdentity string) TableOption

func WithSchema

func WithSchema(schema string) TableOption

type Tables

type Tables []Table

func (Tables) Diff

func (ts Tables) Diff(tss Tables) Tables

func (Tables) Validate

func (ts Tables) Validate() error

Jump to

Keyboard shortcuts

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