effect 4.1.5 → 4.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ai-docs/package.json +2 -2
- package/dist/Channel.d.ts +104 -7
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +73 -4
- package/dist/Channel.js.map +1 -1
- package/dist/Codegen.d.ts +7 -2
- package/dist/Codegen.d.ts.map +1 -1
- package/dist/Codegen.js +7 -2
- package/dist/Codegen.js.map +1 -1
- package/dist/Effect.d.ts +139 -18
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +10 -2
- package/dist/Effect.js.map +1 -1
- package/dist/Equal.d.ts +4 -4
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equal.js +78 -65
- package/dist/Equal.js.map +1 -1
- package/dist/Hash.d.ts.map +1 -1
- package/dist/Hash.js +24 -17
- package/dist/Hash.js.map +1 -1
- package/dist/LayerRef.d.ts +1 -1
- package/dist/LayerRef.d.ts.map +1 -1
- package/dist/LayerRef.js +3 -3
- package/dist/LayerRef.js.map +1 -1
- package/dist/Logger.d.ts +37 -13
- package/dist/Logger.d.ts.map +1 -1
- package/dist/Logger.js +39 -10
- package/dist/Logger.js.map +1 -1
- package/dist/Match.d.ts +23 -23
- package/dist/Match.d.ts.map +1 -1
- package/dist/Match.js.map +1 -1
- package/dist/Order.js +1 -1
- package/dist/Order.js.map +1 -1
- package/dist/Schema.d.ts +41 -0
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +51 -390
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +0 -3
- package/dist/SchemaAST.js.map +1 -1
- package/dist/ScopedCache.d.ts.map +1 -1
- package/dist/ScopedCache.js +6 -4
- package/dist/ScopedCache.js.map +1 -1
- package/dist/Stream.d.ts +128 -5
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +124 -29
- package/dist/Stream.js.map +1 -1
- package/dist/String.js +1 -1
- package/dist/String.js.map +1 -1
- package/dist/Tracer.d.ts +10 -0
- package/dist/Tracer.d.ts.map +1 -1
- package/dist/Tracer.js +2 -0
- package/dist/Tracer.js.map +1 -1
- package/dist/ai/McpSchema.d.ts +88 -88
- package/dist/ai/McpSchema.d.ts.map +1 -1
- package/dist/ai/McpServer.d.ts +152 -2
- package/dist/ai/McpServer.d.ts.map +1 -1
- package/dist/ai/McpServer.js +8 -2
- package/dist/ai/McpServer.js.map +1 -1
- package/dist/ai/Prompt.d.ts +3 -1
- package/dist/ai/Prompt.d.ts.map +1 -1
- package/dist/ai/Prompt.js +17 -3
- package/dist/ai/Prompt.js.map +1 -1
- package/dist/ai/Skill.d.ts +172 -0
- package/dist/ai/Skill.d.ts.map +1 -0
- package/dist/ai/Skill.js +209 -0
- package/dist/ai/Skill.js.map +1 -0
- package/dist/ai/index.d.ts +5 -0
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +5 -0
- package/dist/ai/index.js.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.js +155 -83
- package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/cluster/MessageStorage.d.ts +56 -0
- package/dist/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/cluster/MessageStorage.js +18 -2
- package/dist/cluster/MessageStorage.js.map +1 -1
- package/dist/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/cluster/SqlMessageStorage.js +45 -22
- package/dist/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/cluster/internal/entityActivation.js +2 -0
- package/dist/cluster/internal/entityActivation.js.map +1 -1
- package/dist/cluster/internal/entityManager.js +8 -5
- package/dist/cluster/internal/entityManager.js.map +1 -1
- package/dist/encoding/Base64.js +5 -1
- package/dist/encoding/Base64.js.map +1 -1
- package/dist/encoding/Base64Url.d.ts.map +1 -1
- package/dist/encoding/Base64Url.js +6 -1
- package/dist/encoding/Base64Url.js.map +1 -1
- package/dist/encoding/Xml.d.ts +38 -9
- package/dist/encoding/Xml.d.ts.map +1 -1
- package/dist/encoding/Xml.js +63 -31
- package/dist/encoding/Xml.js.map +1 -1
- package/dist/http/FetchHttpClient.d.ts +2 -1
- package/dist/http/FetchHttpClient.d.ts.map +1 -1
- package/dist/http/FetchHttpClient.js +14 -10
- package/dist/http/FetchHttpClient.js.map +1 -1
- package/dist/http/Headers.d.ts +201 -3
- package/dist/http/Headers.d.ts.map +1 -1
- package/dist/http/Headers.js +205 -3
- package/dist/http/Headers.js.map +1 -1
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpClient.js +11 -7
- package/dist/http/HttpClient.js.map +1 -1
- package/dist/http/HttpClientError.d.ts +1 -0
- package/dist/http/HttpClientError.d.ts.map +1 -1
- package/dist/http/HttpClientError.js +32 -9
- package/dist/http/HttpClientError.js.map +1 -1
- package/dist/http/HttpClientRequest.d.ts +46 -0
- package/dist/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/http/HttpClientRequest.js +15 -0
- package/dist/http/HttpClientRequest.js.map +1 -1
- package/dist/http/HttpClientResponse.d.ts +132 -0
- package/dist/http/HttpClientResponse.d.ts.map +1 -1
- package/dist/http/HttpClientResponse.js +83 -0
- package/dist/http/HttpClientResponse.js.map +1 -1
- package/dist/http/HttpMiddleware.js +1 -1
- package/dist/http/HttpMiddleware.js.map +1 -1
- package/dist/http/HttpServerResponse.d.ts +118 -0
- package/dist/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/http/HttpServerResponse.js +43 -0
- package/dist/http/HttpServerResponse.js.map +1 -1
- package/dist/http/Multipart.d.ts.map +1 -1
- package/dist/http/Multipart.js +0 -5
- package/dist/http/Multipart.js.map +1 -1
- package/dist/http/MultipartParser/internal/contentType.d.ts +6 -0
- package/dist/http/MultipartParser/internal/contentType.d.ts.map +1 -1
- package/dist/http/MultipartParser/internal/contentType.js +1 -1
- package/dist/http/MultipartParser/internal/contentType.js.map +1 -1
- package/dist/http/internal/clientPath.d.ts +2 -0
- package/dist/http/internal/clientPath.d.ts.map +1 -0
- package/dist/http/internal/clientPath.js +24 -0
- package/dist/http/internal/clientPath.js.map +1 -0
- package/dist/http/internal/redactedPath.js +2 -0
- package/dist/http/internal/redactedPath.js.map +1 -1
- package/dist/http/internal/tracing.js +5 -3
- package/dist/http/internal/tracing.js.map +1 -1
- package/dist/http-api/HttpApi.d.ts +2 -2
- package/dist/http-api/HttpApi.d.ts.map +1 -1
- package/dist/http-api/HttpApi.js +30 -7
- package/dist/http-api/HttpApi.js.map +1 -1
- package/dist/http-api/HttpApiBuilder.d.ts.map +1 -1
- package/dist/http-api/HttpApiBuilder.js +5 -2
- package/dist/http-api/HttpApiBuilder.js.map +1 -1
- package/dist/http-api/HttpApiClient.d.ts.map +1 -1
- package/dist/http-api/HttpApiClient.js +23 -6
- package/dist/http-api/HttpApiClient.js.map +1 -1
- package/dist/http-api/internal/redactedKeys.d.ts +2 -0
- package/dist/http-api/internal/redactedKeys.d.ts.map +1 -0
- package/dist/http-api/internal/redactedKeys.js +37 -0
- package/dist/http-api/internal/redactedKeys.js.map +1 -0
- package/dist/internal/base64.js +34 -2
- package/dist/internal/base64.js.map +1 -1
- package/dist/internal/dateTime.js +35 -17
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +9 -1
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/equal.js +14 -13
- package/dist/internal/equal.js.map +1 -1
- package/dist/internal/hash.js +4 -1
- package/dist/internal/hash.js.map +1 -1
- package/dist/internal/matcher.js +17 -17
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/schema/schemaCodegen.js +3 -2
- package/dist/internal/schema/schemaCodegen.js.map +1 -1
- package/dist/internal/schema/schemaCodegenBuiltIns.d.ts +2 -0
- package/dist/internal/schema/schemaCodegenBuiltIns.d.ts.map +1 -0
- package/dist/internal/schema/schemaCodegenBuiltIns.js +425 -0
- package/dist/internal/schema/schemaCodegenBuiltIns.js.map +1 -0
- package/dist/internal/schema/toEquivalence.js +3 -4
- package/dist/internal/schema/toEquivalence.js.map +1 -1
- package/dist/internal/version.js +1 -1
- package/dist/jose/JoseError.d.ts +51 -1
- package/dist/jose/JoseError.d.ts.map +1 -1
- package/dist/jose/JoseError.js +25 -18
- package/dist/jose/JoseError.js.map +1 -1
- package/dist/jose/internal/compact.js +10 -5
- package/dist/jose/internal/compact.js.map +1 -1
- package/dist/observability/Otlp.d.ts +19 -0
- package/dist/observability/Otlp.d.ts.map +1 -1
- package/dist/observability/Otlp.js +10 -0
- package/dist/observability/Otlp.js.map +1 -1
- package/dist/observability/OtlpExporter.d.ts +49 -13
- package/dist/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/observability/OtlpExporter.js +135 -54
- package/dist/observability/OtlpExporter.js.map +1 -1
- package/dist/observability/OtlpLogger.d.ts +14 -0
- package/dist/observability/OtlpLogger.d.ts.map +1 -1
- package/dist/observability/OtlpLogger.js +10 -2
- package/dist/observability/OtlpLogger.js.map +1 -1
- package/dist/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/observability/OtlpMetrics.js +2 -0
- package/dist/observability/OtlpMetrics.js.map +1 -1
- package/dist/observability/OtlpTracer.d.ts +14 -0
- package/dist/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/observability/OtlpTracer.js +10 -2
- package/dist/observability/OtlpTracer.js.map +1 -1
- package/dist/persistence/KeyValueStore.d.ts.map +1 -1
- package/dist/persistence/KeyValueStore.js +6 -4
- package/dist/persistence/KeyValueStore.js.map +1 -1
- package/dist/reactivity/Atom.d.ts.map +1 -1
- package/dist/reactivity/Atom.js +10 -9
- package/dist/reactivity/Atom.js.map +1 -1
- package/dist/rpc/RpcClient.d.ts.map +1 -1
- package/dist/rpc/RpcClient.js +32 -1
- package/dist/rpc/RpcClient.js.map +1 -1
- package/dist/rpc/RpcGroup.d.ts +1 -1
- package/dist/rpc/RpcGroup.d.ts.map +1 -1
- package/dist/rpc/RpcGroup.js +4 -0
- package/dist/rpc/RpcGroup.js.map +1 -1
- package/dist/sql/Migrator.d.ts.map +1 -1
- package/dist/sql/Migrator.js +2 -5
- package/dist/sql/Migrator.js.map +1 -1
- package/dist/sql/SqlClient.d.ts.map +1 -1
- package/dist/sql/SqlClient.js +5 -1
- package/dist/sql/SqlClient.js.map +1 -1
- package/dist/workflow/Activity.d.ts +18 -0
- package/dist/workflow/Activity.d.ts.map +1 -1
- package/dist/workflow/Activity.js +13 -4
- package/dist/workflow/Activity.js.map +1 -1
- package/dist/workflow/Workflow.d.ts +10 -9
- package/dist/workflow/Workflow.d.ts.map +1 -1
- package/dist/workflow/Workflow.js +33 -22
- package/dist/workflow/Workflow.js.map +1 -1
- package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/workflow/WorkflowEngine.js +26 -12
- package/dist/workflow/WorkflowEngine.js.map +1 -1
- package/dist/workflow/internal/retry.d.ts +2 -0
- package/dist/workflow/internal/retry.d.ts.map +1 -0
- package/dist/workflow/internal/retry.js +11 -0
- package/dist/workflow/internal/retry.js.map +1 -0
- package/dist/workflow/internal/scope.d.ts +2 -0
- package/dist/workflow/internal/scope.d.ts.map +1 -0
- package/dist/workflow/internal/scope.js +26 -0
- package/dist/workflow/internal/scope.js.map +1 -0
- package/package.json +3 -3
- package/src/Channel.ts +105 -8
- package/src/Codegen.ts +7 -2
- package/src/Effect.ts +224 -48
- package/src/Equal.ts +85 -79
- package/src/Hash.ts +30 -22
- package/src/LayerRef.ts +6 -4
- package/src/Logger.ts +68 -25
- package/src/Match.ts +78 -50
- package/src/Order.ts +1 -1
- package/src/Schema.ts +79 -296
- package/src/SchemaAST.ts +0 -1
- package/src/ScopedCache.ts +6 -4
- package/src/Stream.ts +167 -33
- package/src/String.ts +1 -1
- package/src/Tracer.ts +10 -0
- package/src/ai/McpServer.ts +161 -4
- package/src/ai/Prompt.ts +20 -3
- package/src/ai/Skill.ts +236 -0
- package/src/ai/index.ts +6 -0
- package/src/cluster/ClusterWorkflowEngine.ts +172 -96
- package/src/cluster/MessageStorage.ts +51 -2
- package/src/cluster/SqlMessageStorage.ts +81 -34
- package/src/cluster/internal/entityActivation.ts +6 -0
- package/src/cluster/internal/entityManager.ts +8 -4
- package/src/encoding/Base64.ts +5 -1
- package/src/encoding/Base64Url.ts +6 -1
- package/src/encoding/Xml.ts +96 -26
- package/src/http/FetchHttpClient.ts +8 -5
- package/src/http/Headers.ts +309 -3
- package/src/http/HttpClient.ts +19 -7
- package/src/http/HttpClientError.ts +42 -9
- package/src/http/HttpClientRequest.ts +51 -0
- package/src/http/HttpClientResponse.ts +156 -0
- package/src/http/HttpMiddleware.ts +1 -1
- package/src/http/HttpServerResponse.ts +126 -0
- package/src/http/Multipart.ts +0 -5
- package/src/http/MultipartParser/internal/contentType.ts +1 -1
- package/src/http/internal/clientPath.ts +39 -0
- package/src/http/internal/redactedPath.ts +4 -0
- package/src/http/internal/tracing.ts +6 -3
- package/src/http-api/HttpApi.ts +29 -8
- package/src/http-api/HttpApiBuilder.ts +7 -2
- package/src/http-api/HttpApiClient.ts +30 -7
- package/src/http-api/internal/redactedKeys.ts +40 -0
- package/src/internal/base64.ts +57 -2
- package/src/internal/dateTime.ts +43 -24
- package/src/internal/effect.ts +31 -102
- package/src/internal/equal.ts +37 -17
- package/src/internal/hash.ts +5 -1
- package/src/internal/matcher.ts +34 -113
- package/src/internal/schema/schemaCodegen.ts +5 -4
- package/src/internal/schema/schemaCodegenBuiltIns.ts +343 -0
- package/src/internal/schema/toEquivalence.ts +3 -5
- package/src/internal/version.ts +1 -1
- package/src/jose/JoseError.ts +34 -0
- package/src/jose/internal/compact.ts +14 -5
- package/src/observability/Otlp.ts +29 -0
- package/src/observability/OtlpExporter.ts +206 -75
- package/src/observability/OtlpLogger.ts +24 -2
- package/src/observability/OtlpMetrics.ts +2 -0
- package/src/observability/OtlpTracer.ts +24 -3
- package/src/persistence/KeyValueStore.ts +17 -14
- package/src/reactivity/Atom.ts +12 -18
- package/src/rpc/RpcClient.ts +26 -1
- package/src/rpc/RpcGroup.ts +4 -1
- package/src/sql/Migrator.ts +2 -11
- package/src/sql/SqlClient.ts +14 -8
- package/src/workflow/Activity.ts +28 -4
- package/src/workflow/Workflow.ts +68 -44
- package/src/workflow/WorkflowEngine.ts +38 -15
- package/src/workflow/internal/retry.ts +12 -0
- package/src/workflow/internal/scope.ts +36 -0
|
@@ -27,6 +27,8 @@ import * as Semaphore from "../Semaphore.ts"
|
|
|
27
27
|
import type * as Activity from "./Activity.ts"
|
|
28
28
|
import type { DurableClock } from "./DurableClock.ts"
|
|
29
29
|
import type * as DurableDeferred from "./DurableDeferred.ts"
|
|
30
|
+
import { RetryingExecution } from "./internal/retry.ts"
|
|
31
|
+
import { reuseOrForkScope } from "./internal/scope.ts"
|
|
30
32
|
import * as Workflow from "./Workflow.ts"
|
|
31
33
|
|
|
32
34
|
/**
|
|
@@ -551,8 +553,16 @@ export const makeUnsafe = (options: Encoded): WorkflowEngine["Service"] =>
|
|
|
551
553
|
yield* Effect.annotateCurrentSpan({ executionId })
|
|
552
554
|
let result = Option.none<Workflow.Result<Success["Type"], Error["Type"]>>()
|
|
553
555
|
|
|
554
|
-
// link interruption with parent workflow
|
|
555
556
|
const parentInstance = yield* Effect.serviceOption(WorkflowInstance)
|
|
557
|
+
if (
|
|
558
|
+
!opts.discard &&
|
|
559
|
+
Option.isSome(parentInstance) &&
|
|
560
|
+
parentInstance.value.workflow._tag === self._tag &&
|
|
561
|
+
parentInstance.value.executionId === executionId
|
|
562
|
+
) {
|
|
563
|
+
return yield* Effect.die(`${self._tag}.execute: execution "${executionId}" cannot await itself`)
|
|
564
|
+
}
|
|
565
|
+
// link interruption with parent workflow
|
|
556
566
|
if (Option.isSome(parentInstance) && !opts.detached) {
|
|
557
567
|
const instance = parentInstance.value
|
|
558
568
|
yield* Effect.addFinalizer(() => {
|
|
@@ -748,7 +758,7 @@ export const layerMemory: Layer.Layer<WorkflowEngine> = Layer.effect(WorkflowEng
|
|
|
748
758
|
payload: object,
|
|
749
759
|
executionId: string
|
|
750
760
|
) => Effect.Effect<unknown, unknown, WorkflowInstance | WorkflowEngine>
|
|
751
|
-
readonly
|
|
761
|
+
readonly parents: Set<string>
|
|
752
762
|
instance: WorkflowInstance["Service"]
|
|
753
763
|
interrupted: boolean
|
|
754
764
|
interruptedUnsafe: boolean
|
|
@@ -809,10 +819,10 @@ export const layerMemory: Layer.Layer<WorkflowEngine> = Layer.effect(WorkflowEng
|
|
|
809
819
|
state.scope = Scope.makeUnsafe()
|
|
810
820
|
}
|
|
811
821
|
const executionScope = state.scope
|
|
812
|
-
//
|
|
813
|
-
|
|
822
|
+
// A superseded instance retained by a finalizer no longer needs its wait set.
|
|
823
|
+
state.instance.awaitedDeferreds.clear()
|
|
814
824
|
const instance = WorkflowInstance.initial(state.instance.workflow, state.instance.executionId, {
|
|
815
|
-
scope:
|
|
825
|
+
scope: reuseOrForkScope(state.instance.scope, executionScope)
|
|
816
826
|
})
|
|
817
827
|
state.instance = instance
|
|
818
828
|
state.fiber = yield* state.execute(state.payload, state.instance.executionId).pipe(
|
|
@@ -835,23 +845,33 @@ export const layerMemory: Layer.Layer<WorkflowEngine> = Layer.effect(WorkflowEng
|
|
|
835
845
|
// Deferred wakes interrupt only the body, so `intoResult` still reports `Suspended`.
|
|
836
846
|
(effect) => deferredState.trackRun(instance, effect),
|
|
837
847
|
Workflow.intoResult,
|
|
848
|
+
// Clear any retry region inherited from the caller or child fiber that started or woke this run.
|
|
849
|
+
Effect.provideService(RetryingExecution, undefined),
|
|
838
850
|
Effect.provideService(WorkflowInstance, instance),
|
|
839
851
|
Effect.provideService(WorkflowEngine, engine),
|
|
840
|
-
Effect.tap((result) => {
|
|
841
|
-
if (!state.parent || result._tag !== "Complete") {
|
|
842
|
-
return Effect.void
|
|
843
|
-
}
|
|
844
|
-
return Effect.forkIn(resume(state.parent, "automatic"), scope)
|
|
845
|
-
}),
|
|
846
852
|
Effect.onExit((exit) => {
|
|
847
853
|
if (Exit.isSuccess(exit) && exit.value._tag === "Suspended") return Effect.void
|
|
848
854
|
// The final run's scope closes with the real exit. Closing the parent
|
|
849
855
|
// then closes earlier scopes in reverse order with `Exit.void`, so their
|
|
850
856
|
// superseded compensations are skipped, which means their finalizers
|
|
851
857
|
// also observe success rather than the outcome.
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
858
|
+
const close = Scope.close(executionScope, Exit.void)
|
|
859
|
+
if (Exit.isFailure(exit)) return close
|
|
860
|
+
// Wake parents only after the fiber exits so `poll` already observes
|
|
861
|
+
// `Complete` and joins during finalization are included.
|
|
862
|
+
const wakeParents = (fiber: Fiber.Fiber<unknown, unknown>) =>
|
|
863
|
+
Fiber.await(fiber).pipe(
|
|
864
|
+
Effect.flatMap(() =>
|
|
865
|
+
Effect.forEach(state.parents, (parent) => Effect.forkIn(resume(parent, "automatic"), scope), {
|
|
866
|
+
discard: true
|
|
867
|
+
})
|
|
868
|
+
),
|
|
869
|
+
Effect.forkIn(scope)
|
|
870
|
+
)
|
|
871
|
+
return close.pipe(
|
|
872
|
+
Effect.andThen(Deferred.succeed(state.done, void 0)),
|
|
873
|
+
// A dying finalizer must not strand parents; they observe the defect.
|
|
874
|
+
Effect.ensuring(Effect.withFiber(wakeParents))
|
|
855
875
|
)
|
|
856
876
|
}),
|
|
857
877
|
Effect.forkIn(entry.scope)
|
|
@@ -876,6 +896,7 @@ export const layerMemory: Layer.Layer<WorkflowEngine> = Layer.effect(WorkflowEng
|
|
|
876
896
|
return yield* Effect.orDie(Effect.fail(`Workflow ${workflow._tag} is not registered`))
|
|
877
897
|
}
|
|
878
898
|
|
|
899
|
+
const parentId = options.detached ? undefined : options.parent?.executionId
|
|
879
900
|
let state = executions.get(options.executionId)
|
|
880
901
|
if (!state) {
|
|
881
902
|
state = {
|
|
@@ -888,10 +909,12 @@ export const layerMemory: Layer.Layer<WorkflowEngine> = Layer.effect(WorkflowEng
|
|
|
888
909
|
fiber: undefined,
|
|
889
910
|
done: Deferred.makeUnsafe(),
|
|
890
911
|
scope: Scope.makeUnsafe(),
|
|
891
|
-
|
|
912
|
+
parents: new Set(parentId === undefined ? [] : [parentId])
|
|
892
913
|
}
|
|
893
914
|
executions.set(options.executionId, state)
|
|
894
915
|
yield* resume(options.executionId, "explicit")
|
|
916
|
+
} else if (parentId !== undefined) {
|
|
917
|
+
state.parents.add(parentId)
|
|
895
918
|
}
|
|
896
919
|
if (options.discard) return
|
|
897
920
|
// Capture together so a wake that swaps in a replay cannot desync them.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as Context from "../../Context.ts"
|
|
2
|
+
import { constUndefined } from "../../Function.ts"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The id of the execution whose `Activity.retry` the current fiber is inside.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export const RetryingExecution = Context.Reference<string | undefined>(
|
|
10
|
+
"effect/workflow/Activity/RetryingExecution",
|
|
11
|
+
{ defaultValue: constUndefined }
|
|
12
|
+
)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as Scope from "../../Scope.ts"
|
|
2
|
+
|
|
3
|
+
const abandonedScopes = new WeakSet<Scope.Scope>()
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Marks `scope` and its direct children as abandoned, so engines need not
|
|
7
|
+
* retain the instances of the runs under it.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export const markScopeAbandoned = (scope: Scope.Scope): void => {
|
|
12
|
+
abandonedScopes.add(scope)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Reports whether `scope` or its parent scope was marked abandoned.
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export const isScopeAbandoned = (scope: Scope.Scope): boolean =>
|
|
21
|
+
abandonedScopes.has(scope) || (scope.parent !== undefined && abandonedScopes.has(scope.parent))
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Reuses `prev` while it is still an empty child of `parent`, so replays that
|
|
25
|
+
* register nothing do not grow `parent`. Otherwise forks a fresh child, which
|
|
26
|
+
* keeps a superseded run's compensations apart from the next run's.
|
|
27
|
+
*
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
export const reuseOrForkScope = (
|
|
31
|
+
prev: Scope.Closeable | undefined,
|
|
32
|
+
parent: Scope.Scope
|
|
33
|
+
): Scope.Closeable =>
|
|
34
|
+
prev !== undefined && prev.parent === parent && prev.state._tag === "Empty"
|
|
35
|
+
? prev
|
|
36
|
+
: Scope.forkUnsafe(parent)
|