camel-config
Configuration management for the Rust Camel framework. Provides profile-based configuration with environment variable overrides and supervision settings.
Overview
camel-config manages application configuration through:
- Camel.toml files - Central configuration file
- Profile support - Environment-specific settings ([default], [production], etc.)
- Environment variables - Override any setting with
CAMEL_*variables - Route discovery - Automatic route file discovery via glob patterns
- Supervision configuration - Retry and backoff settings for route supervision
Features
- 🎯 Profile-based configuration - Deep merge of profile settings with defaults
- 🌍 Environment variable overrides - Override any config value with
CAMEL_*prefix - 📁 Route discovery - Automatic route file discovery from glob patterns
- ⚙️ Supervision settings - Configure retry strategies and backoff policies
- 🔄 Hot reload support - Optional file watching for configuration changes
Camel.toml Format
Create a Camel.toml file in your project root:
[]
= ["routes/*.yaml"]
= false
= "info"
= 30
[]
= 1000
= 2.0
= 60000
= 5
[]
= "warn"
= false
[]
= 5000
= 10
[]
= "debug"
= true
Configuration Sections
[default]- Base configuration (required)[default.supervision]- Default supervision settings[<profile>]- Profile-specific overrides (merged with default)[<profile>.supervision]- Profile-specific supervision overrides
Key Fields
| Field | Type | Description |
|---|---|---|
routes |
[String] |
Glob patterns for route files |
watch |
bool |
Enable hot reload on file changes |
log_level |
String |
Logging level (trace/debug/info/warn/error) |
shutdown_timeout_secs |
u64 |
Graceful shutdown timeout |
supervision.initial_delay_ms |
u64 |
Initial retry delay |
supervision.backoff_multiplier |
f64 |
Exponential backoff multiplier |
supervision.max_delay_ms |
u64 |
Maximum retry delay cap |
supervision.max_attempts |
u32 |
Maximum retry attempts (0 = unlimited) |
Profile Selection
Set the active profile via the CAMEL_PROFILE environment variable:
# Use production profile
# Use development profile
If not set, defaults to the [default] profile only.
Environment Variables
Override any configuration value with environment variables using the CAMEL_ prefix:
# Override log level
# Override watch mode
# Override supervision settings
# Override routes
Environment variables take precedence over file configuration and are applied after profile merging.
Usage
Basic Usage
use CamelConfig;
// Load from Camel.toml in current directory
let config = from_file?;
// Access configuration values
println!;
println!;
With Profile
use CamelConfig;
// Load with profile (reads CAMEL_PROFILE env var or uses default)
let config = from_file_with_profile?;
// The profile is automatically merged with [default]
With Environment Variables
use CamelConfig;
// Load with full override support (profile + env vars)
let config = from_file_with_env?;
// Environment variables override all other sources
Accessing Supervision Configuration
use CamelConfig;
let config = from_file?;
if let Some = &config.supervision
Installation
Add to your Cargo.toml:
[]
= "0.1"
Related Crates
- camel-core - Core framework and context
- camel-dsl - YAML route definitions and parsing
- camel-runtime - Route execution engine
Documentation
For more details, see the API documentation and the main Rust Camel project.