(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
})
| 83 | * @category Constructors |
| 84 | */ |
| 85 | export 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 | |
| 128 | const interruptRetryPolicy = Schedule.exponential(100, 1.5).pipe( |
| 129 | Schedule.union(Schedule.spaced("10 seconds")), |
nothing calls this directly
no test coverage detected
searching dependent graphs…