Integrate.Replication.Client (IntegrateDB v0.1.0) View Source

Database replication client.

Uses :epgsql for it's start_replication function. Borrows the connection config from the Integrate.Repo is need be. Note that epgsql doesn't support connecting via a unix socket.

Link to this section Summary

Functions

Confirm successful processing of a WAL segment.

Create a database connection.

Ensure there is a replication slot called name.

Execute a query / sql statement.

Start consuming logical replication feed using a given publication and slot.

Link to this section Functions

Link to this function

acknowledge_lsn(conn, lsn_tup)

View Source

Confirm successful processing of a WAL segment.

Returns :ok on success.

Create a database connection.

Uses the Integrate.Repo config as default, can be overriden by passing in epqsql config directly opts.

Returns {:ok, conn} or {:error, reason}.

Link to this function

ensure_replication_slot(conn, slot)

View Source

Ensure there is a replication slot called name.

Returns :ok on success.

Execute a query / sql statement.

Returns {:ok, cols, rows} or {:error, error}.

Link to this function

start_replication(conn, publication, slot, handler)

View Source

Start consuming logical replication feed using a given publication and slot.

The handler can be a pid or a module implementing the handle_x_log_data callback.

Returns :ok on success.