Replicant.Decoder (Replicant v0.1.0)

Copy Markdown View Source

Binary decoder for the Postgres logical-replication pgoutput stream.

The byte parser (decode_message/1) is vendored from walex (MIT; see NOTICE), itself derived from cainophile and supabase-realtime. It raises on malformed input and produces %Unsupported{data: binary} (carrying raw bytes) for unknown message types.

Callers MUST use decode/1, not decode_message/1. decode/1 is the value-free-error boundary (Critical Rule 1): it catches every raise, scrubs the raw bytes, and normalises %Unsupported{} into a value-free {:error, %Replicant.Error{reason: :unsupported_message}}. No row value or raw WAL byte ever escapes the decode boundary.

Summary

Functions

Decode one pgoutput message, value-free on failure.

Functions

decode(binary, opts \\ [])

@spec decode(
  binary(),
  keyword()
) :: {:ok, struct()} | {:error, Replicant.Error.t()}

Decode one pgoutput message, value-free on failure.

Returns {:ok, message_struct} on success, or {:error, %Error{reason: :decode_failure | :unsupported_message}} — never raises, never surfaces raw bytes.