Skip to main content

EngineBuilder

Struct EngineBuilder 

Source
pub struct EngineBuilder { /* private fields */ }
Expand description

Builder for the embedded, transport-agnostic workflow engine.

Implementations§

Source§

impl EngineBuilder

Source

pub fn new() -> Self

Create a builder with no store, no scheduler-thread override, no loaded workflows, and no host NIFs.

Source

pub const fn query_timeout(self, timeout: Duration) -> Self

Record the caller-supplied workflow query reply timeout.

Setting a timeout installs the concrete query-dispatch seam during build() (unless Self::query_service overrides it) and enables the in-engine dispatch_query NIF. There is no default: without this call the query seam stays deferred and Engine::query fails typed with its “not configured” error.

Source

pub const fn configured_query_timeout(&self) -> Option<Duration>

Inspect the configured workflow query reply timeout.

Source

pub const fn event_streaming(self, capacity: NonZeroUsize) -> Self

Opt in to live event streaming with a caller-provided broadcast capacity.

build() wraps the configured store in a PublishingEventStore before any recorder, recovery, or NIF bridge captures the store — so every successful append publishes — and installs the matching BroadcastEventPublisher as the event-publisher seam behind Engine::subscribe. Without this call the deferred publisher remains installed and subscriptions are empty.

Source

pub fn search_attribute_schema(self, schema: SearchAttributeSchema) -> Self

Supply the search attribute schema validating every recorded attribute.

The default schema is empty, which rejects all search attributes: a deployment must declare each attribute name and type before workflows can record values for it.

Source

pub fn store<S>(self, store: S) -> Self
where S: EventStore,

Supply the event store used by the engine.

Source

pub fn store_arc(self, store: Arc<dyn EventStore>) -> Self

Supply an already type-erased event store.

Source

pub fn visibility_store<S>(self, visibility_store: S) -> Self
where S: VisibilityStore,

Supply the visibility store used by the engine for workflow projections.

Source

pub fn visibility_store_arc( self, visibility_store: Arc<dyn VisibilityStore>, ) -> Self

Supply an already type-erased visibility store.

Source

pub fn in_memory_visibility(self) -> Self

Explicitly opt in to an ephemeral in-memory visibility store.

This is intended for tests and local scenarios that do not need durable visibility projections. Visibility data stored this way does not survive process restarts.

Source

pub const fn scheduler_threads(self, threads: usize) -> Self

Record the caller-supplied scheduler thread count.

If this setter is never called, None is passed through to beamr.

Source

pub const fn visibility_reconciliation_interval( self, interval: Duration, ) -> Self

Record the caller-supplied periodic visibility reconciliation interval.

If this setter is never called, no periodic background reconciliation task is spawned.

Source

pub const fn signal_delivery( self, signal_delivery: SignalDeliveryConfig, ) -> Self

Record the caller-supplied signal delivery readiness and retry policy.

Source

pub fn outbox_enabled(self, enabled: bool) -> Self

Record whether the durable-outbox fan-out dispatch path is enabled.

Source

pub const fn bootstrap_schedule_coordinator(self, enabled: bool) -> Self

Control whether build() seeds the schedule-coordinator history.

Default true (single-node). Under multi-shard active-active the coordinator stream is owned by exactly ONE shard; a deployment sets this false on every node that does NOT own that shard, so only the owner seeds (and serves) it — a non-owner would otherwise try to write the coordinator stream and race or fence the real owner.

Source

pub fn owned_shards(self, shards: impl IntoIterator<Item = usize>) -> Self

Restrict this engine’s store to the distribution shards this node owns.

Under multi-shard active-active a node serves only a SUBSET of the cluster’s shards. build() calls ReadableEventStore::set_owned_shards with this set BEFORE startup recovery, so the node recovers and enumerates only the workflows / timers / outbox rows that live on its shards. The set is deduplicated and ordered by the store.

Not calling this leaves the store owning ALL shards — the single-node default, which is byte-identical to today’s behaviour (build() never touches the scoping hook). Single-shard backends (in-memory, libSQL) ignore the call regardless, since they own everything unconditionally.

Source

pub fn configured_owned_shards(&self) -> Option<&[usize]>

Inspect the configured owned-shard set (None = own all shards).

Source

pub fn load_workflows(self, source: impl Into<WorkflowPackageSource>) -> Self

Add one workflow package source to load during build().

Source

pub fn load_workflow_sources<I, S>(self, sources: I) -> Self
where I: IntoIterator<Item = S>, S: Into<WorkflowPackageSource>,

Add many workflow package sources to load during build().

Source

pub fn register_nifs(self, entries: impl IntoIterator<Item = NifEntry>) -> Self

Collect host-supplied NIF entries to install before workflow modules load.

Source

pub fn recovery_seam( self, recovery: Arc<dyn ActiveWorkflowRecoverySeam>, ) -> Self

Override the AD recovery seam used while repopulating active workflows.

Source

pub fn production_recovery_seam(self) -> Self

Use the production AD recovery seam created after runtime/package loading.

Source

pub fn signal_router(self, signal_router: Arc<dyn SignalRouter>) -> Self

Override the AT signal-routing seam.

Source

pub fn signal_router_factory<F>(self, factory: F) -> Self
where F: Fn(Arc<RuntimeHandle>, Arc<SignalResumeHandoff>) -> Arc<dyn SignalRouter> + Send + Sync + 'static,

Override the AT signal-routing seam after the runtime is assembled.

Source

pub fn query_service(self, query_service: Arc<dyn QueryService>) -> Self

Override the AT query-dispatch seam.

An explicit override wins over the concrete service that Self::query_timeout would otherwise install during build().

Source

pub fn event_publisher(self, event_publisher: Arc<dyn EventPublisher>) -> Self

Override the AD/AT live event-publisher seam.

Mutually exclusive with Self::event_streaming, which installs the broadcast publisher itself; configuring both fails build().

Source

pub fn activity_dispatcher( self, dispatcher: Arc<dyn ActivityDispatcher>, ) -> Self

Supply the activity dispatcher that backs activity dispatch NIFs.

When set, the dispatcher is installed in the global bridge before workflow modules are loaded. Without a dispatcher, dispatch_activity returns an error to workflow code instead of crashing the process.

Source

pub fn active_registry(self, registry: Arc<Registry>) -> Self

Supply the active workflow registry used by the built engine.

Server-owned dispatchers that run behind raw NIFs use this to correlate a calling BEAM pid to the same workflow handle the engine registers.

Source

pub const fn scheduler_thread_count(&self) -> Option<usize>

Inspect the configured scheduler thread count.

Source

pub const fn configured_visibility_reconciliation_interval( &self, ) -> Option<Duration>

Inspect the configured periodic visibility reconciliation interval.

Source

pub async fn build(self) -> Result<Engine, EngineError>

Construct the live engine.

§Errors

Returns typed EngineError variants for missing store, runtime startup, NIF registration, package loading, store reads, registry/supervision lock poison, or deferred AD recovery failures for active histories.

Trait Implementations§

Source§

impl Default for EngineBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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