ExESDB.StoreManager (ex_esdb v0.1.0)

Manages multiple event stores dynamically within a single ExESDB cluster.

This module provides the API for creating, starting, stopping, and managing multiple stores at runtime. Each store has its own unique identifier and operates independently within the shared cluster infrastructure.

Summary

Functions

Returns a specification to start this module under a supervisor.

Creates and starts a new store with the given store_id and configuration.

Gets the configuration for a specific store.

Gets the status of a specific store.

Lists all currently managed stores and their status.

Stops and removes a store from the manager.

Types

store_config()

@type store_config() :: keyword()

store_id()

@type store_id() :: atom()

store_status()

@type store_status() :: :starting | :running | :stopping | :stopped | :error

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

create_store(store_id, config \\ [])

@spec create_store(store_id(), store_config()) :: {:ok, store_id()} | {:error, term()}

Creates and starts a new store with the given store_id and configuration.

Parameters

  • store_id: Unique identifier for the store (atom)
  • config: Optional configuration overrides (keyword list)

Returns

  • {:ok, store_id} if successful
  • {:error, reason} if failed

get_store_config(store_id)

@spec get_store_config(store_id()) :: {:ok, store_config()} | {:error, :not_found}

Gets the configuration for a specific store.

Parameters

  • store_id: The store identifier

Returns

  • {:ok, store_config} if store exists
  • {:error, :not_found} if store doesn't exist

get_store_status(store_id)

@spec get_store_status(store_id()) :: {:ok, store_status()} | {:error, :not_found}

Gets the status of a specific store.

Parameters

  • store_id: The store identifier

Returns

  • {:ok, store_status} if store exists
  • {:error, :not_found} if store doesn't exist

list_stores()

@spec list_stores() :: map()

Lists all currently managed stores and their status.

Returns

  • %{store_id => %{status: store_status, config: store_config}}

remove_store(store_id)

@spec remove_store(store_id()) :: :ok | {:error, term()}

Stops and removes a store from the manager.

Parameters

  • store_id: The store identifier to remove

Returns

  • :ok if successful
  • {:error, reason} if failed

start_link(default_config)