Effects Composition¶
The Integration Events generator emits the same effect methods as the Event Queue module — Enqueue, EnqueueWithAck, EnqueueAndWait — on the publisher class.
Generated Effect Methods¶
// Generated on OrderingIntegrationEvents
public static Eff<RT, Unit> Enqueue<RT>(object @event) => ...
public static Eff<RT, EventAcknowledgement> EnqueueWithAck<RT>(object @event) => ...
public static Eff<RT, Unit> EnqueueAndWait<RT>(object @event) => ...
The methods accept object because integration event queues handle polymorphic event types (multiple event records sharing a single channel). The EventTypeRegistry handles type discrimination at the transport level.
Test Helpers¶
// Generated — read a single event (non-blocking)
public static bool TryRead(out object @event) => ...
// Generated — drain all buffered events
public static List<object> DrainAll() => ...
Runtime Composition¶
Local [IntegrationEvents] modules are auto-discovered by the runtime:
[Runtime]
public partial class OrderingRuntime;
// OrderingIntegrationEvents is auto-discovered — no [Uses] needed
Effect Pipeline Examples¶
Publish an integration event after a command succeeds:
from order in OrderingDispatch.CreateOrder(cmd)
from _ in OrderingIntegrationEvents.Enqueue<OrderingRuntime>(
new OrderingEvents.OrderPlaced(order.Id, cmd.CustomerId))
select order;
Fan out to multiple topics:
from _ in OrderingIntegrationEvents.Enqueue<OrderingRuntime>(
new OrderingEvents.OrderStatusChangedToPaid(orderId, stockItems))
from _ in OrderingIntegrationEvents.Enqueue<OrderingRuntime>(
new OrderingEvents.OrderStatusChanged(orderId, "Paid", buyerId))
select unit;
For more composition patterns, see the Event Queue Effects reference.