A3S Search
Configuration
HCL configuration files and health monitoring for engine management
Configuration
A3S Search supports HCL configuration files for engine settings and health monitoring. Load settings from a .hcl file instead of hardcoding them.
HCL Config File
timeout = 10
health {
max_failures = 5
suspend_seconds = 120
}
engine "ddg" {
enabled = true
weight = 1.0
}
engine "brave" {
enabled = true
weight = 1.0
}
engine "bing" {
enabled = true
weight = 1.2
}
engine "wiki" {
enabled = true
weight = 1.5
}
engine "sogou" {
enabled = false
}Loading Config
use a3s_search::config::SearchConfig;
// Load from file
let config = SearchConfig::load("search.hcl")?;
// Or parse a string
let config = SearchConfig::parse(r#"
timeout = 10
engine "ddg" { enabled = true }
"#)?;Prop
Type
Health Monitor
HealthMonitor tracks per-engine failure counts and automatically suspends engines after repeated failures. Suspended engines are re-enabled after a configurable duration.
use a3s_search::{Search, HealthConfig};
use a3s_search::engines::{DuckDuckGo, Brave, Bing};
use std::time::Duration;
let mut search = Search::with_health_config(HealthConfig {
max_failures: 3,
suspend_duration: Duration::from_secs(120),
});
search.add_engine(DuckDuckGo::new());
search.add_engine(Brave::new());
search.add_engine(Bing::new());
// If DuckDuckGo fails 3 times consecutively, it is suspended for 120 seconds.
// After 120 seconds, it is automatically re-enabled for the next search.HealthConfig
Prop
Type
Behavior
- Each engine starts with a failure count of 0
- On failure, the count increments
- On success, the count resets to 0
- When
count >= max_failures, the engine is suspended - After
suspend_duration, the engine is re-enabled and the count resets
From HCL Config
Combine HCL config with health monitoring:
use a3s_search::{Search, SearchQuery};
use a3s_search::config::SearchConfig;
use a3s_search::engines::{DuckDuckGo, Brave, Bing, Wikipedia};
let config = SearchConfig::load("search.hcl")?;
let mut search = if let Some(health) = config.health_config() {
Search::with_health_config(health)
} else {
Search::new()
};
// Add only engines enabled in config
for shortcut in config.enabled_engines() {
match shortcut.as_str() {
"ddg" => search.add_engine(DuckDuckGo::new()),
"brave" => search.add_engine(Brave::new()),
"bing" => search.add_engine(Bing::new()),
"wiki" => search.add_engine(Wikipedia::new()),
_ => {}
}
}
let results = search.search(SearchQuery::new("rust")).await?;