Skip to main content

KeelCore

Trait KeelCore 

Source
pub trait KeelCore {
    // Required methods
    fn configure(&mut self, policy_json: &Value) -> Result<(), KeelError>;
    fn execute(
        &mut self,
        request: &Request,
        effect: &mut dyn FnMut(u32) -> AttemptResult,
    ) -> Outcome;
    fn report(&self) -> Value;

    // Provided method
    fn advance_clock(&mut self, _ms: u64) { ... }
}
Expand description

The logical core surface. The real core implements this behind the C ABI in core-ffi.h; keel-core-stub implements it in-memory. Python/Node stubs mirror the same four operations on native values.

Required Methods§

Source

fn configure(&mut self, policy_json: &Value) -> Result<(), KeelError>

Apply a policy document (keel.toml as JSON, per policy.schema.json). Reconfiguration replaces the previous policy atomically.

Source

fn execute( &mut self, request: &Request, effect: &mut dyn FnMut(u32) -> AttemptResult, ) -> Outcome

Run one intercepted call through the target’s layer chain. effect performs a single attempt (1-based attempt number) in the host language. Must always return an Outcome — policy failures are outcomes, not panics/exceptions.

Source

fn report(&self) -> Value

Deterministic metrics/discovery report (JSON): per-target counters {calls, attempts, retries, successes, failures, cache_hits, throttled, breaker_opens, breaker_state} plus {“v”, “clock_ms”}.

Provided Methods§

Source

fn advance_clock(&mut self, _ms: u64)

Advance the core’s clock (milliseconds). The stub runs on a virtual clock starting at 0 and never sleeps — waits advance the clock and are recorded. The real core runs on real time and implements this as a no-op outside its test harness; conformance harnesses use it to model the passage of time (breaker cooldowns, cache TTLs).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§