Skip to main content

Module retention

Module retention 

Source
Expand description

Retention: pruning settled records.

Records are kept forever unless the runtime has a RetentionPolicy. With one, Runtime::prune (and every round of Runtime::run_recovery) deletes records that settled long enough ago, with their audit trail:

use std::time::Duration;
use agent_effects::{RetentionPolicy, Runtime};
use agent_effects_memory::MemoryStore;

const DAY: Duration = Duration::from_secs(86_400);
let runtime = Runtime::builder(MemoryStore::new())
    .retention(RetentionPolicy::settled(30 * DAY).failed(7 * DAY))
    .build();

Only settled records are pruned: Committed, Failed, Rejected and Compensated. An effect that is unknown, waits for an operator or approval, or is still running is kept however old it is, and so is one whose lease is live (a compensation about to start).

Pruning forgets. A pruned key is free: the next call with it starts a new effect and runs it again, and a pruned committed effect can no longer be compensated. Keep committed records at least as long as any caller might retry with the same key, which is the same rule as for a remote system’s idempotency keys.

Structs§

PruneReport
What one Runtime::prune pass deleted, per status.
RetentionPolicy
How long settled records are kept, per status. None keeps them forever, which is the default.