effect 3.22.2 → 3.22.3
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/Effect.js.map +1 -1
- package/dist/cjs/LayerMap.js +3 -2
- package/dist/cjs/LayerMap.js.map +1 -1
- package/dist/cjs/internal/fiberRuntime.js +2 -0
- package/dist/cjs/internal/fiberRuntime.js.map +1 -1
- package/dist/cjs/internal/reloadable.js +1 -1
- package/dist/cjs/internal/reloadable.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/dts/Effect.d.ts +5 -0
- package/dist/dts/Effect.d.ts.map +1 -1
- package/dist/dts/LayerMap.d.ts +21 -1
- package/dist/dts/LayerMap.d.ts.map +1 -1
- package/dist/esm/Effect.js.map +1 -1
- package/dist/esm/LayerMap.js +3 -2
- package/dist/esm/LayerMap.js.map +1 -1
- package/dist/esm/internal/fiberRuntime.js +2 -0
- package/dist/esm/internal/fiberRuntime.js.map +1 -1
- package/dist/esm/internal/reloadable.js +1 -1
- package/dist/esm/internal/reloadable.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/package.json +1 -1
- package/src/Effect.ts +5 -0
- package/src/LayerMap.ts +27 -3
- package/src/internal/fiberRuntime.ts +2 -0
- package/src/internal/reloadable.ts +1 -0
- package/src/internal/version.ts +1 -1
package/src/LayerMap.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @experimental
|
|
4
4
|
*/
|
|
5
5
|
import * as Context from "./Context.js"
|
|
6
|
-
import
|
|
6
|
+
import * as Duration from "./Duration.js"
|
|
7
7
|
import * as Effect from "./Effect.js"
|
|
8
8
|
import * as FiberRefsPatch from "./FiberRefsPatch.js"
|
|
9
9
|
import { identity } from "./Function.js"
|
|
@@ -119,6 +119,11 @@ export const make: <
|
|
|
119
119
|
lookup: (key: K) => L,
|
|
120
120
|
options?: {
|
|
121
121
|
readonly idleTimeToLive?: Duration.DurationInput | undefined
|
|
122
|
+
/**
|
|
123
|
+
* Preloaded entries become idle immediately and follow the idle TTL.
|
|
124
|
+
* The default idle TTL is zero, so preloading only occurs when a nonzero
|
|
125
|
+
* `idleTimeToLive` is configured.
|
|
126
|
+
*/
|
|
122
127
|
readonly preloadKeys?: PreloadKeys
|
|
123
128
|
} | undefined
|
|
124
129
|
) => Effect.Effect<
|
|
@@ -177,9 +182,13 @@ export const make: <
|
|
|
177
182
|
idleTimeToLive: options?.idleTimeToLive
|
|
178
183
|
})
|
|
179
184
|
|
|
180
|
-
if (
|
|
185
|
+
if (
|
|
186
|
+
options?.preloadKeys &&
|
|
187
|
+
options.idleTimeToLive !== undefined &&
|
|
188
|
+
!Duration.isZero(Duration.decode(options.idleTimeToLive))
|
|
189
|
+
) {
|
|
181
190
|
for (const key of options.preloadKeys) {
|
|
182
|
-
yield* (RcMap.get(rcMap, key) as Effect.Effect<any, EL, RL | Scope.Scope>)
|
|
191
|
+
yield* Effect.scoped(RcMap.get(rcMap, key) as Effect.Effect<any, EL, RL | Scope.Scope>)
|
|
183
192
|
}
|
|
184
193
|
}
|
|
185
194
|
|
|
@@ -204,6 +213,11 @@ export const fromRecord = <
|
|
|
204
213
|
layers: Layers,
|
|
205
214
|
options?: {
|
|
206
215
|
readonly idleTimeToLive?: Duration.DurationInput | undefined
|
|
216
|
+
/**
|
|
217
|
+
* Preloaded entries become idle immediately and follow the idle TTL.
|
|
218
|
+
* The default idle TTL is zero, so preloading only occurs when a nonzero
|
|
219
|
+
* `idleTimeToLive` is configured.
|
|
220
|
+
*/
|
|
207
221
|
readonly preload?: Preload | undefined
|
|
208
222
|
} | undefined
|
|
209
223
|
): Effect.Effect<
|
|
@@ -327,6 +341,11 @@ export const Service = <Self>() =>
|
|
|
327
341
|
readonly lookup: (key: any) => Layer.Layer<any, any, any>
|
|
328
342
|
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>>
|
|
329
343
|
readonly idleTimeToLive?: Duration.DurationInput | undefined
|
|
344
|
+
/**
|
|
345
|
+
* Preloaded entries become idle immediately and follow the idle TTL.
|
|
346
|
+
* The default idle TTL is zero, so preloading only occurs when a nonzero
|
|
347
|
+
* `idleTimeToLive` is configured.
|
|
348
|
+
*/
|
|
330
349
|
readonly preloadKeys?:
|
|
331
350
|
| Iterable<Options extends { readonly lookup: (key: infer K) => any } ? K : never>
|
|
332
351
|
| undefined
|
|
@@ -337,6 +356,11 @@ export const Service = <Self>() =>
|
|
|
337
356
|
readonly layers: Record<string, Layer.Layer<any, any, any>>
|
|
338
357
|
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>>
|
|
339
358
|
readonly idleTimeToLive?: Duration.DurationInput | undefined
|
|
359
|
+
/**
|
|
360
|
+
* Preloaded entries become idle immediately and follow the idle TTL.
|
|
361
|
+
* The default idle TTL is zero, so preloading only occurs when a nonzero
|
|
362
|
+
* `idleTimeToLive` is configured.
|
|
363
|
+
*/
|
|
340
364
|
readonly preload?: boolean
|
|
341
365
|
}, Options>
|
|
342
366
|
>(
|
|
@@ -1719,12 +1719,14 @@ export const addFinalizer = <X, R>(
|
|
|
1719
1719
|
core.withFiberRuntime((runtimeFinalizer) => {
|
|
1720
1720
|
const preRefs = runtimeFinalizer.getFiberRefs()
|
|
1721
1721
|
const preFlags = runtimeFinalizer.currentRuntimeFlags
|
|
1722
|
+
const interruptedCause = runtimeFinalizer.getFiberRef(core.currentInterruptedCause)
|
|
1722
1723
|
const patchRefs = FiberRefsPatch.diff(preRefs, acquireRefs)
|
|
1723
1724
|
const patchFlags = runtimeFlags_.diff(preFlags, acquireFlags)
|
|
1724
1725
|
const inverseRefs = FiberRefsPatch.diff(acquireRefs, preRefs)
|
|
1725
1726
|
runtimeFinalizer.setFiberRefs(
|
|
1726
1727
|
FiberRefsPatch.patch(patchRefs, runtimeFinalizer.id(), acquireRefs)
|
|
1727
1728
|
)
|
|
1729
|
+
runtimeFinalizer.setFiberRef(core.currentInterruptedCause, interruptedCause)
|
|
1728
1730
|
|
|
1729
1731
|
return ensuring(
|
|
1730
1732
|
core.withRuntimeFlags(finalizer(exit) as Effect.Effect<X>, patchFlags),
|
package/src/internal/version.ts
CHANGED