MCPcopy Index your code
hub / github.com/Effect-TS/effect / make

Function make

packages/workflow/src/Activity.ts:85–126  ·  view source on GitHub ↗
(options: {
  readonly name: string
  readonly success?: Success | undefined
  readonly error?: Error | undefined
  readonly execute: Effect.Effect<Success["Type"], Error["Type"], R>
  readonly interruptRetryPolicy?: Schedule.Schedule<any, Cause.Cause<unknown>> | undefined
})

Source from the content-addressed store, hash-verified

83 * @category Constructors
84 */
85export const make = <
86 R,
87 Success extends Schema.Schema.Any = typeof Schema.Void,
88 Error extends Schema.Schema.All = typeof Schema.Never
89>(options: {
90 readonly name: string
91 readonly success?: Success | undefined
92 readonly error?: Error | undefined
93 readonly execute: Effect.Effect<Success["Type"], Error["Type"], R>
94 readonly interruptRetryPolicy?: Schedule.Schedule<any, Cause.Cause<unknown>> | undefined
95}): Activity<Success, Error, Exclude<R, WorkflowInstance | WorkflowEngine | Scope>> => {
96 const successSchema = options.success ?? Schema.Void as any as Success
97 const errorSchema = options.error ?? Schema.Never as any as Error
98 // eslint-disable-next-line prefer-const
99 let execute!: Effect.Effect<Success["Type"], Error["Type"], any>
100 const executeWithoutInterrupt = retryOnInterrupt(
101 options.name,
102 options.interruptRetryPolicy
103 )(options.execute)
104 const self: Activity<Success, Error, Exclude<R, WorkflowInstance | WorkflowEngine>> = {
105 ...Effectable.CommitPrototype,
106 [TypeId]: TypeId,
107 name: options.name,
108 successSchema,
109 errorSchema,
110 exitSchema: Schema.ExitFromSelf({
111 success: successSchema,
112 failure: errorSchema,
113 defect: Schema.Defect
114 }),
115 execute: executeWithoutInterrupt,
116 executeEncoded: Effect.matchEffect(executeWithoutInterrupt, {
117 onFailure: (error) => Effect.flatMap(Effect.orDie(Schema.encode(self.errorSchema as any)(error)), Effect.fail),
118 onSuccess: (value) => Effect.orDie(Schema.encode(self.successSchema)(value))
119 }),
120 commit() {
121 return execute
122 }
123 } as any
124 execute = makeExecute(self)
125 return self
126}
127
128const interruptRetryPolicy = Schedule.exponential(100, 1.5).pipe(
129 Schedule.union(Schedule.spaced("10 seconds")),

Callers

nothing calls this directly

Calls 3

retryOnInterruptFunction · 0.85
makeExecuteFunction · 0.85
encodeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…