Expand description
Fallback chain adapter — tries services in priority order with per-service circuit breakers Fallback chain service adapter.
Implements crate::ports::ScrapingService by trying a prioritised list of inner services
with per-service circuit breakers. When a service’s circuit is Open or
its execution fails, the chain automatically moves to the next lower-priority
service.
§Behaviour
- Services are tried in registration order (index 0 = highest priority).
- A service is skipped when its circuit breaker is
crate::ports::CircuitState::Openand the reset timeout has not yet elapsed. The chain then probes it once the timeout passes (half-open probe). - On success the corresponding circuit breaker records the success and the result is returned immediately — no further services are tried.
- On failure the circuit breaker records the failure and the next service is tried.
- If every service is exhausted the last error is propagated.
§Example
use std::sync::Arc;
use std::time::Duration;
use stygian_graph::adapters::fallback::FallbackChainService;
use stygian_graph::adapters::noop::NoopService;
use stygian_graph::adapters::resilience::CircuitBreakerImpl;
let chain = FallbackChainService::builder()
.add(Arc::new(NoopService), CircuitBreakerImpl::new(3, Duration::from_secs(30)))
.named("primary-with-plugin-fallback")
.build();Structs§
- Fallback
Chain Builder - Builder for
FallbackChainService. - Fallback
Chain Service - A
ScrapingServicethat tries multiple inner services in priority order, automatically routing around open circuit breakers and failed services.
Functions§
- default_
fallback_ breaker - Sensible default for a production circuit breaker on a fallback scraper.
- default_
primary_ breaker - Sensible default for a production circuit breaker on a primary scraper.