effect 3.4.4 → 3.4.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/dist/cjs/Match.js.map +1 -1
- package/dist/cjs/Micro.js +481 -425
- package/dist/cjs/Micro.js.map +1 -1
- package/dist/cjs/internal/channel.js +5 -2
- package/dist/cjs/internal/channel.js.map +1 -1
- package/dist/cjs/internal/core-effect.js +14 -11
- package/dist/cjs/internal/core-effect.js.map +1 -1
- package/dist/cjs/internal/fiberRuntime.js +4 -9
- package/dist/cjs/internal/fiberRuntime.js.map +1 -1
- package/dist/cjs/internal/matcher.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/dts/Match.d.ts +16 -16
- package/dist/dts/Match.d.ts.map +1 -1
- package/dist/dts/Micro.d.ts +344 -260
- package/dist/dts/Micro.d.ts.map +1 -1
- package/dist/dts/internal/core-effect.d.ts.map +1 -1
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Micro.js +456 -402
- package/dist/esm/Micro.js.map +1 -1
- package/dist/esm/internal/channel.js +5 -2
- package/dist/esm/internal/channel.js.map +1 -1
- package/dist/esm/internal/core-effect.js +11 -9
- package/dist/esm/internal/core-effect.js.map +1 -1
- package/dist/esm/internal/fiberRuntime.js +4 -9
- package/dist/esm/internal/fiberRuntime.js.map +1 -1
- package/dist/esm/internal/matcher.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/package.json +1 -1
- package/src/Match.ts +20 -20
- package/src/Micro.ts +715 -603
- package/src/internal/channel.ts +17 -19
- package/src/internal/core-effect.ts +14 -10
- package/src/internal/fiberRuntime.ts +4 -10
- package/src/internal/matcher.ts +20 -19
- package/src/internal/version.ts +1 -1
package/src/internal/channel.ts
CHANGED
|
@@ -8,6 +8,7 @@ import * as Either from "../Either.js"
|
|
|
8
8
|
import * as Equal from "../Equal.js"
|
|
9
9
|
import * as Exit from "../Exit.js"
|
|
10
10
|
import * as Fiber from "../Fiber.js"
|
|
11
|
+
import * as FiberRef from "../FiberRef.js"
|
|
11
12
|
import { constVoid, dual, identity, pipe } from "../Function.js"
|
|
12
13
|
import type { LazyArg } from "../Function.js"
|
|
13
14
|
import * as Layer from "../Layer.js"
|
|
@@ -28,6 +29,7 @@ import * as mergeDecision from "./channel/mergeDecision.js"
|
|
|
28
29
|
import * as mergeState from "./channel/mergeState.js"
|
|
29
30
|
import * as _mergeStrategy from "./channel/mergeStrategy.js"
|
|
30
31
|
import * as singleProducerAsyncInput from "./channel/singleProducerAsyncInput.js"
|
|
32
|
+
import * as coreEffect from "./core-effect.js"
|
|
31
33
|
import * as core from "./core-stream.js"
|
|
32
34
|
import * as MergeDecisionOpCodes from "./opCodes/channelMergeDecision.js"
|
|
33
35
|
import * as MergeStateOpCodes from "./opCodes/channelMergeState.js"
|
|
@@ -2326,29 +2328,25 @@ export const withSpan: {
|
|
|
2326
2328
|
const dataFirst = typeof arguments[0] !== "string"
|
|
2327
2329
|
const name = dataFirst ? arguments[1] : arguments[0]
|
|
2328
2330
|
const options = tracer.addSpanStackTrace(dataFirst ? arguments[2] : arguments[1])
|
|
2331
|
+
const acquire = Effect.all([
|
|
2332
|
+
Effect.makeSpan(name, options),
|
|
2333
|
+
Effect.context(),
|
|
2334
|
+
Effect.clock,
|
|
2335
|
+
FiberRef.get(FiberRef.currentTracerTimingEnabled)
|
|
2336
|
+
])
|
|
2329
2337
|
if (dataFirst) {
|
|
2330
2338
|
const self = arguments[0]
|
|
2331
|
-
return
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
Effect.map(
|
|
2336
|
-
Effect.makeSpanScoped(name, options),
|
|
2337
|
-
(span) => core.provideContext(self, Context.add(context, tracer.spanTag, span))
|
|
2338
|
-
)
|
|
2339
|
-
)
|
|
2339
|
+
return acquireUseRelease(
|
|
2340
|
+
acquire,
|
|
2341
|
+
([span, context]) => core.provideContext(self, Context.add(context, tracer.spanTag, span)),
|
|
2342
|
+
([span, , clock, timingEnabled], exit) => coreEffect.endSpan(span, exit, clock, timingEnabled)
|
|
2340
2343
|
)
|
|
2341
2344
|
}
|
|
2342
|
-
return (self:
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
Effect.map(
|
|
2348
|
-
Effect.makeSpanScoped(name, options),
|
|
2349
|
-
(span) => core.provideContext(self, Context.add(context, tracer.spanTag, span))
|
|
2350
|
-
)
|
|
2351
|
-
)
|
|
2345
|
+
return (self: Channel.Channel<any>) =>
|
|
2346
|
+
acquireUseRelease(
|
|
2347
|
+
acquire,
|
|
2348
|
+
([span, context]) => core.provideContext(self, Context.add(context, tracer.spanTag, span)),
|
|
2349
|
+
([span, , clock, timingEnabled], exit) => coreEffect.endSpan(span, exit, clock, timingEnabled)
|
|
2352
2350
|
)
|
|
2353
2351
|
} as any
|
|
2354
2352
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Exit } from "effect/Exit"
|
|
1
2
|
import { internalCall } from "effect/Utils"
|
|
2
3
|
import * as Arr from "../Array.js"
|
|
3
4
|
import type * as Cause from "../Cause.js"
|
|
@@ -2122,6 +2123,18 @@ export const spanAnnotations: Effect.Effect<HashMap.HashMap<string, unknown>> =
|
|
|
2122
2123
|
export const spanLinks: Effect.Effect<Chunk.Chunk<Tracer.SpanLink>> = core
|
|
2123
2124
|
.fiberRefGet(core.currentTracerSpanLinks)
|
|
2124
2125
|
|
|
2126
|
+
/** @internal */
|
|
2127
|
+
export const endSpan = <A, E>(span: Tracer.Span, exit: Exit<A, E>, clock: Clock.Clock, timingEnabled: boolean) =>
|
|
2128
|
+
core.sync(() => {
|
|
2129
|
+
if (span.status._tag === "Ended") {
|
|
2130
|
+
return
|
|
2131
|
+
}
|
|
2132
|
+
if (core.exitIsFailure(exit) && internalCause.spanToTrace.has(span)) {
|
|
2133
|
+
span.attribute("code.stacktrace", internalCause.spanToTrace.get(span)!())
|
|
2134
|
+
}
|
|
2135
|
+
span.end(timingEnabled ? clock.unsafeCurrentTimeNanos() : bigint0, exit)
|
|
2136
|
+
})
|
|
2137
|
+
|
|
2125
2138
|
/** @internal */
|
|
2126
2139
|
export const useSpan: {
|
|
2127
2140
|
<A, E, R>(name: string, evaluate: (span: Tracer.Span) => Effect.Effect<A, E, R>): Effect.Effect<A, E, R>
|
|
@@ -2144,16 +2157,7 @@ export const useSpan: {
|
|
|
2144
2157
|
const span = unsafeMakeSpan(fiber, name, options)
|
|
2145
2158
|
const timingEnabled = fiber.getFiberRef(core.currentTracerTimingEnabled)
|
|
2146
2159
|
const clock = Context.get(fiber.getFiberRef(defaultServices.currentServices), clockTag)
|
|
2147
|
-
return core.onExit(evaluate(span), (exit) =>
|
|
2148
|
-
core.sync(() => {
|
|
2149
|
-
if (span.status._tag === "Ended") {
|
|
2150
|
-
return
|
|
2151
|
-
}
|
|
2152
|
-
if (core.exitIsFailure(exit) && internalCause.spanToTrace.has(span)) {
|
|
2153
|
-
span.attribute("code.stacktrace", internalCause.spanToTrace.get(span)!())
|
|
2154
|
-
}
|
|
2155
|
-
span.end(timingEnabled ? clock.unsafeCurrentTimeNanos() : bigint0, exit)
|
|
2156
|
-
}))
|
|
2160
|
+
return core.onExit(evaluate(span), (exit) => endSpan(span, exit, clock, timingEnabled))
|
|
2157
2161
|
})
|
|
2158
2162
|
}
|
|
2159
2163
|
|
|
@@ -1085,13 +1085,13 @@ export class FiberRuntime<in out A, in out E = never> implements Fiber.RuntimeFi
|
|
|
1085
1085
|
return resume(core.exitSucceed(result.right))
|
|
1086
1086
|
}
|
|
1087
1087
|
switch (result.left._tag) {
|
|
1088
|
-
case "
|
|
1088
|
+
case "Interrupt": {
|
|
1089
1089
|
return resume(core.exitFailCause(internalCause.interrupt(FiberId.none)))
|
|
1090
1090
|
}
|
|
1091
|
-
case "
|
|
1091
|
+
case "Fail": {
|
|
1092
1092
|
return resume(core.fail(result.left.error))
|
|
1093
1093
|
}
|
|
1094
|
-
case "
|
|
1094
|
+
case "Die": {
|
|
1095
1095
|
return resume(core.die(result.left.defect))
|
|
1096
1096
|
}
|
|
1097
1097
|
}
|
|
@@ -3666,13 +3666,7 @@ export const makeSpanScoped = (
|
|
|
3666
3666
|
const timingEnabled = fiber.getFiberRef(core.currentTracerTimingEnabled)
|
|
3667
3667
|
const clock_ = Context.get(fiber.getFiberRef(defaultServices.currentServices), clock.clockTag)
|
|
3668
3668
|
return core.as(
|
|
3669
|
-
core.scopeAddFinalizerExit(scope, (exit) =>
|
|
3670
|
-
core.sync(() => {
|
|
3671
|
-
if (span.status._tag === "Ended") {
|
|
3672
|
-
return
|
|
3673
|
-
}
|
|
3674
|
-
span.end(timingEnabled ? clock_.unsafeCurrentTimeNanos() : BigInt(0), exit)
|
|
3675
|
-
})),
|
|
3669
|
+
core.scopeAddFinalizerExit(scope, (exit) => internalEffect.endSpan(span, exit, clock_, timingEnabled)),
|
|
3676
3670
|
span
|
|
3677
3671
|
)
|
|
3678
3672
|
})
|
package/src/internal/matcher.ts
CHANGED
|
@@ -239,11 +239,11 @@ export const typeTags = <I>() =>
|
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
/** @internal */
|
|
242
|
-
export const withReturnType =
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
242
|
+
export const withReturnType = <Ret>() =>
|
|
243
|
+
<I, F, R, A, Pr, _>(self: Matcher<I, F, R, A, Pr, _>): [Ret] extends [
|
|
244
|
+
[A] extends [never] ? any : A
|
|
245
|
+
] ? Matcher<I, F, R, A, Pr, Ret>
|
|
246
|
+
: "withReturnType constraint does not extend Result type" => self as any
|
|
247
247
|
|
|
248
248
|
/** @internal */
|
|
249
249
|
export const when = <
|
|
@@ -512,23 +512,24 @@ export const instanceOfUnsafe: <A extends abstract new(...args: any) => any>(
|
|
|
512
512
|
) => SafeRefinement<InstanceType<A>, InstanceType<A>> = instanceOf
|
|
513
513
|
|
|
514
514
|
/** @internal */
|
|
515
|
-
export const orElse =
|
|
516
|
-
<
|
|
517
|
-
self: Matcher<I, R, RA, A, Pr, Ret>
|
|
518
|
-
|
|
519
|
-
|
|
515
|
+
export const orElse =
|
|
516
|
+
<RA, Ret, F extends (_: RA) => Ret>(f: F) =>
|
|
517
|
+
<I, R, A, Pr>(self: Matcher<I, R, RA, A, Pr, Ret>): [Pr] extends [never] ? (input: I) => Unify<ReturnType<F> | A>
|
|
518
|
+
: Unify<ReturnType<F> | A> =>
|
|
519
|
+
{
|
|
520
|
+
const result = either(self)
|
|
521
|
+
|
|
522
|
+
if (Either.isEither(result)) {
|
|
523
|
+
// @ts-expect-error
|
|
524
|
+
return result._tag === "Right" ? result.right : f(result.left)
|
|
525
|
+
}
|
|
520
526
|
|
|
521
|
-
if (Either.isEither(result)) {
|
|
522
527
|
// @ts-expect-error
|
|
523
|
-
return
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
return (input: I) => {
|
|
528
|
-
const a = result(input)
|
|
529
|
-
return a._tag === "Right" ? a.right : f(a.left)
|
|
528
|
+
return (input: I) => {
|
|
529
|
+
const a = result(input)
|
|
530
|
+
return a._tag === "Right" ? a.right : f(a.left)
|
|
531
|
+
}
|
|
530
532
|
}
|
|
531
|
-
}
|
|
532
533
|
|
|
533
534
|
/** @internal */
|
|
534
535
|
export const orElseAbsurd = <I, R, RA, A, Pr, Ret>(
|
package/src/internal/version.ts
CHANGED