postgres

package
v0.0.0-...-a4bc04b Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package postgres provides a PostgreSQL CDC source implementation using pgstream.

Package postgres provides a PostgreSQL CDC source implementation using pgstream.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissingConnectionURL is returned when the connection URL is not provided.
	ErrMissingConnectionURL = errors.New("postgres: connection URL is required")

	// ErrMissingSlotName is returned when the replication slot name is not provided.
	ErrMissingSlotName = errors.New("postgres: replication slot name is required")

	// ErrMissingPublicationName is returned when the publication name is not provided.
	ErrMissingPublicationName = errors.New("postgres: publication name is required")

	// ErrAlreadyStarted is returned when Start is called on an already started source.
	ErrAlreadyStarted = errors.New("postgres: source already started")

	// ErrNotStarted is returned when Stop is called on a source that hasn't started.
	ErrNotStarted = errors.New("postgres: source not started")

	// ErrConnectionFailed is returned when the connection to PostgreSQL fails.
	ErrConnectionFailed = errors.New("postgres: connection failed")

	// ErrReplicationFailed is returned when replication streaming fails.
	ErrReplicationFailed = errors.New("postgres: replication failed")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	source.Config

	// ConnectionURL is the PostgreSQL connection URL.
	ConnectionURL string

	// SlotName is the name of the replication slot.
	SlotName string

	// PublicationName is the name of the publication to subscribe to.
	PublicationName string

	// Tables is a list of tables to capture (empty means all tables in publication).
	Tables []string

	// ReconnectInterval is the interval between reconnection attempts.
	ReconnectInterval time.Duration

	// MaxReconnectAttempts is the maximum number of reconnection attempts (0 = unlimited).
	MaxReconnectAttempts int

	// EventBufferSize is the size of the internal event buffer.
	EventBufferSize int
}

Config holds configuration for the PostgreSQL CDC source.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with sensible defaults.

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration.

type Reader

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

Reader is a PostgreSQL CDC source that uses pgstream for logical replication.

func New

func New(cfg Config, logger *slog.Logger) (*Reader, error)

New creates a new PostgreSQL CDC reader with the given configuration.

func (*Reader) LastLSN

func (r *Reader) LastLSN() string

LastLSN returns the last processed LSN.

func (*Reader) Name

func (r *Reader) Name() string

Name returns the name of this source.

func (*Reader) Start

func (r *Reader) Start(ctx context.Context) (<-chan cdc.Event, <-chan error)

Start begins capturing CDC events from PostgreSQL.

func (*Reader) Stop

func (r *Reader) Stop(ctx context.Context) error

Stop gracefully stops the reader.

Jump to

Keyboard shortcuts

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