reliakit-core
Shared building blocks for the Reliakit workspace.
Reliakit's resilience crates (reliakit-backoff, reliakit-circuit,
reliakit-ratelimit, reliakit-timeout) are clock-agnostic: you pass the
current time in as a u64 tick in any monotonic unit. reliakit-core provides
the small piece they share — a Clock trait plus ready-made clocks — so you do
not have to hand-roll one.
The crate has no dependencies and forbids unsafe code.
What This Crate Does
Clock— a trait with a singlenow(&self) -> u64. There is a blanket impl for&C, and it is object-safe (&dyn Clock).ManualClock— a settable clock for deterministic tests (new,set,advance); uses interior mutability so every method takes&self.no_std.MonotonicClock— milliseconds since creation, backed bystd::time::Instant, so it never goes backwards and ignores wall-clock adjustments. Requires thestdfeature.
Installation
[]
= "0.1"
Disable default features for no_std; ManualClock and the Clock trait work
without std, while MonotonicClock needs the default std feature.
Example
use ;
let clock = new;
clock.advance;
assert_eq!;
// Feed `clock.now()` into any clock-agnostic Reliakit policy, e.g.
// `breaker.allow(clock.now())` or `limiter.try_acquire_one(clock.now())`.
Feature flags
| Feature | Default | Effect |
|---|---|---|
std |
yes | Enables MonotonicClock (real monotonic time). |
Safety
This crate is #![forbid(unsafe_code)] and no_std (with the default std
feature adding MonotonicClock). Clock arithmetic saturates.
Minimum Supported Rust Version
Rust 1.85 and newer. No nightly features are used.
Status
Published to crates.io and pre-1.0. The crate is intentionally minimal — a
Clock trait plus two clocks — and its API may receive backward-compatible
refinements before a 1.0 release.
License
Licensed under the MIT License. See LICENSE.