Skip to main content

Module integration

Module integration 

Source
Expand description

Cross-module integration — adapters, anti-corruption layer, and event bridges.

Modules MUST NOT share entities. When module A needs data from module B, it defines an External projection and a ModuleAdapter that maps from B’s published types into A’s internal types.

§Pattern

Module B publishes:  UserCreatedEvent { user_id, email }
Module A adapts:     CustomerCreatedEvent { customer_id, contact_email }

impl ModuleAdapter<UserCreatedEvent, CustomerCreatedEvent>
    for SapiensToCorpusAdapter { ... }

This keeps bounded contexts decoupled while allowing event-driven integration.

§Module identification

Adapters expose source_module() and target_module() so the framework can log, trace, and validate cross-context data flows.

Structs§

EventBridge
Bridges domain events from module A into module B by adapting and re-publishing.
IdentityAdapter
An adapter that maps a type to itself — useful when module A re-publishes its own event with no transformation.

Enums§

IntegrationError
Standard error for integration/adapter failures.

Traits§

ModuleAdapter
Bidirectional adapter between an external module’s type and this module’s type.
ProjectionAdapter
Synchronous adapter for pure data projections (no async needed).

Functions§

identity_adapter
Helper: build an IdentityAdapter without importing the type name.