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.
| Value | Behaviour |
|---|---|
'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
| Situation | SQLSTATE |
|---|---|
CREATE SUBSCRIPTION of an existing name | 42710 (duplicate_object) |
| Poll/ack/drop of a non-existent subscription | 42704 (undefined_object) |
| Invalid subscription name | 42602 (invalid_name) |
| Malformed statement | 42601 (syntax_error) |