reckon_db_leader (reckon_db v1.4.4)

View Source

Leader worker for reckon-db

Handles leader responsibilities when this node is the Raft leader.

Responsibilities: - Save default subscriptions (like $all stream) - Start emitter pools for active subscriptions - Coordinate leader-specific tasks

Summary

Functions

Activate leader responsibilities Called when this node becomes the cluster leader.

Check if leader is currently active

Types

store_config/0

-type store_config() ::
          #store_config{store_id :: atom(),
                        data_dir :: string(),
                        mode :: single | cluster,
                        timeout :: pos_integer(),
                        writer_pool_size :: pos_integer(),
                        reader_pool_size :: pos_integer(),
                        gateway_pool_size :: pos_integer(),
                        options :: map()}.

subscription/0

-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()}.

subscription_type/0

-type subscription_type() ::
          stream | event_type | event_pattern | event_payload | tags | by_stream | by_event_type |
          by_event_pattern | by_event_payload | by_tags.

Functions

activate(StoreId)

-spec activate(atom()) -> ok | {error, term()}.

Activate leader responsibilities Called when this node becomes the cluster leader.

handle_call(Request, From, State)

handle_cast(Msg, State)

handle_info(Info, State)

init(Store_config)

is_active(StoreId)

-spec is_active(atom()) -> boolean().

Check if leader is currently active

start_link(Store_config)

-spec start_link(store_config()) -> {ok, pid()} | {error, term()}.

terminate(Reason, State)