barrel_changes_stream (barrel_docdb v1.2.0)
View SourceChanges stream for barrel_docdb
A gen_statem process that provides a streaming interface to the changes feed. Supports two modes: - iterate: Pull-based, client calls next/1 to get changes - push: Push-based, changes are sent to subscriber
Summary
Functions
Acknowledge receipt of changes (push mode)
Wait for changes (push mode)
Wait for changes with timeout (push mode). Distinguishes a genuine timeout (timeout) from the stream process dying (down), so a caller polling on a bounded timeout can tell "nothing new yet" from "this stream is gone."
Get the next change (iterate mode)
Start a changes stream
Stop the stream
Types
-type att_info() :: #{name := binary(), content_type := binary(), length := non_neg_integer(), digest := binary(), chunked => boolean(), chunk_size => pos_integer(), chunk_count => pos_integer()}.
-type change() :: map().
-type db_name() :: binary().
-type docid() :: binary().
-type revid() :: binary().
-type seq() :: barrel_hlc:timestamp().
-type seq_string() :: binary().
-type stream_mode() :: iterate | push.
-type stream_opts() :: #{since => seq() | first, mode => stream_mode(), include_docs => boolean(), interval => pos_integer(), batch_size => pos_integer(), owner => pid()}.
-type view_name() :: binary().
Functions
Acknowledge receipt of changes (push mode)
-spec await(pid()) -> {reference(), [barrel_changes:change()]} | down.
Wait for changes (push mode)
-spec await(pid(), timeout()) -> {reference(), [barrel_changes:change()]} | timeout | down.
Wait for changes with timeout (push mode). Distinguishes a genuine timeout (timeout) from the stream process dying (down), so a caller polling on a bounded timeout can tell "nothing new yet" from "this stream is gone."
-spec next(pid()) -> {ok, barrel_changes:change()} | done | {error, term()}.
Get the next change (iterate mode)
-spec start_link(barrel_store_rocksdb:db_ref(), db_name(), stream_opts()) -> {ok, pid()} | {error, term()}.
Start a changes stream
-spec stop(pid()) -> ok.
Stop the stream