Expand description
Clock abstraction for deterministic time-dependent testing.
Inject Clock into any component that calls SystemTime::now(),
enabling unit tests to control time without real-time delays.
§Usage
Production code should accept Arc<dyn Clock> and use
SystemClock as the default:
use std::sync::Arc;
use fraiseql_core::utils::clock::{Clock, SystemClock};
struct MyComponent {
clock: Arc<dyn Clock>,
}
impl MyComponent {
pub fn new() -> Self {
Self { clock: Arc::new(SystemClock) }
}
pub fn new_with_clock(clock: Arc<dyn Clock>) -> Self {
Self { clock }
}
}Structs§
- System
Clock - Production clock: delegates to
SystemTime::now().
Traits§
- Clock
- Abstraction over the system clock.