reckon_db_store_coordinator (reckon_db v5.11.4)
View SourceStore coordinator for reckon-db
Coordinates cluster join operations and prevents split-brain scenarios.
Responsibilities: - Detecting existing clusters via RPC - Coordinator election (lowest node name) - Coordinated cluster joining - Split-brain prevention
Summary
Functions
Check if this node is the leader
Join the Khepri cluster using coordinated approach.
Join a specific node's cluster.
Get current leader node
Get cluster members
Check if this node should handle nodeup events.
Types
-type integrity_config() :: disabled | #{enabled := true, key_source := integrity_key_source()}.
-type integrity_key_source() :: {env_var, EnvName :: binary()} | {sealed_file, Path :: file:filename()}.
-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(), integrity :: integrity_config(), indexes :: [index_decl()]}.
Functions
Check if this node is the leader
Join the Khepri cluster using coordinated approach.
Returns {error, not_started} if the coordinator process isn't registered yet (startup race or after a store stop). gen_server:call/3 throws {exit, {noproc}} as an exception when the target process doesn't exist — the guard converts that to an error tuple.
Join a specific node's cluster.
Returns {error, not_started} if the coordinator process isn't registered.
Get current leader node
Get cluster members
Check if this node should handle nodeup events.
Returns false if the coordinator isn't running — a store without a coordinator should not handle nodeup events.
-spec start_link(store_config()) -> {ok, pid()} | {error, term()}.