Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

AngaraStream

AngaraStream provides Change Data Capture (CDC) for AngaraBase via subscriptions over a table’s change log.

API

-- create a subscription on a table's DML events
CREATE SUBSCRIPTION "my-sub" ON TABLE public.orders
  FOR EVENTS (INSERT, UPDATE, DELETE)
  WITH (start_offset = 'latest');

-- poll up to N events (does NOT advance the cursor)
SELECT * FROM angara_stream_poll('my-sub', batch_size => 100);

-- acknowledge up to an offset (advances the cursor)
SELECT angara_stream_ack('my-sub', offset => 42);

-- remove the subscription
DROP SUBSCRIPTION "my-sub";

FOR EVENTS (...) may list any subset of INSERT/UPDATE/DELETE; an empty list defaults to all three.

start_offset semantics

The start_offset WITH-option controls which events a new subscription sees.

ValueBehaviour
'latest' (default)Skips history. Only events published after the subscription is created are delivered.
'earliest'Delivers events currently retained in the buffer, starting from the oldest retained event.

The change-log buffer is bounded: events older than the retained window have already been evicted and are not delivered even with 'earliest' — the cursor starts at the oldest event still in the buffer. For a full re-seed you must drop and recreate the subscription (and reload the table out of band):

DROP SUBSCRIPTION "my-sub";
CREATE SUBSCRIPTION "my-sub" ON TABLE public.orders
  FOR EVENTS (INSERT, UPDATE, DELETE)
  WITH (start_offset = 'earliest');

SQLSTATE

SituationSQLSTATE
CREATE SUBSCRIPTION of an existing name42710 (duplicate_object)
Poll/ack/drop of a non-existent subscription42704 (undefined_object)
Invalid subscription name42602 (invalid_name)
Malformed statement42601 (syntax_error)