Skip to main content

Module registry

Module registry 

Source
Expand description

Process routing registry.

Maps string routing keys to ProcessIdentity values so inbound EDIFACT messages can be dispatched to the correct running process without the caller managing a bespoke routing table.

§Routing key conventions

Any stable string that uniquely identifies a process for a given message type works as a routing key. Common patterns:

Message typeRecommended key
UTILMD waiting for APERAKRegistryKey::from_conversation_and_sender(conversation_id, sender_gln)
Route follow-up by correlationRegistryKey::from_correlation(correlation_id)
Direct lookup by processRegistryKey::from_process(process_id)

One process may be registered under multiple keys when it handles several different message types simultaneously.

§Tenant scoping

All registry operations are scoped to a TenantId. This prevents routing keys from leaking across tenant boundaries when the engine handles multiple market participants in a single deployment.

§Usage

// After spawning a process, register it under the UTILMD conversation ID + sender GLN:
ctx.registry
    .register(tenant_id, &RegistryKey::from_conversation_and_sender(utilmd_conv_id, sender_gln), process.identity())
    .await?;

// When the APERAK arrives, look up by conversation ID + APERAK sender GLN:
let identity = ctx.registry
    .lookup(tenant_id, &RegistryKey::from_conversation_and_sender(aperak_conv_id, aperak_sender_gln))
    .await?
    .ok_or(EngineError::registry("unknown conversation"))?;

let process = ctx.resume::<SupplierChangeWorkflow>(identity);
process.execute(HandleAperak { .. }).await?;

// Clean up after process completion:
ctx.registry.remove(tenant_id, &RegistryKey::from_conversation_and_sender(utilmd_conv_id, sender_gln)).await?;

Structs§

NoopProcessRegistry
A ProcessRegistry that never stores any mappings.
RegistryKey
A typed routing key for the ProcessRegistry.

Constants§

MAX_REGISTRY_KEY_LEN
Maximum byte length for a RegistryKey routing key.

Traits§

ProcessRegistry
Routes inbound messages to their target processes by string key.