pub struct RuntimeBuilder<S> { /* private fields */ }Expand description
Configures a Runtime.
Implementations§
Source§impl<S: EffectStore> RuntimeBuilder<S>
impl<S: EffectStore> RuntimeBuilder<S>
Sourcepub fn retention(self, policy: RetentionPolicy) -> Self
pub fn retention(self, policy: RetentionPolicy) -> Self
How long settled records are kept before Runtime::prune (and
every round of Runtime::run_recovery) deletes them; see
retention. Defaults to keeping them forever.
Sourcepub fn observer(self, observer: impl EffectObserver) -> Self
pub fn observer(self, observer: impl EffectObserver) -> Self
Tells observer about every effect recorded and every transition
stored, for metrics; see observer. May be called
more than once.
Sourcepub fn redactor(self, redactor: impl Redactor) -> Self
pub fn redactor(self, redactor: impl Redactor) -> Self
Rewrites every input, output, audit payload and error message before
it is stored; see redaction.
Sourcepub fn risk_policy(self, policy: RiskPolicy) -> Self
pub fn risk_policy(self, policy: RiskPolicy) -> Self
Adds requirements by risk level and effect kind to every effect; see
RiskPolicy. Requirements only accumulate on top of each effect’s
own settings.
Sourcepub fn approval_provider(self, provider: impl ApprovalProvider) -> Self
pub fn approval_provider(self, provider: impl ApprovalProvider) -> Self
Asks provider to decide on effects that require approval; see
approval. Without one, such effects wait for an
operator’s Runtime::approve or Runtime::deny.
Sourcepub fn register<H: EffectHandler>(self, handler: Handler<H>) -> Self
pub fn register<H: EffectHandler>(self, handler: Handler<H>) -> Self
Registers a durable handler under its EffectHandler::NAME, so
Runtime::submit can run it and Runtime::recover can finish
its effects without a caller.
§Panics
If a handler is already registered under the same name.
Sourcepub fn clock(self, clock: impl Clock) -> Self
pub fn clock(self, clock: impl Clock) -> Self
The time source for leases and schedules. Defaults to the system
clock. Tests with paused Tokio time want
TokioClock.
Sourcepub fn worker_id(self, worker: WorkerId) -> Self
pub fn worker_id(self, worker: WorkerId) -> Self
This runtime’s identity as a lease holder. Defaults to a random id. Must be unique among runtimes sharing a store.
Sourcepub fn lease_ttl(self, ttl: Duration) -> Self
pub fn lease_ttl(self, ttl: Duration) -> Self
How long a lease lasts without renewal. The runtime renews it every third of this while it works on an effect, including while it waits between retries. If a worker dies, others wait this long before treating its in-flight effect as unknown. Defaults to 30 seconds; values under 3 ms are raised to 3 ms.
Sourcepub fn retry_policy(self, policy: RetryPolicy) -> Self
pub fn retry_policy(self, policy: RetryPolicy) -> Self
The retry policy for effects that do not set their own. Defaults to
RetryPolicy::default: 5 attempts, 1 s to 30 s exponential backoff
with jitter.
Sourcepub fn fault_injector(self, injector: Arc<FaultInjector>) -> Self
pub fn fault_injector(self, injector: Arc<FaultInjector>) -> Self
Simulates crashes at the injector’s armed points. For tests; see
fault.