Skip to main content

Module builder

Module builder 

Source
Expand description

EngineModule trait, EngineBuilder, and EngineContext.

§Summary

EngineBuilder assembles all engine infrastructure into a single EngineContext value. Domain modules (GPKE, WiM, GeLi Gas, …) register themselves at startup via the EngineModule trait, making their names visible in diagnostics and health checks.

§Type-state guarantee

EngineBuilder::build is only available when the event store type parameter ES implements EventStore. Forgetting to call with_event_store is a compile-time error, not a runtime panic.

All other stores default to their respective Noop implementations:

StoreDefault
Snapshot storeNoopSnapshotStore
Outbox storeNoopOutboxStore
Deadline storeNoopDeadlineStore
Process registryNoopProcessRegistry

§Assembly example

use mako_engine::builder::{EngineBuilder, EngineModule};
use mako_engine::event_store::InMemoryEventStore;
use mako_engine::outbox::InMemoryOutboxStore;
use mako_engine::deadline::InMemoryDeadlineStore;
use mako_engine::registry::InMemoryProcessRegistry;
use mako_engine::snapshot::InMemorySnapshotStore;

struct GpkeModule;
impl EngineModule for GpkeModule { fn name(&self) -> &'static str { "gpke" } }

let ctx = EngineBuilder::new()
    .with_event_store(InMemoryEventStore::new())
    .with_snapshot_store(InMemorySnapshotStore::new())
    .with_outbox_store(InMemoryOutboxStore::new())
    .with_deadline_store(InMemoryDeadlineStore::new())
    .with_registry(InMemoryProcessRegistry::new())
    .register(Box::new(GpkeModule))
    .build();

// Spawn a fresh process:
let p = ctx.spawn::<SupplierChangeWorkflow>(tenant_id, workflow_id);
p.execute(ReceiveUtilmd { .. }).await?;

// Resume an existing process from a persisted identity:
let identity = ctx.registry.lookup(&conv_id.to_string()).await?.unwrap();
let p = ctx.resume::<SupplierChangeWorkflow>(identity);

// Access stores for delivery workers / schedulers:
let pending = ctx.outbox_store.pending_now(50).await?;
let overdue = ctx.deadline_store.due_now(50).await?;

Structs§

DeadlineScheduler
A background task that polls DeadlineStore::due_now and dispatches deadline commands to the owning processes via a caller-supplied function.
EngineBuilder
Assembles engine infrastructure and produces an EngineContext.
EngineContext
Assembled engine infrastructure returned by EngineBuilder::build.
LogAs4Sender
An As4Sender that logs every outbound message at warn level and succeeds without transmitting.
NoopAs4Sender
An As4Sender that succeeds immediately without sending anything.
OutboxWorker
A background worker that drains the outbox by polling pending OutboxMessages and dispatching them via an As4Sender.

Traits§

As4Sender
Sends a single AS4 / EDIINT-over-HTTP outbound message.
EngineModule
A self-contained domain module that registers with the engine at startup.

Type Aliases§

MinimalEngine
An EngineContext with all optional subsystems disabled.