effect 3.12.0 → 3.12.2
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/dist/cjs/BigDecimal.js +3 -3
- package/dist/cjs/Effect.js +2957 -928
- package/dist/cjs/Effect.js.map +1 -1
- package/dist/cjs/GlobalValue.js +8 -6
- package/dist/cjs/GlobalValue.js.map +1 -1
- package/dist/cjs/HashMap.js +2 -2
- package/dist/cjs/HashMap.js.map +1 -1
- package/dist/cjs/ManagedRuntime.js.map +1 -1
- package/dist/cjs/Predicate.js.map +1 -1
- package/dist/cjs/Request.js +3 -3
- package/dist/cjs/Request.js.map +1 -1
- package/dist/cjs/RequestBlock.js +7 -7
- package/dist/cjs/RequestBlock.js.map +1 -1
- package/dist/cjs/Runtime.js.map +1 -1
- package/dist/cjs/Schema.js +5 -8
- package/dist/cjs/Schema.js.map +1 -1
- package/dist/cjs/Stream.js +5 -5
- package/dist/cjs/Stream.js.map +1 -1
- package/dist/cjs/internal/channel.js +3 -3
- package/dist/cjs/internal/channel.js.map +1 -1
- package/dist/cjs/internal/core-effect.js +3 -3
- package/dist/cjs/internal/core-effect.js.map +1 -1
- package/dist/cjs/internal/core.js +19 -33
- package/dist/cjs/internal/core.js.map +1 -1
- package/dist/cjs/internal/defaultServices.js +2 -2
- package/dist/cjs/internal/defaultServices.js.map +1 -1
- package/dist/cjs/internal/effect/circular.js +4 -4
- package/dist/cjs/internal/effect/circular.js.map +1 -1
- package/dist/cjs/internal/fiberRefs/patch.js +5 -5
- package/dist/cjs/internal/fiberRefs/patch.js.map +1 -1
- package/dist/cjs/internal/fiberRuntime.js +40 -37
- package/dist/cjs/internal/fiberRuntime.js.map +1 -1
- package/dist/cjs/internal/fiberScope.js.map +1 -1
- package/dist/cjs/internal/layer/circular.js +2 -2
- package/dist/cjs/internal/layer/circular.js.map +1 -1
- package/dist/cjs/internal/logSpan.js +10 -3
- package/dist/cjs/internal/logSpan.js.map +1 -1
- package/dist/cjs/internal/logger-circular.js +2 -2
- package/dist/cjs/internal/logger-circular.js.map +1 -1
- package/dist/cjs/internal/logger.js +44 -118
- package/dist/cjs/internal/logger.js.map +1 -1
- package/dist/cjs/internal/metric.js +3 -3
- package/dist/cjs/internal/metric.js.map +1 -1
- package/dist/cjs/internal/reloadable.js +7 -7
- package/dist/cjs/internal/reloadable.js.map +1 -1
- package/dist/cjs/internal/resource.js +2 -2
- package/dist/cjs/internal/resource.js.map +1 -1
- package/dist/cjs/internal/runtime.js +7 -7
- package/dist/cjs/internal/runtime.js.map +1 -1
- package/dist/cjs/internal/scopedCache.js +9 -9
- package/dist/cjs/internal/scopedCache.js.map +1 -1
- package/dist/cjs/internal/stream.js +28 -28
- package/dist/cjs/internal/stream.js.map +1 -1
- package/dist/cjs/internal/subscriptionRef.js +4 -4
- package/dist/cjs/internal/subscriptionRef.js.map +1 -1
- package/dist/cjs/internal/synchronizedRef.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/dts/BigDecimal.d.ts +3 -3
- package/dist/dts/Effect.d.ts +6541 -2072
- package/dist/dts/Effect.d.ts.map +1 -1
- package/dist/dts/GlobalValue.d.ts.map +1 -1
- package/dist/dts/Layer.d.ts +3 -3
- package/dist/dts/Layer.d.ts.map +1 -1
- package/dist/dts/ManagedRuntime.d.ts +2 -2
- package/dist/dts/ManagedRuntime.d.ts.map +1 -1
- package/dist/dts/Predicate.d.ts +1 -1
- package/dist/dts/Predicate.d.ts.map +1 -1
- package/dist/dts/Runtime.d.ts +2 -2
- package/dist/dts/Runtime.d.ts.map +1 -1
- package/dist/dts/Schema.d.ts.map +1 -1
- package/dist/dts/Utils.d.ts +4 -4
- package/dist/dts/Utils.d.ts.map +1 -1
- package/dist/dts/internal/core-effect.d.ts.map +1 -1
- package/dist/dts/internal/core.d.ts.map +1 -1
- package/dist/dts/internal/fiberScope.d.ts.map +1 -1
- package/dist/dts/internal/logger.d.ts +1 -1
- package/dist/dts/internal/logger.d.ts.map +1 -1
- package/dist/esm/BigDecimal.js +3 -3
- package/dist/esm/Effect.js +2958 -929
- package/dist/esm/Effect.js.map +1 -1
- package/dist/esm/GlobalValue.js +8 -6
- package/dist/esm/GlobalValue.js.map +1 -1
- package/dist/esm/HashMap.js +2 -2
- package/dist/esm/HashMap.js.map +1 -1
- package/dist/esm/ManagedRuntime.js.map +1 -1
- package/dist/esm/Predicate.js.map +1 -1
- package/dist/esm/Request.js +3 -3
- package/dist/esm/Request.js.map +1 -1
- package/dist/esm/RequestBlock.js +7 -7
- package/dist/esm/RequestBlock.js.map +1 -1
- package/dist/esm/Runtime.js.map +1 -1
- package/dist/esm/Schema.js +5 -8
- package/dist/esm/Schema.js.map +1 -1
- package/dist/esm/Stream.js +5 -5
- package/dist/esm/Stream.js.map +1 -1
- package/dist/esm/internal/channel.js +3 -3
- package/dist/esm/internal/channel.js.map +1 -1
- package/dist/esm/internal/core-effect.js +3 -3
- package/dist/esm/internal/core-effect.js.map +1 -1
- package/dist/esm/internal/core.js +16 -28
- package/dist/esm/internal/core.js.map +1 -1
- package/dist/esm/internal/defaultServices.js +2 -2
- package/dist/esm/internal/defaultServices.js.map +1 -1
- package/dist/esm/internal/effect/circular.js +4 -4
- package/dist/esm/internal/effect/circular.js.map +1 -1
- package/dist/esm/internal/fiberRefs/patch.js +5 -5
- package/dist/esm/internal/fiberRefs/patch.js.map +1 -1
- package/dist/esm/internal/fiberRuntime.js +40 -37
- package/dist/esm/internal/fiberRuntime.js.map +1 -1
- package/dist/esm/internal/fiberScope.js.map +1 -1
- package/dist/esm/internal/layer/circular.js +2 -2
- package/dist/esm/internal/layer/circular.js.map +1 -1
- package/dist/esm/internal/logSpan.js +7 -1
- package/dist/esm/internal/logSpan.js.map +1 -1
- package/dist/esm/internal/logger-circular.js +2 -2
- package/dist/esm/internal/logger-circular.js.map +1 -1
- package/dist/esm/internal/logger.js +45 -119
- package/dist/esm/internal/logger.js.map +1 -1
- package/dist/esm/internal/metric.js +3 -3
- package/dist/esm/internal/metric.js.map +1 -1
- package/dist/esm/internal/reloadable.js +7 -7
- package/dist/esm/internal/reloadable.js.map +1 -1
- package/dist/esm/internal/resource.js +2 -2
- package/dist/esm/internal/resource.js.map +1 -1
- package/dist/esm/internal/runtime.js +7 -7
- package/dist/esm/internal/runtime.js.map +1 -1
- package/dist/esm/internal/scopedCache.js +9 -9
- package/dist/esm/internal/scopedCache.js.map +1 -1
- package/dist/esm/internal/stream.js +28 -28
- package/dist/esm/internal/stream.js.map +1 -1
- package/dist/esm/internal/subscriptionRef.js +4 -4
- package/dist/esm/internal/subscriptionRef.js.map +1 -1
- package/dist/esm/internal/synchronizedRef.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/package.json +1 -1
- package/src/BigDecimal.ts +3 -3
- package/src/Effect.ts +6587 -2108
- package/src/GlobalValue.ts +8 -6
- package/src/HashMap.ts +2 -2
- package/src/Layer.ts +3 -3
- package/src/ManagedRuntime.ts +3 -2
- package/src/Predicate.ts +2 -2
- package/src/Request.ts +3 -3
- package/src/RequestBlock.ts +7 -7
- package/src/Runtime.ts +2 -5
- package/src/Schema.ts +5 -8
- package/src/Stream.ts +5 -5
- package/src/Utils.ts +4 -4
- package/src/internal/channel.ts +3 -3
- package/src/internal/core-effect.ts +4 -6
- package/src/internal/core.ts +28 -54
- package/src/internal/defaultServices.ts +10 -10
- package/src/internal/effect/circular.ts +54 -49
- package/src/internal/fiberRefs/patch.ts +5 -5
- package/src/internal/fiberRuntime.ts +54 -48
- package/src/internal/fiberScope.ts +0 -1
- package/src/internal/layer/circular.ts +2 -2
- package/src/internal/logSpan.ts +8 -1
- package/src/internal/logger-circular.ts +2 -2
- package/src/internal/logger.ts +54 -145
- package/src/internal/metric.ts +3 -3
- package/src/internal/reloadable.ts +10 -10
- package/src/internal/resource.ts +2 -2
- package/src/internal/runtime.ts +8 -8
- package/src/internal/scopedCache.ts +23 -23
- package/src/internal/stream.ts +30 -30
- package/src/internal/subscriptionRef.ts +4 -4
- package/src/internal/synchronizedRef.ts +0 -1
- package/src/internal/version.ts +1 -1
|
@@ -24,7 +24,7 @@ import * as Ref from "../Ref.js";
|
|
|
24
24
|
import * as RuntimeFlagsPatch from "../RuntimeFlagsPatch.js";
|
|
25
25
|
import { currentScheduler } from "../Scheduler.js";
|
|
26
26
|
import { internalCall, yieldWrapGet } from "../Utils.js";
|
|
27
|
-
import * as
|
|
27
|
+
import * as RequestBlock_ from "./blockedRequests.js";
|
|
28
28
|
import * as internalCause from "./cause.js";
|
|
29
29
|
import * as clock from "./clock.js";
|
|
30
30
|
import { currentRequestMap } from "./completedRequestMap.js";
|
|
@@ -46,7 +46,7 @@ import * as metricLabel from "./metric/label.js";
|
|
|
46
46
|
import * as OpCodes from "./opCodes/effect.js";
|
|
47
47
|
import { randomTag } from "./random.js";
|
|
48
48
|
import { complete } from "./request.js";
|
|
49
|
-
import * as
|
|
49
|
+
import * as runtimeFlags_ from "./runtimeFlags.js";
|
|
50
50
|
import { OpSupervision } from "./runtimeFlags.js";
|
|
51
51
|
import * as supervisor from "./supervisor.js";
|
|
52
52
|
import * as SupervisorPatch from "./supervisor/patch.js";
|
|
@@ -103,7 +103,7 @@ const contOpSuccess = {
|
|
|
103
103
|
},
|
|
104
104
|
[OpCodes.OP_REVERT_FLAGS]: (self, cont, value) => {
|
|
105
105
|
self.patchRuntimeFlags(self.currentRuntimeFlags, cont.patch);
|
|
106
|
-
if (
|
|
106
|
+
if (runtimeFlags_.interruptible(self.currentRuntimeFlags) && self.isInterrupted()) {
|
|
107
107
|
return core.exitFailCause(self.getInterruptedCause());
|
|
108
108
|
} else {
|
|
109
109
|
return core.exitSucceed(value);
|
|
@@ -128,7 +128,7 @@ const contOpSuccess = {
|
|
|
128
128
|
const drainQueueWhileRunningTable = {
|
|
129
129
|
[FiberMessage.OP_INTERRUPT_SIGNAL]: (self, runtimeFlags, cur, message) => {
|
|
130
130
|
self.processNewInterruptSignal(message.cause);
|
|
131
|
-
return
|
|
131
|
+
return runtimeFlags_.interruptible(runtimeFlags) ? core.exitFailCause(message.cause) : cur;
|
|
132
132
|
},
|
|
133
133
|
[FiberMessage.OP_RESUME]: (_self, _runtimeFlags, _cur, _message) => {
|
|
134
134
|
throw new Error("It is illegal to have multiple concurrent run loops in a single fiber");
|
|
@@ -144,7 +144,7 @@ const drainQueueWhileRunningTable = {
|
|
|
144
144
|
/**
|
|
145
145
|
* Executes all requests, submitting requests to each data source in parallel.
|
|
146
146
|
*/
|
|
147
|
-
const runBlockedRequests = self => core.forEachSequentialDiscard(
|
|
147
|
+
const runBlockedRequests = self => core.forEachSequentialDiscard(RequestBlock_.flatten(self), requestsByRequestResolver => forEachConcurrentDiscard(RequestBlock_.sequentialCollectionToChunk(requestsByRequestResolver), ([dataSource, sequential]) => {
|
|
148
148
|
const map = new Map();
|
|
149
149
|
const arr = [];
|
|
150
150
|
for (const block of sequential) {
|
|
@@ -158,6 +158,7 @@ const runBlockedRequests = self => core.forEachSequentialDiscard(_RequestBlock.f
|
|
|
158
158
|
entry.listeners.interrupted = true;
|
|
159
159
|
})), currentRequestMap, map);
|
|
160
160
|
}, false, false));
|
|
161
|
+
const _version = /*#__PURE__*/version.getCurrentVersion();
|
|
161
162
|
/** @internal */
|
|
162
163
|
export class FiberRuntime extends Effectable.Class {
|
|
163
164
|
[internalFiber.FiberTypeId] = internalFiber.fiberVariance;
|
|
@@ -187,7 +188,7 @@ export class FiberRuntime extends Effectable.Class {
|
|
|
187
188
|
this.currentRuntimeFlags = runtimeFlags0;
|
|
188
189
|
this._fiberId = fiberId;
|
|
189
190
|
this._fiberRefs = fiberRefs0;
|
|
190
|
-
if (
|
|
191
|
+
if (runtimeFlags_.runtimeMetrics(runtimeFlags0)) {
|
|
191
192
|
const tags = this.getFiberRef(core.currentMetricLabels);
|
|
192
193
|
fiberStarted.unsafeUpdate(1, tags);
|
|
193
194
|
fiberActive.unsafeUpdate(1, tags);
|
|
@@ -316,9 +317,9 @@ export class FiberRuntime extends Effectable.Class {
|
|
|
316
317
|
const updatedFiberRefs = fiberRefs.joinAs(parentFiberRefs, parentFiberId, childFiberRefs);
|
|
317
318
|
parentFiber.setFiberRefs(updatedFiberRefs);
|
|
318
319
|
const updatedRuntimeFlags = parentFiber.getFiberRef(currentRuntimeFlags);
|
|
319
|
-
const patch = pipe(
|
|
320
|
+
const patch = pipe(runtimeFlags_.diff(parentRuntimeFlags, updatedRuntimeFlags),
|
|
320
321
|
// Do not inherit WindDown or Interruption!
|
|
321
|
-
RuntimeFlagsPatch.exclude(
|
|
322
|
+
RuntimeFlagsPatch.exclude(runtimeFlags_.Interruption), RuntimeFlagsPatch.exclude(runtimeFlags_.WindDown));
|
|
322
323
|
return core.updateRuntimeFlags(patch);
|
|
323
324
|
});
|
|
324
325
|
}
|
|
@@ -612,7 +613,7 @@ export class FiberRuntime extends Effectable.Class {
|
|
|
612
613
|
return null;
|
|
613
614
|
}
|
|
614
615
|
reportExitValue(exit) {
|
|
615
|
-
if (
|
|
616
|
+
if (runtimeFlags_.runtimeMetrics(this.currentRuntimeFlags)) {
|
|
616
617
|
const tags = this.getFiberRef(core.currentMetricLabels);
|
|
617
618
|
const startTimeMillis = this.id().startTimeMillis;
|
|
618
619
|
const endTimeMillis = Date.now();
|
|
@@ -726,7 +727,7 @@ export class FiberRuntime extends Effectable.Class {
|
|
|
726
727
|
evaluateEffect(effect0) {
|
|
727
728
|
this.currentSupervisor.onResume(this);
|
|
728
729
|
try {
|
|
729
|
-
let effect =
|
|
730
|
+
let effect = runtimeFlags_.interruptible(this.currentRuntimeFlags) && this.isInterrupted() ? core.exitFailCause(this.getInterruptedCause()) : effect0;
|
|
730
731
|
while (effect !== null) {
|
|
731
732
|
const eff = effect;
|
|
732
733
|
const exit = this.runLoop(eff);
|
|
@@ -734,7 +735,7 @@ export class FiberRuntime extends Effectable.Class {
|
|
|
734
735
|
const op = yieldedOpChannel.currentOp;
|
|
735
736
|
yieldedOpChannel.currentOp = null;
|
|
736
737
|
if (op._op === OpCodes.OP_YIELD) {
|
|
737
|
-
if (
|
|
738
|
+
if (runtimeFlags_.cooperativeYielding(this.currentRuntimeFlags)) {
|
|
738
739
|
this.tell(FiberMessage.yieldNow());
|
|
739
740
|
this.tell(FiberMessage.resume(core.exitVoid));
|
|
740
741
|
effect = null;
|
|
@@ -746,7 +747,7 @@ export class FiberRuntime extends Effectable.Class {
|
|
|
746
747
|
effect = null;
|
|
747
748
|
}
|
|
748
749
|
} else {
|
|
749
|
-
this.currentRuntimeFlags = pipe(this.currentRuntimeFlags,
|
|
750
|
+
this.currentRuntimeFlags = pipe(this.currentRuntimeFlags, runtimeFlags_.enable(runtimeFlags_.WindDown));
|
|
750
751
|
const interruption = this.interruptAllChildren();
|
|
751
752
|
if (interruption !== null) {
|
|
752
753
|
effect = core.flatMap(interruption, () => exit);
|
|
@@ -815,7 +816,7 @@ export class FiberRuntime extends Effectable.Class {
|
|
|
815
816
|
* **NOTE**: This method must be invoked by the fiber itself.
|
|
816
817
|
*/
|
|
817
818
|
patchRuntimeFlags(oldRuntimeFlags, patch) {
|
|
818
|
-
const newRuntimeFlags =
|
|
819
|
+
const newRuntimeFlags = runtimeFlags_.patch(oldRuntimeFlags, patch);
|
|
819
820
|
globalThis[internalFiber.currentFiberURI] = this;
|
|
820
821
|
this.currentRuntimeFlags = newRuntimeFlags;
|
|
821
822
|
return newRuntimeFlags;
|
|
@@ -835,7 +836,7 @@ export class FiberRuntime extends Effectable.Class {
|
|
|
835
836
|
this.tell(FiberMessage.resume(effect));
|
|
836
837
|
}
|
|
837
838
|
};
|
|
838
|
-
if (
|
|
839
|
+
if (runtimeFlags_.interruptible(runtimeFlags)) {
|
|
839
840
|
this._asyncInterruptor = callback;
|
|
840
841
|
}
|
|
841
842
|
try {
|
|
@@ -965,7 +966,7 @@ export class FiberRuntime extends Effectable.Class {
|
|
|
965
966
|
case OpCodes.OP_ON_FAILURE:
|
|
966
967
|
case OpCodes.OP_ON_SUCCESS_AND_FAILURE:
|
|
967
968
|
{
|
|
968
|
-
if (!(
|
|
969
|
+
if (!(runtimeFlags_.interruptible(this.currentRuntimeFlags) && this.isInterrupted())) {
|
|
969
970
|
return internalCall(() => cont.effect_instruction_i1(cause));
|
|
970
971
|
} else {
|
|
971
972
|
return core.exitFailCause(internalCause.stripFailures(cause));
|
|
@@ -973,7 +974,7 @@ export class FiberRuntime extends Effectable.Class {
|
|
|
973
974
|
}
|
|
974
975
|
case "OnStep":
|
|
975
976
|
{
|
|
976
|
-
if (!(
|
|
977
|
+
if (!(runtimeFlags_.interruptible(this.currentRuntimeFlags) && this.isInterrupted())) {
|
|
977
978
|
return core.exitSucceed(core.exitFailCause(cause));
|
|
978
979
|
} else {
|
|
979
980
|
return core.exitFailCause(internalCause.stripFailures(cause));
|
|
@@ -982,7 +983,7 @@ export class FiberRuntime extends Effectable.Class {
|
|
|
982
983
|
case OpCodes.OP_REVERT_FLAGS:
|
|
983
984
|
{
|
|
984
985
|
this.patchRuntimeFlags(this.currentRuntimeFlags, cont.patch);
|
|
985
|
-
if (
|
|
986
|
+
if (runtimeFlags_.interruptible(this.currentRuntimeFlags) && this.isInterrupted()) {
|
|
986
987
|
return core.exitFailCause(internalCause.sequential(cause, this.getInterruptedCause()));
|
|
987
988
|
} else {
|
|
988
989
|
return core.exitFailCause(cause);
|
|
@@ -1015,13 +1016,13 @@ export class FiberRuntime extends Effectable.Class {
|
|
|
1015
1016
|
this.setFiberRefs(snap.refs);
|
|
1016
1017
|
this.currentRuntimeFlags = snap.flags;
|
|
1017
1018
|
const patchRefs = FiberRefsPatch.diff(snap.refs, refs);
|
|
1018
|
-
const patchFlags =
|
|
1019
|
+
const patchFlags = runtimeFlags_.diff(snap.flags, flags);
|
|
1019
1020
|
return core.exitSucceed(core.blocked(op.effect_instruction_i0, core.withFiberRuntime(newFiber => {
|
|
1020
1021
|
while (frames.length > 0) {
|
|
1021
1022
|
newFiber.pushStack(frames.pop());
|
|
1022
1023
|
}
|
|
1023
1024
|
newFiber.setFiberRefs(FiberRefsPatch.patch(newFiber.id(), newFiber.getFiberRefs())(patchRefs));
|
|
1024
|
-
newFiber.currentRuntimeFlags =
|
|
1025
|
+
newFiber.currentRuntimeFlags = runtimeFlags_.patch(patchFlags)(newFiber.currentRuntimeFlags);
|
|
1025
1026
|
return op.effect_instruction_i1;
|
|
1026
1027
|
})));
|
|
1027
1028
|
}
|
|
@@ -1033,19 +1034,19 @@ export class FiberRuntime extends Effectable.Class {
|
|
|
1033
1034
|
[OpCodes.OP_UPDATE_RUNTIME_FLAGS](op) {
|
|
1034
1035
|
const updateFlags = op.effect_instruction_i0;
|
|
1035
1036
|
const oldRuntimeFlags = this.currentRuntimeFlags;
|
|
1036
|
-
const newRuntimeFlags =
|
|
1037
|
+
const newRuntimeFlags = runtimeFlags_.patch(oldRuntimeFlags, updateFlags);
|
|
1037
1038
|
// One more chance to short circuit: if we're immediately going
|
|
1038
1039
|
// to interrupt. Interruption will cause immediate reversion of
|
|
1039
1040
|
// the flag, so as long as we "peek ahead", there's no need to
|
|
1040
1041
|
// set them to begin with.
|
|
1041
|
-
if (
|
|
1042
|
+
if (runtimeFlags_.interruptible(newRuntimeFlags) && this.isInterrupted()) {
|
|
1042
1043
|
return core.exitFailCause(this.getInterruptedCause());
|
|
1043
1044
|
} else {
|
|
1044
1045
|
// Impossible to short circuit, so record the changes
|
|
1045
1046
|
this.patchRuntimeFlags(this.currentRuntimeFlags, updateFlags);
|
|
1046
1047
|
if (op.effect_instruction_i1) {
|
|
1047
1048
|
// Since we updated the flags, we need to revert them
|
|
1048
|
-
const revertFlags =
|
|
1049
|
+
const revertFlags = runtimeFlags_.diff(newRuntimeFlags, oldRuntimeFlags);
|
|
1049
1050
|
this.pushStack(new core.RevertFlags(revertFlags, op));
|
|
1050
1051
|
return internalCall(() => op.effect_instruction_i1(oldRuntimeFlags));
|
|
1051
1052
|
} else {
|
|
@@ -1126,7 +1127,7 @@ export class FiberRuntime extends Effectable.Class {
|
|
|
1126
1127
|
try {
|
|
1127
1128
|
// @ts-expect-error
|
|
1128
1129
|
cur = this.currentTracer.context(() => {
|
|
1129
|
-
if (
|
|
1130
|
+
if (_version !== cur[core.EffectTypeId]._V) {
|
|
1130
1131
|
return core.dieMessage(`Cannot execute an Effect versioned ${cur[core.EffectTypeId]._V} with a Runtime of version ${version.getCurrentVersion()}`);
|
|
1131
1132
|
}
|
|
1132
1133
|
// @ts-expect-error
|
|
@@ -1143,8 +1144,6 @@ export class FiberRuntime extends Effectable.Class {
|
|
|
1143
1144
|
} catch (e) {
|
|
1144
1145
|
if (cur !== YieldedOp && !Predicate.hasProperty(cur, "_op") || !(cur._op in this)) {
|
|
1145
1146
|
cur = core.dieMessage(`Not a valid effect: ${Inspectable.toStringUnknown(cur)}`);
|
|
1146
|
-
} else if (core.isEffectError(e)) {
|
|
1147
|
-
cur = core.exitFailCause(e.cause);
|
|
1148
1147
|
} else if (core.isInterruptedException(e)) {
|
|
1149
1148
|
cur = core.exitFailCause(internalCause.sequential(internalCause.die(e), internalCause.interrupt(FiberId.none)));
|
|
1150
1149
|
} else {
|
|
@@ -1281,7 +1280,7 @@ export const addFinalizer = finalizer => core.withFiberRuntime(runtime => {
|
|
|
1281
1280
|
const preRefs = runtimeFinalizer.getFiberRefs();
|
|
1282
1281
|
const preFlags = runtimeFinalizer.currentRuntimeFlags;
|
|
1283
1282
|
const patchRefs = FiberRefsPatch.diff(preRefs, acquireRefs);
|
|
1284
|
-
const patchFlags =
|
|
1283
|
+
const patchFlags = runtimeFlags_.diff(preFlags, acquireFlags);
|
|
1285
1284
|
const inverseRefs = FiberRefsPatch.diff(acquireRefs, preRefs);
|
|
1286
1285
|
runtimeFinalizer.setFiberRefs(FiberRefsPatch.patch(patchRefs, runtimeFinalizer.id(), acquireRefs));
|
|
1287
1286
|
return ensuring(core.withRuntimeFlags(finalizer(exit), patchFlags), core.sync(() => {
|
|
@@ -1339,7 +1338,8 @@ const allValidate = (effects, reconcile, options) => {
|
|
|
1339
1338
|
}
|
|
1340
1339
|
return core.flatMap(forEach(eitherEffects, identity, {
|
|
1341
1340
|
concurrency: options?.concurrency,
|
|
1342
|
-
batching: options?.batching
|
|
1341
|
+
batching: options?.batching,
|
|
1342
|
+
concurrentFinalizers: options?.concurrentFinalizers
|
|
1343
1343
|
}), eithers => {
|
|
1344
1344
|
const none = Option.none();
|
|
1345
1345
|
const size = eithers.length;
|
|
@@ -1373,12 +1373,14 @@ const allEither = (effects, reconcile, options) => {
|
|
|
1373
1373
|
return forEach(eitherEffects, identity, {
|
|
1374
1374
|
concurrency: options?.concurrency,
|
|
1375
1375
|
batching: options?.batching,
|
|
1376
|
-
discard: true
|
|
1376
|
+
discard: true,
|
|
1377
|
+
concurrentFinalizers: options?.concurrentFinalizers
|
|
1377
1378
|
});
|
|
1378
1379
|
}
|
|
1379
1380
|
return core.map(forEach(eitherEffects, identity, {
|
|
1380
1381
|
concurrency: options?.concurrency,
|
|
1381
|
-
batching: options?.batching
|
|
1382
|
+
batching: options?.batching,
|
|
1383
|
+
concurrentFinalizers: options?.concurrentFinalizers
|
|
1382
1384
|
}), eithers => reconcile._tag === "Some" ? reconcile.value(eithers) : eithers);
|
|
1383
1385
|
};
|
|
1384
1386
|
/* @internal */
|
|
@@ -1523,7 +1525,7 @@ export const forEachConcurrentDiscard = (self, f, batching, processAll, n) => co
|
|
|
1523
1525
|
parallel: true
|
|
1524
1526
|
}), () => core.exitVoid)));
|
|
1525
1527
|
} else if (residual.length + results.length === target) {
|
|
1526
|
-
const requests = residual.map(blocked => blocked.effect_instruction_i0).reduce(
|
|
1528
|
+
const requests = residual.map(blocked => blocked.effect_instruction_i0).reduce(RequestBlock_.par);
|
|
1527
1529
|
resume(core.succeed(core.blocked(requests, forEachConcurrentDiscard([Option.getOrElse(core.exitCollectAll(collectExits(), {
|
|
1528
1530
|
parallel: true
|
|
1529
1531
|
}), () => core.exitVoid), ...residual.map(blocked => blocked.effect_instruction_i1)], i => i, batching, true, n))));
|
|
@@ -1628,8 +1630,9 @@ export const partition = /*#__PURE__*/dual(args => Predicate.isIterable(args[0])
|
|
|
1628
1630
|
/* @internal */
|
|
1629
1631
|
export const validateAll = /*#__PURE__*/dual(args => Predicate.isIterable(args[0]), (elements, f, options) => core.flatMap(partition(elements, f, {
|
|
1630
1632
|
concurrency: options?.concurrency,
|
|
1631
|
-
batching: options?.batching
|
|
1632
|
-
|
|
1633
|
+
batching: options?.batching,
|
|
1634
|
+
concurrentFinalizers: options?.concurrentFinalizers
|
|
1635
|
+
}), ([es, bs]) => RA.isNonEmptyArray(es) ? core.fail(es) : options?.discard ? core.void : core.succeed(bs)));
|
|
1633
1636
|
/* @internal */
|
|
1634
1637
|
export const raceAll = all => {
|
|
1635
1638
|
const list = Chunk.fromIterable(all);
|
|
@@ -1752,11 +1755,11 @@ export const validateAllParDiscard = /*#__PURE__*/dual(2, (elements, f) => core.
|
|
|
1752
1755
|
/* @internal */
|
|
1753
1756
|
export const validateFirst = /*#__PURE__*/dual(args => Predicate.isIterable(args[0]), (elements, f, options) => core.flip(forEach(elements, (a, i) => core.flip(f(a, i)), options)));
|
|
1754
1757
|
/* @internal */
|
|
1755
|
-
export const withClockScoped =
|
|
1758
|
+
export const withClockScoped = c => fiberRefLocallyScopedWith(defaultServices.currentServices, Context.add(clock.clockTag, c));
|
|
1756
1759
|
/* @internal */
|
|
1757
1760
|
export const withRandomScoped = value => fiberRefLocallyScopedWith(defaultServices.currentServices, Context.add(randomTag, value));
|
|
1758
1761
|
/* @internal */
|
|
1759
|
-
export const withConfigProviderScoped =
|
|
1762
|
+
export const withConfigProviderScoped = provider => fiberRefLocallyScopedWith(defaultServices.currentServices, Context.add(configProviderTag, provider));
|
|
1760
1763
|
/* @internal */
|
|
1761
1764
|
export const withEarlyRelease = self => scopeWith(parent => core.flatMap(core.scopeFork(parent, executionStrategy.sequential), child => pipe(self, scopeExtend(child), core.map(value => [core.fiberIdWith(fiberId => core.scopeClose(child, core.exitInterrupt(fiberId))), value]))));
|
|
1762
1765
|
/** @internal */
|
|
@@ -1787,8 +1790,8 @@ export const withRuntimeFlagsScoped = update => {
|
|
|
1787
1790
|
return core.void;
|
|
1788
1791
|
}
|
|
1789
1792
|
return pipe(core.runtimeFlags, core.flatMap(runtimeFlags => {
|
|
1790
|
-
const updatedRuntimeFlags =
|
|
1791
|
-
const revertRuntimeFlags =
|
|
1793
|
+
const updatedRuntimeFlags = runtimeFlags_.patch(runtimeFlags, update);
|
|
1794
|
+
const revertRuntimeFlags = runtimeFlags_.diff(updatedRuntimeFlags, runtimeFlags);
|
|
1792
1795
|
return pipe(core.updateRuntimeFlags(update), core.zipRight(addFinalizer(() => core.updateRuntimeFlags(revertRuntimeFlags))), core.asVoid);
|
|
1793
1796
|
}), core.uninterruptible);
|
|
1794
1797
|
};
|
|
@@ -1892,7 +1895,7 @@ export const fiberRefMakeContext = initial => fiberRefMakeWith(() => core.fiberR
|
|
|
1892
1895
|
/* @internal */
|
|
1893
1896
|
export const fiberRefMakeRuntimeFlags = initial => fiberRefMakeWith(() => core.fiberRefUnsafeMakeRuntimeFlags(initial));
|
|
1894
1897
|
/** @internal */
|
|
1895
|
-
export const currentRuntimeFlags = /*#__PURE__*/core.fiberRefUnsafeMakeRuntimeFlags(
|
|
1898
|
+
export const currentRuntimeFlags = /*#__PURE__*/core.fiberRefUnsafeMakeRuntimeFlags(runtimeFlags_.none);
|
|
1896
1899
|
/** @internal */
|
|
1897
1900
|
export const currentSupervisor = /*#__PURE__*/fiberRefUnsafeMakeSupervisor(supervisor.none);
|
|
1898
1901
|
// circular with Fiber
|