MCPcopy Create free account
hub / github.com/Effect-TS/effect / make

Function make

packages/effect/src/unstable/workflow/DurableDeferred.ts:84–114  ·  view source on GitHub ↗
(
  name: string,
  options?: {
    readonly success?: Success | undefined
    readonly error?: Error | undefined
  }
)

Source from the content-addressed store, hash-verified

82 * @since 4.0.0
83 */
84export const make = <
85 Success extends Schema.Constraint = Schema.Void,
86 Error extends Schema.Constraint = Schema.Never
87>(
88 name: string,
89 options?: {
90 readonly success?: Success | undefined
91 readonly error?: Error | undefined
92 }
93): DurableDeferred<Success, Error> => {
94 const successSchema = options?.success ?? (Schema.Void as any as Success)
95 const errorSchema = options?.error ?? (Schema.Never as any as Error)
96 return {
97 [TypeId]: TypeId as typeof TypeId,
98 name,
99 successSchema,
100 errorSchema,
101 exitSchema: Schema.Exit(
102 Schema.toCodecJson(successSchema),
103 Schema.toCodecJson(errorSchema),
104 Schema.toCodecJson(Schema.Defect())
105 ) as any,
106 withActivityAttempt: Effect.gen(function*() {
107 const attempt = yield* CurrentAttempt
108 return make(`${name}/${attempt}`, {
109 success: successSchema,
110 error: errorSchema
111 })
112 })
113 }
114}
115
116const EngineTag = Context.Service<WorkflowEngine, WorkflowEngine["Service"]>(
117 "effect/workflow/WorkflowEngine" satisfies typeof WorkflowEngine.key

Callers 1

raceAllFunction · 0.70

Calls 1

toCodecJsonMethod · 0.45

Tested by

no test coverage detected