Copyright | (c) James King 2020 2021 |
---|---|
License | BSD3 |
Maintainer | [email protected] |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
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
- withLogicalStream :: PgSettings -> (Change -> IO a) -> IO ()
- data PgSettings = PgSettings {}
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 | |
Instances
Eq PgSettings Source # | |
Defined in Database.PostgreSQL.Replicant | |
Show PgSettings Source # | |
Defined in Database.PostgreSQL.Replicant Methods showsPrec :: Int -> PgSettings -> ShowS # show :: PgSettings -> String # showList :: [PgSettings] -> ShowS # |