Open History to see the last commit
1/**
2 * RuntimeReceiptBus layers.
3 *
4 * `RuntimeReceiptBusLive` is the production default and intentionally does not
5 * retain or broadcast receipts. `RuntimeReceiptBusTest` installs the in-memory
6 * PubSub-backed implementation used by integration tests that need to await
7 * checkpoint-reactor milestones precisely.
8 *
9 * @module RuntimeReceiptBus
10 */
11import * as Effect from "effect/Effect";
12import * as Layer from "effect/Layer";
13import * as PubSub from "effect/PubSub";
14import * as Stream from "effect/Stream";
15
16import {
17 RuntimeReceiptBus,
18 type RuntimeReceiptBusShape,
19 type OrchestrationRuntimeReceipt,
20} from "../Services/RuntimeReceiptBus.ts";
21
22const makeRuntimeReceiptBus = Effect.succeed({
23 publish: () => Effect.void,
24 streamEventsForTest: Stream.empty,
25} satisfies RuntimeReceiptBusShape);
26
27const makeRuntimeReceiptBusTest = Effect.gen(function* () {
28 const pubSub = yield* PubSub.unbounded<OrchestrationRuntimeReceipt>();
29
30 return {
31 publish: (receipt) => PubSub.publish(pubSub, receipt).pipe(Effect.asVoid),
32 get streamEventsForTest() {
33 return Stream.fromPubSub(pubSub);
34 },
35 } satisfies RuntimeReceiptBusShape;
36});
37
38export const RuntimeReceiptBusLive = Layer.effect(RuntimeReceiptBus, makeRuntimeReceiptBus);
39export const RuntimeReceiptBusTest = Layer.effect(RuntimeReceiptBus, makeRuntimeReceiptBusTest);