camel-config
Configuration system for rust-camel.
Overview
This crate provides configuration loading and route discovery for rust-camel applications.
Features
- Configuration Loading: Load configuration from TOML files
- Profile Support: Multiple environments (development, production, etc.)
- Environment Variables: Override configuration with
CAMEL_*prefix - Route Discovery: Auto-discover route files using glob patterns
Usage
Basic Usage
use CamelConfig;
use CamelContext;
// Load configuration
let config = from_file?;
// Create context
let mut ctx = new;
ctx.register_component;
// Load routes from discovered files
let routes = discover_routes?;
for route in routes
ctx.start.await?;
Configuration File
Create a Camel.toml file:
[]
= ["routes/**/*.yaml"]
= "INFO"
[]
= "ERROR"
Profile Selection
// Via environment variable
set_var;
// Or programmatically
let config = from_file_with_profile?;
Environment Variables
Override any configuration value:
Route Discovery
Routes are discovered using glob patterns:
# routes/my-route.yaml
routes:
- id: "hello-timer"
from: "timer:tick?period=1000"
steps:
- to: "log:info"
API
CamelConfig
from_file(path)- Load configuration from filefrom_file_with_profile(path, profile)- Load with specific profilefrom_file_with_profile_and_env(path, profile)- Load with env var overrides
discover_routes
discover_routes(patterns)- Discover route files matching patterns
Configuration Schema
[]
= ["routes/**/*.yaml"]
= "INFO" | "DEBUG" | "WARN" | "ERROR"
= 5000
[]
= 1000
[]
= 5000
= 100
[]
= true
= false
[]
= "ERROR"
Examples
See the examples/ directory:
config-basic- Basic configuration usageconfig-profiles- Multi-environment setup
License
Apache-2.0