pub trait ExperimentLogBackend:
Send
+ Sync
+ Debug {
// Required methods
fn append<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tenant: &'life1 str,
route_ix: usize,
fingerprint: &'life2 str,
record: LogRecord,
) -> Pin<Box<dyn Future<Output = Result<u64, LogError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn load_since<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tenant: &'life1 str,
route_ix: usize,
fingerprint: &'life2 str,
offset: u64,
) -> Pin<Box<dyn Future<Output = Result<Vec<Option<LogRecord>>, LogError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn claim_session<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tenant: &'life1 str,
route_ix: usize,
fingerprint: &'life2 str,
session_id: &'life3 str,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait;
}Expand description
A shared log that lets several replicas converge on the same Experiment state.
Implementors: InMemoryExperimentLog (tests), and RedisExperimentLog (behind the
redis-cache feature).
The log for a given experiment is identified by (tenant, route_ix, fingerprint). Multiple
replicas can append concurrently; the authoritative ordering is the list’s arrival order (for
Redis: RPUSH index; for the in-memory implementation: insertion position). A halt decision
derived from the list at position N holds forever — re-reading the list can only add more
evidence, never retract it.
Required Methods§
Sourcefn append<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tenant: &'life1 str,
route_ix: usize,
fingerprint: &'life2 str,
record: LogRecord,
) -> Pin<Box<dyn Future<Output = Result<u64, LogError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn append<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tenant: &'life1 str,
route_ix: usize,
fingerprint: &'life2 str,
record: LogRecord,
) -> Pin<Box<dyn Future<Output = Result<u64, LogError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Append record to the list. Returns the new list length (1-based), or an error if the
backend is unreachable. A failure means the pair/outcome will not reach other replicas,
but local accounting (health, ledger) was already performed by the caller.
Sourcefn load_since<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tenant: &'life1 str,
route_ix: usize,
fingerprint: &'life2 str,
offset: u64,
) -> Pin<Box<dyn Future<Output = Result<Vec<Option<LogRecord>>, LogError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn load_since<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tenant: &'life1 str,
route_ix: usize,
fingerprint: &'life2 str,
offset: u64,
) -> Pin<Box<dyn Future<Output = Result<Vec<Option<LogRecord>>, LogError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Return records starting at offset (0-based). Each element is Some(record) for a valid
entry or None for a malformed one (failed to deserialize). The list length equals the
number of positions consumed: a None at index i still advances offset by 1. Empty
if the list has ≤ offset entries. Returns an error if the backend is unreachable; callers
use this to distinguish “truly empty” from “unreachable” and fail closed.
Sourcefn claim_session<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tenant: &'life1 str,
route_ix: usize,
fingerprint: &'life2 str,
session_id: &'life3 str,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn claim_session<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tenant: &'life1 str,
route_ix: usize,
fingerprint: &'life2 str,
session_id: &'life3 str,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Atomically claim a session for this experiment (live mode session dedup across replicas).
Returns true if the session was newly claimed (this replica should count the outcome),
false if another replica already claimed it. Claimants are permanent: once claimed the
result is final regardless of which replica appended it.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".