ExESDB.Commanded.Config (ex_esdb_commanded v0.1.0)
Configuration validation and normalization for ExESDB.Commanded.Adapter.
This module provides standardized configuration handling with proper validation, error handling, and normalization to ensure consistent behavior between Commanded and ExESDB systems.
Summary
Functions
Gets the connection timeout from configuration or environment.
Gets the retry attempts from configuration or environment.
Gets the retry backoff from configuration or environment.
Gets the serializer module from configuration or environment.
Gets the store ID from configuration or environment.
Gets the stream prefix from configuration or environment.
Checks if libcluster should be used for node discovery.
Validates and normalizes configuration for ExESDB.Commanded.Adapter.
Validates libcluster topology configuration.
Validates that the serializer module is available and has required functions.
Types
Functions
@spec connection_timeout(config()) :: pos_integer()
Gets the connection timeout from configuration or environment.
@spec retry_attempts(config()) :: non_neg_integer()
Gets the retry attempts from configuration or environment.
@spec retry_backoff(config()) :: pos_integer()
Gets the retry backoff from configuration or environment.
Gets the serializer module from configuration or environment.
Gets the store ID from configuration or environment.
Gets the stream prefix from configuration or environment.
Stream prefixes cannot contain dashes to avoid conflicts with ExESDB internal naming conventions.
Checks if libcluster should be used for node discovery.
@spec validate(config()) :: {:ok, adapter_config()} | {:error, {atom(), term()}}
Validates and normalizes configuration for ExESDB.Commanded.Adapter.
Options
:store_id
- ExESDB store identifier (required):stream_prefix
- Prefix for all streams (default: ""):serializer
- Serialization module (default: Jason):use_libcluster
- Whether to use libcluster for node discovery (default: true):connection_timeout
- Connection timeout in ms (default: 10_000):retry_attempts
- Number of retry attempts for failed operations (default: 3):retry_backoff
- Backoff interval between retries in ms (default: 1_000)
Examples
iex> ExESDB.Commanded.Config.validate([store_id: :my_store])
{:ok, %{store_id: :my_store, stream_prefix: "", ...}}
iex> ExESDB.Commanded.Config.validate([])
{:error, {:missing_required_config, [:store_id]}}
Validates libcluster topology configuration.
Validates that the serializer module is available and has required functions.