reckon_db_store_registry (reckon_db v1.6.0)
View SourceDistributed store registry for reckon-db
Provides cluster-wide store registration and discovery using Erlang's built-in pg (process groups) module for distributed membership.
Architecture
Each node runs a store registry GenServer that:
- Maintains a local list of known stores (from all nodes)
- Announces local stores to registries on other nodes
- Receives announcements from other nodes
- Uses pg groups for registry discovery
Cluster-Wide Discovery
When a store starts on any node:
1. Local store calls announce_store/2 with its config
2. Registry adds store to local state
3. Registry broadcasts to all other registries via pg
4. Other registries add the store to their state
When a node goes down, pg automatically notifies remaining nodes and registries remove stores from the dead node.
Summary
Functions
Announce a store to the cluster
Get detailed information about a specific store
List all known stores in the cluster
List stores on a specific node
Start the store registry
Unannounce a store from the cluster
Types
-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()}.
-type store_entry() :: #store_entry{store_id :: atom(), node :: node(), config :: store_config(), registered_at :: integer()}.
Functions
-spec announce_store(atom(), store_config()) -> ok.
Announce a store to the cluster
Called by reckon_db_store when a store starts. This registers the store locally and broadcasts to all other registries in the cluster.
Get detailed information about a specific store
List all known stores in the cluster
Returns stores from all nodes, including their node and config information.
List stores on a specific node
Start the store registry
-spec unannounce_store(atom()) -> ok.
Unannounce a store from the cluster
Called when a store is stopping. Removes the store from local registry and broadcasts removal to all other registries.