Open History to see the last commit
1/**
2 * ThreadDeletionReactor - Thread deletion cleanup reactor service interface.
3 *
4 * Owns background workers that react to thread deletion domain events and
5 * perform best-effort runtime cleanup for provider sessions and terminals.
6 *
7 * @module ThreadDeletionReactor
8 */
9import * as Context from "effect/Context";
10import type * as Effect from "effect/Effect";
11import type * as Scope from "effect/Scope";
12
13/**
14 * ThreadDeletionReactorShape - Service API for thread deletion cleanup.
15 */
16export interface ThreadDeletionReactorShape {
17 /**
18 * Start reacting to thread.deleted orchestration domain events.
19 *
20 * The returned effect must be run in a scope so all worker fibers can be
21 * finalized on shutdown.
22 */
23 readonly start: () => Effect.Effect<void, never, Scope.Scope>;
24
25 /**
26 * Resolves once every thread.deleted at or before the supplied event
27 * sequence has been handed to the worker and the worker is empty and idle.
28 * A successful thread.create sequence is the fence callers use before the
29 * new incarnation can own runtime resources.
30 */
31 readonly drainThrough: (sequence: number) => Effect.Effect<void>;
32}
33
34/**
35 * ThreadDeletionReactor - Service tag for thread deletion cleanup workers.
36 */
37export class ThreadDeletionReactor extends Context.Service<
38 ThreadDeletionReactor,
39 ThreadDeletionReactorShape
40>()("t3/orchestration/Services/ThreadDeletionReactor") {}