Documentation ¶
Index ¶
- Variables
- func CreatePublication(ctx context.Context, conn *pgxpool.Pool, name string, ...) error
- func DropPublication(ctx context.Context, conn *pgxpool.Pool, name string, ...) error
- func IsPgDuplicateErr(err error) bool
- type CreatePublicationOptions
- type DropPublicationOptions
- type Handler
- type ReadReplicationSlotResult
- type RelationSet
- type Subscription
- func (s *Subscription) Ack(lsn pglogrepl.LSN)
- func (s *Subscription) Done() <-chan struct{}
- func (s *Subscription) Err() error
- func (s *Subscription) Ready() <-chan struct{}
- func (s *Subscription) Run(ctx context.Context) error
- func (s *Subscription) Stop()
- func (s *Subscription) Teardown(ctx context.Context) error
- func (s *Subscription) Wait(ctx context.Context, timeout time.Duration) error
Constants ¶
This section is empty.
Variables ¶
var ErrMissingSlot = errors.New("replication slot missing")
Functions ¶
func CreatePublication ¶
func CreatePublication(ctx context.Context, conn *pgxpool.Pool, name string, opts CreatePublicationOptions) error
CreatePublication creates a publication.
func DropPublication ¶
func DropPublication(ctx context.Context, conn *pgxpool.Pool, name string, opts DropPublicationOptions) error
DropPublication drops a publication.
func IsPgDuplicateErr ¶ added in v0.7.1
Types ¶
type CreatePublicationOptions ¶
CreatePublicationOptions contains additional options for creating a publication. If AllTables and Tables are both true and not empty at the same time, publication creation will fail.
type DropPublicationOptions ¶
type DropPublicationOptions struct {
IfExists bool
}
DropPublicationOptions contains additional options for dropping a publication.
type ReadReplicationSlotResult ¶ added in v0.7.4
type ReadReplicationSlotResult struct { Name string ConfirmedFlushLSN pglogrepl.LSN RestartLSN pglogrepl.LSN }
func ReadReplicationSlot ¶ added in v0.7.4
func ReadReplicationSlot(ctx context.Context, conn *pgxpool.Pool, name string) (ReadReplicationSlotResult, error)
ReadReplicationSlot returns state of an existing replication slot.
type RelationSet ¶
type RelationSet struct {
// contains filtered or unexported fields
}
RelationSet can be used to build a cache of relations returned by logical replication.
func (*RelationSet) Add ¶
func (rs *RelationSet) Add(r *pglogrepl.RelationMessage)
func (*RelationSet) Get ¶
func (rs *RelationSet) Get(id uint32) (*pglogrepl.RelationMessage, error)
type Subscription ¶
type Subscription struct { SlotName string Publication string Tables []string StartLSN pglogrepl.LSN Handler Handler StatusTimeout time.Duration TXSnapshotID string // contains filtered or unexported fields }
Subscription manages a subscription to a logical replication slot.
func CreateSubscription ¶ added in v0.7.1
func CreateSubscription( ctx context.Context, pool *pgxpool.Pool, slotName, publication string, tables []string, startLSN pglogrepl.LSN, h Handler, ) (*Subscription, error)
CreateSubscription initializes the logical replication subscriber by creating the replication slot.
func (*Subscription) Ack ¶
func (s *Subscription) Ack(lsn pglogrepl.LSN)
Ack stores the LSN as flushed. Next time WAL positions are flushed, Postgres will know it can purge WAL logs up to this LSN.
func (*Subscription) Done ¶
func (s *Subscription) Done() <-chan struct{}
Done returns a channel that is closed when the subscription is done.
func (*Subscription) Err ¶
func (s *Subscription) Err() error
Err returns an error that might have happened when the subscription stopped running.
func (*Subscription) Ready ¶
func (s *Subscription) Ready() <-chan struct{}
Ready returns a channel that is closed when the subscription is ready and receiving messages.
func (*Subscription) Run ¶ added in v0.7.1
func (s *Subscription) Run(ctx context.Context) error
Run logical replication listener and block until error or ctx is canceled.
func (*Subscription) Stop ¶
func (s *Subscription) Stop()
Stop signals to the subscription it should stop. Call Wait to block until the subscription actually stops running.