reliakit-core 1.0.0

Shared building blocks for Reliakit: a clock-agnostic Clock trait with manual and monotonic clocks. no_std and zero-dependency.
Documentation
  • Coverage
  • 100%
    10 out of 10 items documented1 out of 9 items with examples
  • Size
  • Source code size: 13.03 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 390.95 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 3s Average build duration of successful builds.
  • all releases: 3s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • satyakwok/reliakit
    7 2 17
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • satyakwok

reliakit-core

Crates.io Crates.io Downloads Docs.rs CI codecov License: MIT zero dependencies

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 single now(&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 by std::time::Instant, so it never goes backwards and ignores wall-clock adjustments. Requires the std feature.

Installation

[dependencies]
reliakit-core = "1.0"

Disable default features for no_std; ManualClock and the Clock trait work without std, while MonotonicClock needs the default std feature.

Example

use reliakit_core::{Clock, ManualClock};

let clock = ManualClock::new(0);
clock.advance(250);
assert_eq!(clock.now(), 250);

// 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.