reckon_db_store_registry (reckon_db v1.2.7)

View Source

Distributed 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

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

store_entry/0

-type store_entry() ::
          #store_entry{store_id :: atom(),
                       node :: node(),
                       config :: store_config(),
                       registered_at :: integer()}.

Functions

announce_store(StoreId, Config)

-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_store_info(StoreId)

-spec get_store_info(atom()) -> {ok, map()} | {error, not_found}.

Get detailed information about a specific store

handle_call(Request, From, State)

handle_cast(Msg, State)

handle_info(Info, State)

init(_)

list_stores()

-spec list_stores() -> {ok, [map()]} | {error, term()}.

List all known stores in the cluster

Returns stores from all nodes, including their node and config information.

list_stores_on_node(Node)

-spec list_stores_on_node(node()) -> {ok, [map()]} | {error, term()}.

List stores on a specific node

start_link()

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

Start the store registry

terminate(Reason, State)

unannounce_store(StoreId)

-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.