postgresql-replicant-0.1.0.1: PostgreSQL logical streaming replication library
Copyright(c) James King 2020 2021
LicenseBSD3
Maintainerjames@agentultra.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Database.PostgreSQL.Replicant

Description

Connect to a PostgreSQL server as a logical replication client and receive changes.

The basic API is this:

  withLogicalStream defaultSettings $ change -> do
    print change
    catch err -> do
      show err

This is a low-level library meant to give the primitives necessary to library authors to add streaming replication support. The API here to rather simplistic but should be hooked up to something like conduit to provide better ergonomics.

Synopsis

Documentation

withLogicalStream :: PgSettings -> (Change -> IO a) -> IO () Source #

Connect to a PostgreSQL database as a user with the replication attribute and start receiving changes using the logical replication protocol. Logical replication happens at the query level so the changes you get represent the set of queries in a transaction: insert, update, and delete.

This function will create the replication slot, if it doesn't exist, or reconnect to it otherwise and restart the stream from where the replication slot left off.

This function can throw exceptions in IO and shut-down the socket in case of any error.

data PgSettings Source #

Constructors

PgSettings 

Fields

Instances

Instances details
Eq PgSettings Source # 
Instance details

Defined in Database.PostgreSQL.Replicant

Show PgSettings Source # 
Instance details

Defined in Database.PostgreSQL.Replicant