reckon_db_emitter_pool (reckon_db v5.11.14)
View SourceEmitter pool supervisor for reckon-db
Supervises a pool of emitter workers for a single subscription. Each subscription can have multiple emitter workers for load distribution.
Summary
Functions
Generate the name for an emitter pool
Run Fun in the section a subscription's pool is stopped or re-pointed in, on this node. The pools stopped here are this node's, and a subscriber that re-subscribes does so on its own node.
Start an emitter pool for a subscription
Start the emitter pool supervisor
Stop an emitter pool by key (deprecated, use stop_emitter/2)
Stop an emitter pool for a subscription
Stop the pool of a subscription whose subscriber Dead died, unless the subscription names another subscriber by now.
Update an emitter pool configuration
Types
-type subscription() :: #subscription{id :: binary(), type :: subscription_type(), selector :: binary() | map(), subscription_name :: binary(), subscriber_pid :: pid() | undefined, created_at :: integer(), pool_size :: pos_integer(), checkpoint :: non_neg_integer() | undefined, options :: map()}.
-type subscription_type() ::
stream | event_type | event_pattern | event_payload | by_stream | by_event_type |
by_event_pattern | by_event_payload | by_tags.
Functions
Generate the name for an emitter pool
Run Fun in the section a subscription's pool is stopped or re-pointed in, on this node. The pools stopped here are this node's, and a subscriber that re-subscribes does so on its own node.
-spec start_emitter(atom(), subscription()) -> {ok, pid()} | {error, term()}.
Start an emitter pool for a subscription
-spec start_link(atom(), subscription()) -> {ok, pid()} | {error, term()}.
Start the emitter pool supervisor
Stop an emitter pool by key (deprecated, use stop_emitter/2)
-spec stop_emitter(atom(), subscription()) -> ok | {error, term()}.
Stop an emitter pool for a subscription
Stop the pool of a subscription whose subscriber Dead died, unless the subscription names another subscriber by now.
The emitter that found Dead asks for this asynchronously, so a re-subscribe by the restarted subscriber can come first. It wrote the new pid and saw this pool running, so it started none: stopping the pool then left the new subscriber with no emitters (reckon-db#24). The check and the stop run under serialized/3, the same section as the re-subscribe's write and its pool check, so one of the two always sees what the other did.
-spec update_emitter(atom(), subscription()) -> ok | {error, term()}.
Update an emitter pool configuration