ExESDB.Config (ex_esdb v0.1.0)
Configuration validation and normalization for ExESDB.
This module provides standardized configuration handling with proper validation, error handling, and normalization to ensure consistent behavior across the system.
Summary
Functions
Gets the data directory from configuration or environment.
Gets the database type from configuration or environment.
Gets the PubSub configuration from configuration or environment.
Gets the reader idle timeout from configuration or environment.
Gets the store ID from configuration or environment.
Gets the timeout from configuration or environment.
Checks if libcluster should be used for node discovery.
Validates and normalizes configuration for ExESDB.
Validates libcluster topology configuration.
Gets the writer idle timeout from configuration or environment.
Types
@type config() :: Keyword.t()
@type data_dir() :: String.t()
@type db_type() :: :single | :cluster
@type idle_ms() :: non_neg_integer()
@type pub_sub() :: atom()
@type store_id() :: atom()
@type time_out() :: non_neg_integer()
Functions
Gets the data directory from configuration or environment.
Gets the database type from configuration or environment.
Gets the PubSub configuration from configuration or environment.
Gets the reader idle timeout from configuration or environment.
Gets the store ID from configuration or environment.
Gets the timeout from configuration or environment.
Checks if libcluster should be used for node discovery.
Validates and normalizes configuration for ExESDB.
Options
:store_id
- Unique identifier for the store (required):data_dir
- Directory for data storage (required):timeout
- Operation timeout in milliseconds (default: 10_000):db_type
- Database type:single
or:cluster
(default::single
):pub_sub
- PubSub mechanism identifier (default::native
):writer_idle_ms
- Writer idle timeout in milliseconds (default: 10_000):reader_idle_ms
- Reader idle timeout in milliseconds (default: 10_000):use_libcluster
- Whether to use libcluster for node discovery (default:true
)
Examples
iex> ExESDB.Config.validate([store_id: :my_store, data_dir: "/tmp/data"])
{:ok, %{store_id: :my_store, data_dir: "/tmp/data", timeout: 10_000, ...}}
iex> ExESDB.Config.validate([])
{:error, {:missing_required_config, [:store_id, :data_dir]}}
Validates libcluster topology configuration.
Gets the writer idle timeout from configuration or environment.