Expand description
In-flight process state migration across BDEW format-version boundaries.
When an old BDEW format version (FV) is removed from the adapter registry
after its grace period, any process initiated under that FV can no longer
receive new events — the ForwardCompatible policy rejects FV mismatches
at dispatch time. StateMigration + MigrationRunner provide the
tooling to advance those processes to a newer FV before the old FV is
retired.
§How it works
- Scan all event streams via
EventStore::list_streams. - Filter streams whose first event carries
workflow_id == migration.source_workflow_id(). - Replay each matched stream using
FromWorkflow::applyto reconstruct the fully-folded state. - Migrate the state via
StateMigration::migrate. - Snapshot the migrated state under
target_workflow_id’s schema version so the process can continue executing under the new workflow definition without replaying old incompatible events.
§Deployment sequence
- Deploy the new binary with both FVs still registered in the adapter registry.
- Run
MigrationRunner::run_and_update_registry(®istry)— all in-flight processes are migrated and their routing-table entries are rewritten to use the newworkflow_id. InspectMigrationReportfor errors. - Remove the old FV from the adapter registry and redeploy.
Note:
MigrationRunner::run_and_update_registryhandles theProcessRegistryupdate automatically (updatingProcessIdentity.workflow_idfor every primary process-keyed entry). For conversation- or correlation-keyed entries (which are short-lived and self-expire) no action is needed. If you only want the snapshot migration without registry updates, use the simplerMigrationRunner::run()instead.
§Example
use mako_engine::{
migration::{MigrationRunner, StateMigration},
version::WorkflowId,
};
struct SupplierChangeFv2024ToFv2025;
impl StateMigration for SupplierChangeFv2024ToFv2025 {
type FromWorkflow = GpkeSupplierChangeWorkflowFv2024;
type ToWorkflow = GpkeSupplierChangeWorkflowFv2025;
fn source_workflow_id(&self) -> &WorkflowId { &FV2024_WORKFLOW_ID }
fn target_workflow_id(&self) -> &WorkflowId { &FV2025_WORKFLOW_ID }
fn migrate(
&self,
state: SupplierChangeStateFv2024,
) -> Result<SupplierChangeStateFv2025, String> {
Ok(SupplierChangeStateFv2025::from_v2024(state))
}
}
let runner = MigrationRunner::new(
SupplierChangeFv2024ToFv2025,
event_store,
snap_store,
);
let report = runner.run().await;
assert!(report.is_ok(), "migration errors: {:?}", report.errors);Structs§
- Identity
Migration - A no-op
StateMigrationfor workflows whose state schema did not change between two BDEW format versions. - Migration
Error - Describes a failure to migrate a single process stream.
- Migration
Report - Summary produced by a
MigrationRunner::runcall. - Migration
Runner - Drives a
StateMigrationover every event stream in a store.
Traits§
- State
Migration - A typed, one-directional migration from one workflow version to another.