Copyright | (c) James King 2020 2021 |
---|---|
License | BSD3 |
Maintainer | [email protected] |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Database.PostgreSQL.Replicant.Protocol
Description
This module implements the Postgres streaming replication protocol.
See: https://www.postgresql.org/docs/9.5/protocol-replication.html
Synopsis
- data IdentifySystem = IdentifySystem {}
- identifySystemCommand :: ByteString
- identifySystemSync :: ReplicantConnection -> IO (Maybe IdentifySystem)
- startReplicationCommand :: ReplicantConnection -> ByteString -> LSN -> IO ByteString
- handleCopyOutData :: TChan PrimaryKeepAlive -> WalProgressState -> ReplicantConnection -> (Change -> IO LSN) -> IO ()
- handleReplicationRow :: TChan PrimaryKeepAlive -> WalProgressState -> ReplicantConnection -> ByteString -> (Change -> IO LSN) -> IO ()
- handleReplicationError :: ReplicantConnection -> IO ()
- handleReplicationNoop :: IO ()
- startReplicationStream :: ReplicantConnection -> ByteString -> LSN -> Int -> (Change -> IO LSN) -> IO ()
- keepAliveHandler :: ReplicantConnection -> TChan PrimaryKeepAlive -> WalProgressState -> IO ()
- sendStatusUpdate :: ReplicantConnection -> WalProgressState -> IO ()
Documentation
data IdentifySystem Source #
The information returned by the IDENTIFY_SYSTEM
command
establishes the stream's log start, position, and information about
the database.
Constructors
IdentifySystem | |
Instances
Eq IdentifySystem Source # | |
Defined in Database.PostgreSQL.Replicant.Protocol Methods (==) :: IdentifySystem -> IdentifySystem -> Bool # (/=) :: IdentifySystem -> IdentifySystem -> Bool # | |
Show IdentifySystem Source # | |
Defined in Database.PostgreSQL.Replicant.Protocol Methods showsPrec :: Int -> IdentifySystem -> ShowS # show :: IdentifySystem -> String # showList :: [IdentifySystem] -> ShowS # |
identifySystemSync :: ReplicantConnection -> IO (Maybe IdentifySystem) Source #
Synchronously execute the IDENTIFY SYSTEM
command which returns
some basic system information about the server.
startReplicationCommand :: ReplicantConnection -> ByteString -> LSN -> IO ByteString Source #
Create a START_REPLICATION_SLOT
query, escaping the slot name
passed in by the user.
handleCopyOutData :: TChan PrimaryKeepAlive -> WalProgressState -> ReplicantConnection -> (Change -> IO LSN) -> IO () Source #
This handles the COPY OUT mode messages. PostgreSQL uses this mode to copy the data from a WAL log file to the socket in the streaming replication protocol.
handleReplicationRow :: TChan PrimaryKeepAlive -> WalProgressState -> ReplicantConnection -> ByteString -> (Change -> IO LSN) -> IO () Source #
handleReplicationError :: ReplicantConnection -> IO () Source #
Used to re-throw an exception received from the server.
handleReplicationNoop :: IO () Source #
startReplicationStream :: ReplicantConnection -> ByteString -> LSN -> Int -> (Change -> IO LSN) -> IO () Source #
Initiate the streaming replication protocol handler. This will race the keep-alive and copy data handler threads. It will catch and rethrow exceptions from either thread if any fails or returns.
keepAliveHandler :: ReplicantConnection -> TChan PrimaryKeepAlive -> WalProgressState -> IO () Source #
This listens on the channel for primary keep-alive messages from the server and responds to them with the update status message using the current WAL stream state. It will attempt to buffer prior update messages when the socket is blocked.
sendStatusUpdate :: ReplicantConnection -> WalProgressState -> IO () Source #