![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/lavocat.quebec/private_html/node_modules/effect/dist/esm/ |
import * as Effect from "./Effect.js";
import * as internal from "./internal/executionPlan.js";
import * as Layer from "./Layer.js";
import { pipeArguments } from "./Pipeable.js";
/**
* @since 3.16.0
* @category Symbols
* @experimental
*/
export const TypeId = internal.TypeId;
/**
* @since 3.16.0
* @category Guards
* @experimental
*/
export const isExecutionPlan = internal.isExecutionPlan;
/**
* Create an `ExecutionPlan`, which can be used with `Effect.withExecutionPlan` or `Stream.withExecutionPlan`, allowing you to provide different resources for each step of execution until the effect succeeds or the plan is exhausted.
*
* ```ts
* import { type AiLanguageModel } from "@effect/ai"
* import type { Layer } from "effect"
* import { Effect, ExecutionPlan, Schedule } from "effect"
*
* declare const layerBad: Layer.Layer<AiLanguageModel.AiLanguageModel>
* declare const layerGood: Layer.Layer<AiLanguageModel.AiLanguageModel>
*
* const ThePlan = ExecutionPlan.make(
* {
* // First try with the bad layer 2 times with a 3 second delay between attempts
* provide: layerBad,
* attempts: 2,
* schedule: Schedule.spaced(3000)
* },
* // Then try with the bad layer 3 times with a 1 second delay between attempts
* {
* provide: layerBad,
* attempts: 3,
* schedule: Schedule.spaced(1000)
* },
* // Finally try with the good layer.
* //
* // If `attempts` is omitted, the plan will only attempt once, unless a schedule is provided.
* {
* provide: layerGood
* }
* )
*
* declare const effect: Effect.Effect<
* void,
* never,
* AiLanguageModel.AiLanguageModel
* >
* const withPlan: Effect.Effect<void> = Effect.withExecutionPlan(effect, ThePlan)
* ```
*
* @since 3.16.0
* @category Constructors
* @experimental
*/
export const make = (...steps) => makeProto(steps.map((options, i) => {
if (options.attempts && options.attempts < 1) {
throw new Error(`ExecutionPlan.make: step[${i}].attempts must be greater than 0`);
}
return {
schedule: options.schedule,
attempts: options.attempts,
while: options.while ? input => Effect.suspend(() => {
const result = options.while(input);
return typeof result === "boolean" ? Effect.succeed(result) : result;
}) : undefined,
provide: options.provide
};
}));
const Proto = {
[TypeId]: TypeId,
get withRequirements() {
const self = this;
return Effect.contextWith(context => makeProto(self.steps.map(step => ({
...step,
provide: Layer.isLayer(step.provide) ? Layer.provide(step.provide, Layer.succeedContext(context)) : step.provide
}))));
},
pipe() {
return pipeArguments(this, arguments);
}
};
const makeProto = steps => {
const self = Object.create(Proto);
self.steps = steps;
return self;
};
/**
* @since 3.16.0
* @category Combining
* @experimental
*/
export const merge = (...plans) => makeProto(plans.flatMap(plan => plan.steps));
//# sourceMappingURL=ExecutionPlan.js.map