pub struct EngineBuilder { /* private fields */ }Expand description
Builder for the embedded, transport-agnostic workflow engine.
Implementations§
Source§impl EngineBuilder
impl EngineBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a builder with no store, no scheduler-thread override, no loaded workflows, and no host NIFs.
Sourcepub const fn query_timeout(self, timeout: Duration) -> Self
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.
Sourcepub const fn configured_query_timeout(&self) -> Option<Duration>
pub const fn configured_query_timeout(&self) -> Option<Duration>
Inspect the configured workflow query reply timeout.
Sourcepub const fn event_streaming(self, capacity: NonZeroUsize) -> Self
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.
Sourcepub fn search_attribute_schema(self, schema: SearchAttributeSchema) -> Self
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.
Sourcepub fn store<S>(self, store: S) -> Selfwhere
S: EventStore,
pub fn store<S>(self, store: S) -> Selfwhere
S: EventStore,
Supply the event store used by the engine.
Sourcepub fn store_arc(self, store: Arc<dyn EventStore>) -> Self
pub fn store_arc(self, store: Arc<dyn EventStore>) -> Self
Supply an already type-erased event store.
Sourcepub fn visibility_store<S>(self, visibility_store: S) -> Selfwhere
S: VisibilityStore,
pub fn visibility_store<S>(self, visibility_store: S) -> Selfwhere
S: VisibilityStore,
Supply the visibility store used by the engine for workflow projections.
Sourcepub fn visibility_store_arc(
self,
visibility_store: Arc<dyn VisibilityStore>,
) -> Self
pub fn visibility_store_arc( self, visibility_store: Arc<dyn VisibilityStore>, ) -> Self
Supply an already type-erased visibility store.
Sourcepub fn in_memory_visibility(self) -> Self
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.
Sourcepub const fn scheduler_threads(self, threads: usize) -> Self
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.
Sourcepub const fn visibility_reconciliation_interval(
self,
interval: Duration,
) -> Self
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.
Sourcepub const fn signal_delivery(
self,
signal_delivery: SignalDeliveryConfig,
) -> Self
pub const fn signal_delivery( self, signal_delivery: SignalDeliveryConfig, ) -> Self
Record the caller-supplied signal delivery readiness and retry policy.
Sourcepub fn outbox_enabled(self, enabled: bool) -> Self
pub fn outbox_enabled(self, enabled: bool) -> Self
Record whether the durable-outbox fan-out dispatch path is enabled.
Sourcepub const fn bootstrap_schedule_coordinator(self, enabled: bool) -> Self
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.
Sourcepub fn owned_shards(self, shards: impl IntoIterator<Item = usize>) -> Self
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.
Sourcepub fn configured_owned_shards(&self) -> Option<&[usize]>
pub fn configured_owned_shards(&self) -> Option<&[usize]>
Inspect the configured owned-shard set (None = own all shards).
Sourcepub fn load_workflows(self, source: impl Into<WorkflowPackageSource>) -> Self
pub fn load_workflows(self, source: impl Into<WorkflowPackageSource>) -> Self
Add one workflow package source to load during build().
Sourcepub fn load_workflow_sources<I, S>(self, sources: I) -> Self
pub fn load_workflow_sources<I, S>(self, sources: I) -> Self
Add many workflow package sources to load during build().
Sourcepub fn register_nifs(self, entries: impl IntoIterator<Item = NifEntry>) -> Self
pub fn register_nifs(self, entries: impl IntoIterator<Item = NifEntry>) -> Self
Collect host-supplied NIF entries to install before workflow modules load.
Sourcepub fn recovery_seam(
self,
recovery: Arc<dyn ActiveWorkflowRecoverySeam>,
) -> Self
pub fn recovery_seam( self, recovery: Arc<dyn ActiveWorkflowRecoverySeam>, ) -> Self
Override the AD recovery seam used while repopulating active workflows.
Sourcepub fn production_recovery_seam(self) -> Self
pub fn production_recovery_seam(self) -> Self
Use the production AD recovery seam created after runtime/package loading.
Sourcepub fn signal_router(self, signal_router: Arc<dyn SignalRouter>) -> Self
pub fn signal_router(self, signal_router: Arc<dyn SignalRouter>) -> Self
Override the AT signal-routing seam.
Sourcepub fn signal_router_factory<F>(self, factory: F) -> Selfwhere
F: Fn(Arc<RuntimeHandle>, Arc<SignalResumeHandoff>) -> Arc<dyn SignalRouter> + Send + Sync + 'static,
pub fn signal_router_factory<F>(self, factory: F) -> Selfwhere
F: Fn(Arc<RuntimeHandle>, Arc<SignalResumeHandoff>) -> Arc<dyn SignalRouter> + Send + Sync + 'static,
Override the AT signal-routing seam after the runtime is assembled.
Sourcepub fn query_service(self, query_service: Arc<dyn QueryService>) -> Self
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().
Sourcepub fn event_publisher(self, event_publisher: Arc<dyn EventPublisher>) -> Self
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().
Sourcepub fn activity_dispatcher(
self,
dispatcher: Arc<dyn ActivityDispatcher>,
) -> Self
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.
Sourcepub fn active_registry(self, registry: Arc<Registry>) -> Self
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.
Sourcepub const fn scheduler_thread_count(&self) -> Option<usize>
pub const fn scheduler_thread_count(&self) -> Option<usize>
Inspect the configured scheduler thread count.
Sourcepub const fn configured_visibility_reconciliation_interval(
&self,
) -> Option<Duration>
pub const fn configured_visibility_reconciliation_interval( &self, ) -> Option<Duration>
Inspect the configured periodic visibility reconciliation interval.
Sourcepub async fn build(self) -> Result<Engine, EngineError>
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.