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

ProjectionPipeline.ts

42 lines1.4 KB

1/**
2 * OrchestrationProjectionPipeline - Event projection pipeline service interface.
3 *
4 * Coordinates projection bootstrap/replay and per-event projection updates for
5 * orchestration read models.
6 *
7 * @module OrchestrationProjectionPipeline
8 */
9import type { OrchestrationEvent } from "@t3tools/contracts";
10import { ServiceMap } from "effect";
11import type { Effect } from "effect";
12​
13import type { ProjectionRepositoryError } from "../../persistence/Errors.ts";
14​
15/**
16 * OrchestrationProjectionPipelineShape - Service API for projection execution.
17 */
18export interface OrchestrationProjectionPipelineShape {
19 /**
20 * Bootstrap projections by replaying persisted events.
21 *
22 * Resumes each projector from its stored projection-state cursor.
23 */
24 readonly bootstrap: Effect.Effect<void, ProjectionRepositoryError>;
25​
26 /**
27 * Project a single orchestration event into projection repositories.
28 *
29 * Projectors are executed sequentially to preserve deterministic ordering.
30 */
31 readonly projectEvent: (
32 event: OrchestrationEvent,
33 ) => Effect.Effect<void, ProjectionRepositoryError>;
35​
36/**
37 * OrchestrationProjectionPipeline - Service tag for orchestration projections.
38 */
39export class OrchestrationProjectionPipeline extends ServiceMap.Service<
40 OrchestrationProjectionPipeline,
41 OrchestrationProjectionPipelineShape
42>()("t3/orchestration/Services/ProjectionPipeline/OrchestrationProjectionPipeline") {}