Skip to content
Myr

instance.ts

This file

Path

apps/platform/src/workflows/instance.ts

19 lines · 960 bytes · TypeScript

Last changed by

Merge observability into mainoscabrielbefore adoption1985111

History of this file

Take it

Merge observability into mainoscabrielbefore adoption1985111

lines 1–19why, one step back
1// What every Workflow instance runs under. The engine logs nothing of a run
2// that rejects and traces no Workflow, so the instance's own span is the3// trace's only view into it, and its defects are reported here, once.4import { reportDefects } from "@repo/telemetry/defects";5import { withInvocation } from "@repo/telemetry/spans";6import type { InvocationIds } from "@repo/telemetry/spans";7import { Effect } from "effect";89/** The whole instance, its params' decoding included. */10export const instance =11 (name: string) =>12 <A, E, R>(program: Effect.Effect<A, E, R>): Effect.Effect<A, never, R> =>13 program.pipe(Effect.orDie, reportDefects, Effect.withSpan(name));1415/** The run its params name: a defect's report carries the ids, as each line does. */16export const invocation =17 (ids: InvocationIds) =>18 <A, E, R>(program: Effect.Effect<A, E, R>): Effect.Effect<A, never, R> =>19 program.pipe(Effect.orDie, reportDefects, withInvocation(ids));