Livekitex.Config (livekitex v0.1.0)
Configuration management for LiveKit Elixir SDK.
This module provides centralized configuration management with support for different environments (dev, test, prod) and runtime configuration.
Summary
Functions
Creates a client configuration map from the current config.
Gets the current configuration for the LiveKit SDK.
Gets a specific configuration value.
Gets the configuration for a specific environment.
Gets gRPC connection options from the current configuration.
Sets a runtime configuration value.
Resets runtime configuration to defaults.
Validates the current configuration.
Functions
Creates a client configuration map from the current config.
This is useful for creating service clients with the current configuration.
Examples
iex> Livekitex.Config.client_config()
%{
api_key: "your_api_key",
api_secret: "your_api_secret",
host: "localhost:7880"
}
Gets the current configuration for the LiveKit SDK.
Configuration is loaded from multiple sources in order of precedence:
- Runtime configuration (highest priority)
- Application environment
- System environment variables
- Default values (lowest priority)
Examples
iex> Livekitex.Config.get()
%{
host: "localhost:7880",
use_tls: false,
api_key: "your_api_key",
api_secret: "your_api_secret",
timeout: 30000,
...
}
Gets a specific configuration value.
Parameters
key
- Configuration key (atom)default
- Default value if key is not found
Examples
iex> Livekitex.Config.get(:host)
"localhost:7880"
iex> Livekitex.Config.get(:custom_key, "default_value")
"default_value"
Gets the configuration for a specific environment.
Parameters
env
- Environment atom (:dev, :test, :prod)
Examples
iex> Livekitex.Config.get_env_config(:prod)
%{host: "livekit.example.com:443", use_tls: true, ...}
Gets gRPC connection options from the current configuration.
Examples
iex> Livekitex.Config.grpc_options()
[
timeout: 30000,
max_retries: 3,
retry_delay: 1000,
pool_size: 10,
pool_max_overflow: 5
]
Sets a runtime configuration value.
This allows for dynamic configuration changes at runtime. Runtime configuration has the highest precedence.
Parameters
key
- Configuration key (atom)value
- Configuration value
Examples
iex> Livekitex.Config.put(:host, "production.livekit.io:443")
:ok
iex> Livekitex.Config.put(:use_tls, true)
:ok
Resets runtime configuration to defaults.
This removes all runtime configuration overrides.
Examples
iex> Livekitex.Config.reset()
:ok
Validates the current configuration.
Returns
{:ok, config}
- Configuration is valid{:error, reason}
- Configuration is invalid
Examples
iex> Livekitex.Config.validate()
{:ok, %{host: "localhost:7880", ...}}
iex> Livekitex.Config.validate()
{:error, "API key is required"}