Electric.Postgres.ReplicationClient.MessageConverter (electric v1.4.13)
View SourceConversion of incoming Postgres logical replication messages to internal event representation.
It is stateful, consuming the replication messages in sequential order to keep track of the relation and transaction information needed to form the operations.
It also enforces a maximum transaction size if configured to do so, and batches operations up to a maximum batch size before returning a TransactionFragment.
Summary
Functions
Convert incoming logical replication messages to internal change representation.
Types
@type t() :: %Electric.Postgres.ReplicationClient.MessageConverter{ max_batch_size: non_neg_integer(), max_tx_size: non_neg_integer() | nil, relations: %{ optional(Electric.Postgres.LogicalReplication.Messages.relation_id()) => Electric.Postgres.LogicalReplication.Messages.Relation.t() }, tx_change_count: non_neg_integer(), tx_op_index: non_neg_integer() | nil, tx_size: non_neg_integer(), txn_fragment: Electric.Replication.Changes.TransactionFragment.t() | nil }
Functions
@spec convert(Electric.Postgres.LogicalReplication.Messages.message(), t()) :: {:ok, Electric.Replication.Changes.TransactionFragment.t() | Electric.Replication.Changes.Relation.t(), t()} | {:buffering, t()} | {:error, {:replica_not_full, String.t()}} | {:error, {:exceeded_max_tx_size, String.t()}}
Convert incoming logical replication messages to internal change representation.
Returns:
{:ok, %TransactionFragment{}, state}when a batch is ready (on commit or max_batch_size reached){:ok, %Relation{}, state}when a Relation is encountered (returned immediately){:buffering, state}if no flush occurred{:error, reason}on error