Skip to main content

RuntimeBuilder

Struct RuntimeBuilder 

Source
pub struct RuntimeBuilder<S> { /* private fields */ }
Expand description

Configures a Runtime.

Implementations§

Source§

impl<S: EffectStore> RuntimeBuilder<S>

Source

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.

Source

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.

Source

pub fn redactor(self, redactor: impl Redactor) -> Self

Rewrites every input, output, audit payload and error message before it is stored; see redaction.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn fault_injector(self, injector: Arc<FaultInjector>) -> Self

Simulates crashes at the injector’s armed points. For tests; see fault.

Source

pub fn build(self) -> Runtime<S>

Builds the runtime.

Auto Trait Implementations§

§

impl<S> !RefUnwindSafe for RuntimeBuilder<S>

§

impl<S> !UnwindSafe for RuntimeBuilder<S>

§

impl<S> Freeze for RuntimeBuilder<S>
where S: Freeze, HashMap<&'static str, Registered<S>>: Freeze,

§

impl<S> Send for RuntimeBuilder<S>
where S: Send, HashMap<&'static str, Registered<S>>: Send,

§

impl<S> Sync for RuntimeBuilder<S>
where S: Sync, HashMap<&'static str, Registered<S>>: Sync,

§

impl<S> Unpin for RuntimeBuilder<S>
where S: Unpin, HashMap<&'static str, Registered<S>>: Unpin,

§

impl<S> UnsafeUnpin for RuntimeBuilder<S>
where S: UnsafeUnpin, HashMap<&'static str, Registered<S>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more