Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

CheckpointReactor.ts

40 lines1.2 KB

1/**
2 * CheckpointReactor - Checkpoint reaction service interface.
3 *
4 * Owns background workers that react to orchestration checkpoint lifecycle
5 * events and apply checkpoint side effects.
6 *
7 * @module CheckpointReactor
8 */
9import * as Context from "effect/Context";
10import type * as Effect from "effect/Effect";
11import type * as Scope from "effect/Scope";
12​
13/**
14 * CheckpointReactorShape - Service API for checkpoint reactor lifecycle.
15 */
16export interface CheckpointReactorShape {
17 /**
18 * Start the checkpoint reactor.
19 *
20 * The returned effect must be run in a scope so all worker fibers can be
21 * finalized on shutdown.
22 *
23 * Consumes both orchestration-domain and provider-runtime events via an
24 * internal queue.
25 */
26 readonly start: () => Effect.Effect<void, never, Scope.Scope>;
27​
28 /**
29 * Resolves when the internal processing queue is empty and idle.
30 * Intended for test use to replace timing-sensitive sleeps.
31 */
32 readonly drain: Effect.Effect<void>;
34​
35/**
36 * CheckpointReactor - Service tag for checkpoint reactor workers.
37 */
38export class CheckpointReactor extends Context.Service<CheckpointReactor, CheckpointReactorShape>()(
39 "t3/orchestration/Services/CheckpointReactor",
40) {}