effect 4.0.0-beta.102 → 4.0.0-beta.103
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/Array.d.ts +971 -1037
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +381 -407
- package/dist/Array.js.map +1 -1
- package/dist/BigDecimal.d.ts +433 -756
- package/dist/BigDecimal.d.ts.map +1 -1
- package/dist/BigDecimal.js +200 -325
- package/dist/BigDecimal.js.map +1 -1
- package/dist/BigInt.d.ts +207 -267
- package/dist/BigInt.d.ts.map +1 -1
- package/dist/BigInt.js +107 -135
- package/dist/BigInt.js.map +1 -1
- package/dist/Boolean.d.ts +146 -188
- package/dist/Boolean.d.ts.map +1 -1
- package/dist/Boolean.js +64 -84
- package/dist/Boolean.js.map +1 -1
- package/dist/Brand.js.map +1 -1
- package/dist/Cache.d.ts +405 -254
- package/dist/Cache.d.ts.map +1 -1
- package/dist/Cache.js +166 -101
- package/dist/Cache.js.map +1 -1
- package/dist/Cause.d.ts +167 -277
- package/dist/Cause.d.ts.map +1 -1
- package/dist/Cause.js +122 -176
- package/dist/Cause.js.map +1 -1
- package/dist/Channel.d.ts +729 -768
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +514 -440
- package/dist/Channel.js.map +1 -1
- package/dist/ChannelSchema.d.ts +1 -1
- package/dist/ChannelSchema.d.ts.map +1 -1
- package/dist/ChannelSchema.js.map +1 -1
- package/dist/Chunk.d.ts +834 -1173
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +326 -439
- package/dist/Chunk.js.map +1 -1
- package/dist/Clock.d.ts +180 -49
- package/dist/Clock.d.ts.map +1 -1
- package/dist/Clock.js +96 -31
- package/dist/Clock.js.map +1 -1
- package/dist/Combiner.d.ts +20 -33
- package/dist/Combiner.d.ts.map +1 -1
- package/dist/Combiner.js +18 -30
- package/dist/Combiner.js.map +1 -1
- package/dist/Config.d.ts +225 -173
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +336 -265
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts +194 -68
- package/dist/ConfigProvider.d.ts.map +1 -1
- package/dist/ConfigProvider.js +115 -80
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Console.d.ts +233 -33
- package/dist/Console.d.ts.map +1 -1
- package/dist/Console.js +232 -32
- package/dist/Console.js.map +1 -1
- package/dist/Context.d.ts +151 -274
- package/dist/Context.d.ts.map +1 -1
- package/dist/Context.js +171 -214
- package/dist/Context.js.map +1 -1
- package/dist/Cron.d.ts +68 -77
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +57 -66
- package/dist/Cron.js.map +1 -1
- package/dist/Crypto.d.ts +13 -15
- package/dist/Crypto.d.ts.map +1 -1
- package/dist/Crypto.js +9 -10
- package/dist/Crypto.js.map +1 -1
- package/dist/Data.d.ts +60 -80
- package/dist/Data.d.ts.map +1 -1
- package/dist/Data.js +16 -23
- package/dist/Data.js.map +1 -1
- package/dist/DateTime.d.ts +562 -660
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/DateTime.js +307 -362
- package/dist/DateTime.js.map +1 -1
- package/dist/Deferred.d.ts +253 -256
- package/dist/Deferred.d.ts.map +1 -1
- package/dist/Deferred.js +104 -96
- package/dist/Deferred.js.map +1 -1
- package/dist/Duration.d.ts +216 -308
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +132 -186
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +2841 -3247
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +1322 -1546
- package/dist/Effect.js.map +1 -1
- package/dist/Effectable.js.map +1 -1
- package/dist/Encoding.d.ts +22 -40
- package/dist/Encoding.d.ts.map +1 -1
- package/dist/Encoding.js +22 -40
- package/dist/Encoding.js.map +1 -1
- package/dist/Equal.d.ts +33 -37
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equal.js +29 -21
- package/dist/Equal.js.map +1 -1
- package/dist/Equivalence.d.ts +103 -105
- package/dist/Equivalence.d.ts.map +1 -1
- package/dist/Equivalence.js +77 -79
- package/dist/Equivalence.js.map +1 -1
- package/dist/ErrorReporter.d.ts +51 -27
- package/dist/ErrorReporter.d.ts.map +1 -1
- package/dist/ErrorReporter.js +50 -26
- package/dist/ErrorReporter.js.map +1 -1
- package/dist/ExecutionPlan.d.ts +13 -55
- package/dist/ExecutionPlan.d.ts.map +1 -1
- package/dist/ExecutionPlan.js +7 -28
- package/dist/ExecutionPlan.js.map +1 -1
- package/dist/Exit.d.ts +116 -192
- package/dist/Exit.d.ts.map +1 -1
- package/dist/Exit.js +82 -130
- package/dist/Exit.js.map +1 -1
- package/dist/Fiber.d.ts +82 -146
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.js +48 -87
- package/dist/Fiber.js.map +1 -1
- package/dist/FiberHandle.d.ts +152 -105
- package/dist/FiberHandle.d.ts.map +1 -1
- package/dist/FiberHandle.js +106 -73
- package/dist/FiberHandle.js.map +1 -1
- package/dist/FiberMap.d.ts +213 -168
- package/dist/FiberMap.d.ts.map +1 -1
- package/dist/FiberMap.js +114 -89
- package/dist/FiberMap.js.map +1 -1
- package/dist/FiberSet.d.ts +123 -81
- package/dist/FiberSet.d.ts.map +1 -1
- package/dist/FiberSet.js +85 -59
- package/dist/FiberSet.js.map +1 -1
- package/dist/FileSystem.d.ts +153 -264
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +42 -147
- package/dist/FileSystem.js.map +1 -1
- package/dist/Filter.d.ts +61 -33
- package/dist/Filter.d.ts.map +1 -1
- package/dist/Filter.js +26 -15
- package/dist/Filter.js.map +1 -1
- package/dist/Formatter.d.ts +25 -33
- package/dist/Formatter.d.ts.map +1 -1
- package/dist/Formatter.js +48 -49
- package/dist/Formatter.js.map +1 -1
- package/dist/Function.d.ts +76 -145
- package/dist/Function.d.ts.map +1 -1
- package/dist/Function.js +40 -57
- package/dist/Function.js.map +1 -1
- package/dist/Graph.d.ts +360 -714
- package/dist/Graph.d.ts.map +1 -1
- package/dist/Graph.js +168 -297
- package/dist/Graph.js.map +1 -1
- package/dist/HKT.d.ts +12 -6
- package/dist/HKT.d.ts.map +1 -1
- package/dist/Hash.d.ts +47 -83
- package/dist/Hash.d.ts.map +1 -1
- package/dist/Hash.js +46 -68
- package/dist/Hash.js.map +1 -1
- package/dist/HashMap.d.ts +319 -411
- package/dist/HashMap.d.ts.map +1 -1
- package/dist/HashMap.js +122 -166
- package/dist/HashMap.js.map +1 -1
- package/dist/HashRing.d.ts.map +1 -1
- package/dist/HashRing.js +1 -0
- package/dist/HashRing.js.map +1 -1
- package/dist/HashSet.d.ts +177 -284
- package/dist/HashSet.d.ts.map +1 -1
- package/dist/HashSet.js +68 -109
- package/dist/HashSet.js.map +1 -1
- package/dist/Inspectable.d.ts +12 -12
- package/dist/Inspectable.js +8 -8
- package/dist/Inspectable.js.map +1 -1
- package/dist/Iterable.d.ts +620 -786
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +228 -306
- package/dist/Iterable.js.map +1 -1
- package/dist/JsonPatch.d.ts +11 -13
- package/dist/JsonPatch.d.ts.map +1 -1
- package/dist/JsonPatch.js +44 -102
- package/dist/JsonPatch.js.map +1 -1
- package/dist/JsonPointer.d.ts +8 -8
- package/dist/JsonPointer.js +8 -8
- package/dist/JsonPointer.js.map +1 -1
- package/dist/JsonSchema.d.ts +98 -44
- package/dist/JsonSchema.d.ts.map +1 -1
- package/dist/JsonSchema.js +297 -234
- package/dist/JsonSchema.js.map +1 -1
- package/dist/Latch.d.ts +23 -35
- package/dist/Latch.d.ts.map +1 -1
- package/dist/Latch.js +16 -28
- package/dist/Latch.js.map +1 -1
- package/dist/Layer.d.ts +359 -260
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +195 -175
- package/dist/Layer.js.map +1 -1
- package/dist/LayerMap.d.ts +42 -29
- package/dist/LayerMap.d.ts.map +1 -1
- package/dist/LayerMap.js +31 -21
- package/dist/LayerMap.js.map +1 -1
- package/dist/LayerRef.d.ts +6 -2
- package/dist/LayerRef.d.ts.map +1 -1
- package/dist/LayerRef.js +6 -2
- package/dist/LayerRef.js.map +1 -1
- package/dist/LogLevel.d.ts +114 -214
- package/dist/LogLevel.d.ts.map +1 -1
- package/dist/LogLevel.js +41 -76
- package/dist/LogLevel.js.map +1 -1
- package/dist/Logger.d.ts +218 -467
- package/dist/Logger.d.ts.map +1 -1
- package/dist/Logger.js +204 -450
- package/dist/Logger.js.map +1 -1
- package/dist/ManagedRuntime.d.ts +7 -5
- package/dist/ManagedRuntime.d.ts.map +1 -1
- package/dist/ManagedRuntime.js +7 -5
- package/dist/ManagedRuntime.js.map +1 -1
- package/dist/Match.d.ts +217 -252
- package/dist/Match.d.ts.map +1 -1
- package/dist/Match.js +150 -183
- package/dist/Match.js.map +1 -1
- package/dist/Metric.d.ts +442 -993
- package/dist/Metric.d.ts.map +1 -1
- package/dist/Metric.js +198 -642
- package/dist/Metric.js.map +1 -1
- package/dist/MutableHashMap.d.ts +144 -173
- package/dist/MutableHashMap.d.ts.map +1 -1
- package/dist/MutableHashMap.js +68 -79
- package/dist/MutableHashMap.js.map +1 -1
- package/dist/MutableHashSet.d.ts +84 -89
- package/dist/MutableHashSet.d.ts.map +1 -1
- package/dist/MutableHashSet.js +44 -47
- package/dist/MutableHashSet.js.map +1 -1
- package/dist/MutableList.d.ts +71 -370
- package/dist/MutableList.d.ts.map +1 -1
- package/dist/MutableList.js +59 -284
- package/dist/MutableList.js.map +1 -1
- package/dist/MutableRef.d.ts +420 -243
- package/dist/MutableRef.d.ts.map +1 -1
- package/dist/MutableRef.js +209 -120
- package/dist/MutableRef.js.map +1 -1
- package/dist/Newtype.d.ts +21 -14
- package/dist/Newtype.d.ts.map +1 -1
- package/dist/Newtype.js +15 -13
- package/dist/Newtype.js.map +1 -1
- package/dist/NonEmptyIterable.d.ts +7 -137
- package/dist/NonEmptyIterable.d.ts.map +1 -1
- package/dist/NonEmptyIterable.js +5 -93
- package/dist/NonEmptyIterable.js.map +1 -1
- package/dist/Number.d.ts +196 -233
- package/dist/Number.d.ts.map +1 -1
- package/dist/Number.js +90 -109
- package/dist/Number.js.map +1 -1
- package/dist/Optic.d.ts +97 -189
- package/dist/Optic.d.ts.map +1 -1
- package/dist/Optic.js +187 -290
- package/dist/Optic.js.map +1 -1
- package/dist/Option.d.ts +447 -812
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js +211 -392
- package/dist/Option.js.map +1 -1
- package/dist/Order.d.ts +109 -109
- package/dist/Order.js +91 -91
- package/dist/Order.js.map +1 -1
- package/dist/Ordering.d.ts +20 -23
- package/dist/Ordering.d.ts.map +1 -1
- package/dist/Ordering.js +8 -9
- package/dist/Ordering.js.map +1 -1
- package/dist/PartitionedSemaphore.js.map +1 -1
- package/dist/Path.d.ts +38 -41
- package/dist/Path.d.ts.map +1 -1
- package/dist/Path.js +3 -4
- package/dist/Path.js.map +1 -1
- package/dist/Pipeable.d.ts +6 -5
- package/dist/Pipeable.d.ts.map +1 -1
- package/dist/Pipeable.js +2 -2
- package/dist/Pipeable.js.map +1 -1
- package/dist/PlatformError.d.ts +4 -4
- package/dist/PlatformError.js +3 -3
- package/dist/PlatformError.js.map +1 -1
- package/dist/Pool.d.ts +4 -2
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +4 -2
- package/dist/Pool.js.map +1 -1
- package/dist/Predicate.d.ts +200 -181
- package/dist/Predicate.d.ts.map +1 -1
- package/dist/Predicate.js +100 -108
- package/dist/Predicate.js.map +1 -1
- package/dist/PrimaryKey.d.ts +7 -7
- package/dist/PrimaryKey.js +5 -5
- package/dist/PrimaryKey.js.map +1 -1
- package/dist/PubSub.d.ts +425 -494
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +373 -362
- package/dist/PubSub.js.map +1 -1
- package/dist/Pull.d.ts +24 -18
- package/dist/Pull.d.ts.map +1 -1
- package/dist/Pull.js +11 -9
- package/dist/Pull.js.map +1 -1
- package/dist/Queue.d.ts +200 -159
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +162 -132
- package/dist/Queue.js.map +1 -1
- package/dist/Random.d.ts +49 -74
- package/dist/Random.d.ts.map +1 -1
- package/dist/Random.js +35 -54
- package/dist/Random.js.map +1 -1
- package/dist/RcMap.d.ts +121 -63
- package/dist/RcMap.d.ts.map +1 -1
- package/dist/RcMap.js +42 -21
- package/dist/RcMap.js.map +1 -1
- package/dist/RcRef.d.ts +24 -13
- package/dist/RcRef.d.ts.map +1 -1
- package/dist/RcRef.js +15 -9
- package/dist/RcRef.js.map +1 -1
- package/dist/Record.d.ts +291 -488
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js +111 -202
- package/dist/Record.js.map +1 -1
- package/dist/Redactable.d.ts +6 -2
- package/dist/Redactable.d.ts.map +1 -1
- package/dist/Redactable.js +7 -2
- package/dist/Redactable.js.map +1 -1
- package/dist/Redacted.d.ts +25 -25
- package/dist/Redacted.d.ts.map +1 -1
- package/dist/Redacted.js +19 -20
- package/dist/Redacted.js.map +1 -1
- package/dist/Reducer.d.ts +8 -15
- package/dist/Reducer.d.ts.map +1 -1
- package/dist/Reducer.js +6 -12
- package/dist/Reducer.js.map +1 -1
- package/dist/Ref.d.ts +95 -165
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js +75 -122
- package/dist/Ref.js.map +1 -1
- package/dist/References.d.ts +102 -168
- package/dist/References.d.ts.map +1 -1
- package/dist/References.js +102 -168
- package/dist/References.js.map +1 -1
- package/dist/RegExp.d.ts +10 -14
- package/dist/RegExp.d.ts.map +1 -1
- package/dist/RegExp.js +10 -14
- package/dist/RegExp.js.map +1 -1
- package/dist/Request.d.ts +31 -21
- package/dist/Request.d.ts.map +1 -1
- package/dist/Request.js +16 -13
- package/dist/Request.js.map +1 -1
- package/dist/RequestResolver.d.ts +201 -90
- package/dist/RequestResolver.d.ts.map +1 -1
- package/dist/RequestResolver.js +87 -41
- package/dist/RequestResolver.js.map +1 -1
- package/dist/Resource.js.map +1 -1
- package/dist/Result.d.ts +302 -470
- package/dist/Result.d.ts.map +1 -1
- package/dist/Result.js +133 -217
- package/dist/Result.js.map +1 -1
- package/dist/Runtime.d.ts +50 -75
- package/dist/Runtime.d.ts.map +1 -1
- package/dist/Runtime.js +39 -60
- package/dist/Runtime.js.map +1 -1
- package/dist/Schedule.d.ts +290 -1636
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +162 -803
- package/dist/Schedule.js.map +1 -1
- package/dist/Scheduler.d.ts +5 -5
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +18 -6
- package/dist/Scheduler.js.map +1 -1
- package/dist/Schema.d.ts +644 -642
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +491 -527
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +27 -50
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +366 -279
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaError.d.ts +7 -6
- package/dist/SchemaError.d.ts.map +1 -1
- package/dist/SchemaError.js +7 -6
- package/dist/SchemaError.js.map +1 -1
- package/dist/SchemaGetter.d.ts +217 -174
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +218 -185
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaIssue.d.ts +62 -190
- package/dist/SchemaIssue.d.ts.map +1 -1
- package/dist/SchemaIssue.js +73 -265
- package/dist/SchemaIssue.js.map +1 -1
- package/dist/SchemaParser.d.ts +2 -2
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +123 -75
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +22 -36
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +20 -26
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +114 -74
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +120 -85
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/Scope.d.ts +123 -151
- package/dist/Scope.d.ts.map +1 -1
- package/dist/Scope.js +72 -92
- package/dist/Scope.js.map +1 -1
- package/dist/ScopedCache.js.map +1 -1
- package/dist/ScopedRef.d.ts +3 -3
- package/dist/ScopedRef.js +2 -2
- package/dist/ScopedRef.js.map +1 -1
- package/dist/Semaphore.d.ts +96 -10
- package/dist/Semaphore.d.ts.map +1 -1
- package/dist/Semaphore.js +78 -39
- package/dist/Semaphore.js.map +1 -1
- package/dist/Sink.d.ts +117 -107
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js +107 -100
- package/dist/Sink.js.map +1 -1
- package/dist/Stdio.d.ts +1 -1
- package/dist/Stdio.js.map +1 -1
- package/dist/Stream.d.ts +2415 -2949
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +1078 -1381
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +262 -308
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +184 -215
- package/dist/String.js.map +1 -1
- package/dist/Struct.d.ts +109 -114
- package/dist/Struct.d.ts.map +1 -1
- package/dist/Struct.js +41 -50
- package/dist/Struct.js.map +1 -1
- package/dist/SubscriptionRef.d.ts +282 -250
- package/dist/SubscriptionRef.d.ts.map +1 -1
- package/dist/SubscriptionRef.js +104 -92
- package/dist/SubscriptionRef.js.map +1 -1
- package/dist/Symbol.d.ts +3 -3
- package/dist/Symbol.js +3 -3
- package/dist/Symbol.js.map +1 -1
- package/dist/SynchronizedRef.js.map +1 -1
- package/dist/Take.js.map +1 -1
- package/dist/Terminal.d.ts +2 -2
- package/dist/Terminal.js +1 -1
- package/dist/Terminal.js.map +1 -1
- package/dist/Tracer.d.ts +100 -54
- package/dist/Tracer.d.ts.map +1 -1
- package/dist/Tracer.js +41 -24
- package/dist/Tracer.js.map +1 -1
- package/dist/Trie.d.ts +287 -679
- package/dist/Trie.d.ts.map +1 -1
- package/dist/Trie.js +109 -251
- package/dist/Trie.js.map +1 -1
- package/dist/Tuple.d.ts +92 -127
- package/dist/Tuple.d.ts.map +1 -1
- package/dist/Tuple.js +42 -57
- package/dist/Tuple.js.map +1 -1
- package/dist/TxChunk.d.ts +201 -121
- package/dist/TxChunk.d.ts.map +1 -1
- package/dist/TxChunk.js +85 -56
- package/dist/TxChunk.js.map +1 -1
- package/dist/TxDeferred.d.ts +62 -46
- package/dist/TxDeferred.d.ts.map +1 -1
- package/dist/TxDeferred.js +30 -22
- package/dist/TxDeferred.js.map +1 -1
- package/dist/TxHashMap.d.ts +631 -779
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js +268 -330
- package/dist/TxHashMap.js.map +1 -1
- package/dist/TxHashSet.d.ts +297 -236
- package/dist/TxHashSet.d.ts.map +1 -1
- package/dist/TxHashSet.js +130 -100
- package/dist/TxHashSet.js.map +1 -1
- package/dist/TxPriorityQueue.d.ts +126 -95
- package/dist/TxPriorityQueue.d.ts.map +1 -1
- package/dist/TxPriorityQueue.js +74 -56
- package/dist/TxPriorityQueue.js.map +1 -1
- package/dist/TxPubSub.d.ts +101 -88
- package/dist/TxPubSub.d.ts.map +1 -1
- package/dist/TxPubSub.js +87 -66
- package/dist/TxPubSub.js.map +1 -1
- package/dist/TxQueue.d.ts +200 -180
- package/dist/TxQueue.d.ts.map +1 -1
- package/dist/TxQueue.js +160 -136
- package/dist/TxQueue.js.map +1 -1
- package/dist/TxReentrantLock.d.ts +97 -66
- package/dist/TxReentrantLock.d.ts.map +1 -1
- package/dist/TxReentrantLock.js +67 -45
- package/dist/TxReentrantLock.js.map +1 -1
- package/dist/TxRef.d.ts +51 -32
- package/dist/TxRef.d.ts.map +1 -1
- package/dist/TxRef.js +23 -15
- package/dist/TxRef.js.map +1 -1
- package/dist/TxSemaphore.d.ts +129 -95
- package/dist/TxSemaphore.d.ts.map +1 -1
- package/dist/TxSemaphore.js +85 -70
- package/dist/TxSemaphore.js.map +1 -1
- package/dist/TxSubscriptionRef.d.ts +97 -70
- package/dist/TxSubscriptionRef.d.ts.map +1 -1
- package/dist/TxSubscriptionRef.js +44 -34
- package/dist/TxSubscriptionRef.js.map +1 -1
- package/dist/Types.d.ts +126 -67
- package/dist/Types.d.ts.map +1 -1
- package/dist/UndefinedOr.js.map +1 -1
- package/dist/Unify.d.ts +45 -65
- package/dist/Unify.d.ts.map +1 -1
- package/dist/Unify.js +6 -9
- package/dist/Unify.js.map +1 -1
- package/dist/Utils.d.ts +23 -16
- package/dist/Utils.d.ts.map +1 -1
- package/dist/Utils.js +3 -7
- package/dist/Utils.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/array.js.map +1 -1
- package/dist/internal/core.js +1 -1
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/dateTime.js +4 -0
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/doNotation.js.map +1 -1
- package/dist/internal/effect.js +77 -40
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/equal.js.map +1 -1
- package/dist/internal/errors.js.map +1 -1
- package/dist/internal/executionPlan.js.map +1 -1
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/hashSet.js.map +1 -1
- package/dist/internal/layer.js.map +1 -1
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/metric.js.map +1 -1
- package/dist/internal/option.js.map +1 -1
- package/dist/internal/persistence.d.ts +2 -0
- package/dist/internal/persistence.d.ts.map +1 -0
- package/dist/internal/persistence.js +3 -0
- package/dist/internal/persistence.js.map +1 -0
- package/dist/internal/random.js.map +1 -1
- package/dist/internal/rcRef.js.map +1 -1
- package/dist/internal/record.js.map +1 -1
- package/dist/internal/redacted.js.map +1 -1
- package/dist/internal/references.js +3 -0
- package/dist/internal/references.js.map +1 -1
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/result.js.map +1 -1
- package/dist/internal/schedule.js.map +1 -1
- package/dist/internal/schema/annotations.js.map +1 -1
- package/dist/internal/schema/cause.js.map +1 -1
- package/dist/internal/schema/fromJsonSchemaDocument.js +13 -11
- package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/fromRepresentation.js +8 -15
- package/dist/internal/schema/fromRepresentation.js.map +1 -1
- package/dist/internal/schema/parser.d.ts +14 -0
- package/dist/internal/schema/parser.d.ts.map +1 -0
- package/dist/internal/schema/parser.js +13 -0
- package/dist/internal/schema/parser.js.map +1 -0
- package/dist/internal/schema/schema.js.map +1 -1
- package/dist/internal/schema/toArbitrary.js.map +1 -1
- package/dist/internal/schema/toCodeDocument.js.map +1 -1
- package/dist/internal/schema/toEquivalence.js.map +1 -1
- package/dist/internal/schema/toJsonSchemaDocument.js +48 -6
- package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/toRepresentation.js +87 -107
- package/dist/internal/schema/toRepresentation.js.map +1 -1
- package/dist/internal/stackTraceLimit.js.map +1 -1
- package/dist/internal/stream.js.map +1 -1
- package/dist/internal/tracer.js.map +1 -1
- package/dist/internal/trie.js +13 -9
- package/dist/internal/trie.js.map +1 -1
- package/dist/testing/FastCheck.d.ts +8 -7
- package/dist/testing/FastCheck.d.ts.map +1 -1
- package/dist/testing/FastCheck.js +8 -7
- package/dist/testing/FastCheck.js.map +1 -1
- package/dist/testing/TestClock.d.ts +57 -28
- package/dist/testing/TestClock.d.ts.map +1 -1
- package/dist/testing/TestClock.js +50 -18
- package/dist/testing/TestClock.js.map +1 -1
- package/dist/testing/TestConsole.d.ts +32 -31
- package/dist/testing/TestConsole.d.ts.map +1 -1
- package/dist/testing/TestConsole.js +24 -22
- package/dist/testing/TestConsole.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +29 -29
- package/dist/testing/TestSchema.js +25 -25
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/unstable/ai/AiError.d.ts +95 -118
- package/dist/unstable/ai/AiError.d.ts.map +1 -1
- package/dist/unstable/ai/AiError.js +94 -117
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Chat.d.ts +132 -97
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/Chat.js +55 -51
- package/dist/unstable/ai/Chat.js.map +1 -1
- package/dist/unstable/ai/EmbeddingModel.js.map +1 -1
- package/dist/unstable/ai/IdGenerator.d.ts +32 -28
- package/dist/unstable/ai/IdGenerator.d.ts.map +1 -1
- package/dist/unstable/ai/IdGenerator.js +26 -21
- package/dist/unstable/ai/IdGenerator.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts +107 -67
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +104 -64
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/McpProtocol.d.ts +30 -0
- package/dist/unstable/ai/McpProtocol.d.ts.map +1 -0
- package/dist/unstable/ai/McpProtocol.js +20 -0
- package/dist/unstable/ai/McpProtocol.js.map +1 -0
- package/dist/unstable/ai/McpSchema.d.ts +141 -75
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.js +58 -50
- package/dist/unstable/ai/McpSchema.js.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts +68 -59
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js +694 -241
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/Model.d.ts +8 -19
- package/dist/unstable/ai/Model.d.ts.map +1 -1
- package/dist/unstable/ai/Model.js +9 -20
- package/dist/unstable/ai/Model.js.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Prompt.d.ts +112 -38
- package/dist/unstable/ai/Prompt.d.ts.map +1 -1
- package/dist/unstable/ai/Prompt.js +53 -17
- package/dist/unstable/ai/Prompt.js.map +1 -1
- package/dist/unstable/ai/Response.d.ts +28 -14
- package/dist/unstable/ai/Response.d.ts.map +1 -1
- package/dist/unstable/ai/Response.js +9 -4
- package/dist/unstable/ai/Response.js.map +1 -1
- package/dist/unstable/ai/ResponseIdTracker.js.map +1 -1
- package/dist/unstable/ai/Telemetry.d.ts +46 -13
- package/dist/unstable/ai/Telemetry.d.ts.map +1 -1
- package/dist/unstable/ai/Telemetry.js +18 -7
- package/dist/unstable/ai/Telemetry.js.map +1 -1
- package/dist/unstable/ai/Tokenizer.d.ts +14 -3
- package/dist/unstable/ai/Tokenizer.d.ts.map +1 -1
- package/dist/unstable/ai/Tokenizer.js +10 -2
- package/dist/unstable/ai/Tokenizer.js.map +1 -1
- package/dist/unstable/ai/Tool.d.ts +59 -44
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +48 -39
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/ai/Toolkit.d.ts +26 -8
- package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
- package/dist/unstable/ai/Toolkit.js +18 -4
- package/dist/unstable/ai/Toolkit.js.map +1 -1
- package/dist/unstable/ai/index.d.ts +4 -0
- package/dist/unstable/ai/index.d.ts.map +1 -1
- package/dist/unstable/ai/index.js +4 -0
- package/dist/unstable/ai/index.js.map +1 -1
- package/dist/unstable/ai/internal/codec-transformer.js.map +1 -1
- package/dist/unstable/ai/internal/mcpProtocol.d.ts +21 -0
- package/dist/unstable/ai/internal/mcpProtocol.d.ts.map +1 -0
- package/dist/unstable/ai/internal/mcpProtocol.js +22 -0
- package/dist/unstable/ai/internal/mcpProtocol.js.map +1 -0
- package/dist/unstable/ai/internal/mcpProtocolRegistry.d.ts +2 -0
- package/dist/unstable/ai/internal/mcpProtocolRegistry.d.ts.map +1 -0
- package/dist/unstable/ai/internal/mcpProtocolRegistry.js +32 -0
- package/dist/unstable/ai/internal/mcpProtocolRegistry.js.map +1 -0
- package/dist/unstable/ai/internal/structured-output.js +14 -15
- package/dist/unstable/ai/internal/structured-output.js.map +1 -1
- package/dist/unstable/cli/Argument.d.ts +273 -69
- package/dist/unstable/cli/Argument.d.ts.map +1 -1
- package/dist/unstable/cli/Argument.js +111 -33
- package/dist/unstable/cli/Argument.js.map +1 -1
- package/dist/unstable/cli/CliConfig.js.map +1 -1
- package/dist/unstable/cli/CliError.d.ts +69 -76
- package/dist/unstable/cli/CliError.d.ts.map +1 -1
- package/dist/unstable/cli/CliError.js +57 -61
- package/dist/unstable/cli/CliError.js.map +1 -1
- package/dist/unstable/cli/CliOutput.d.ts +35 -54
- package/dist/unstable/cli/CliOutput.d.ts.map +1 -1
- package/dist/unstable/cli/CliOutput.js +26 -42
- package/dist/unstable/cli/CliOutput.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +705 -107
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +238 -42
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/Completions.js.map +1 -1
- package/dist/unstable/cli/Flag.d.ts +418 -138
- package/dist/unstable/cli/Flag.d.ts.map +1 -1
- package/dist/unstable/cli/Flag.js +197 -71
- package/dist/unstable/cli/Flag.js.map +1 -1
- package/dist/unstable/cli/GlobalFlag.d.ts +1 -1
- package/dist/unstable/cli/GlobalFlag.js.map +1 -1
- package/dist/unstable/cli/HelpDoc.d.ts +12 -4
- package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
- package/dist/unstable/cli/Param.d.ts +292 -78
- package/dist/unstable/cli/Param.d.ts.map +1 -1
- package/dist/unstable/cli/Param.js +128 -46
- package/dist/unstable/cli/Param.js.map +1 -1
- package/dist/unstable/cli/Primitive.d.ts +370 -149
- package/dist/unstable/cli/Primitive.d.ts.map +1 -1
- package/dist/unstable/cli/Primitive.js +344 -136
- package/dist/unstable/cli/Primitive.js.map +1 -1
- package/dist/unstable/cli/Prompt.d.ts +23 -14
- package/dist/unstable/cli/Prompt.d.ts.map +1 -1
- package/dist/unstable/cli/Prompt.js +23 -14
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cli/index.js.map +1 -1
- package/dist/unstable/cli/internal/ansi.js.map +1 -1
- package/dist/unstable/cli/internal/auto-suggest.js.map +1 -1
- package/dist/unstable/cli/internal/command.js.map +1 -1
- package/dist/unstable/cli/internal/completions/bash.js.map +1 -1
- package/dist/unstable/cli/internal/completions/descriptor.js.map +1 -1
- package/dist/unstable/cli/internal/completions/fish.js.map +1 -1
- package/dist/unstable/cli/internal/completions/zsh.js.map +1 -1
- package/dist/unstable/cli/internal/config.js.map +1 -1
- package/dist/unstable/cli/internal/help.js.map +1 -1
- package/dist/unstable/cli/internal/lexer.js +17 -7
- package/dist/unstable/cli/internal/lexer.js.map +1 -1
- package/dist/unstable/cli/internal/parser.js +2 -2
- package/dist/unstable/cli/internal/parser.js.map +1 -1
- package/dist/unstable/cli/internal/wizard.js.map +1 -1
- package/dist/unstable/cluster/ClusterCron.js.map +1 -1
- package/dist/unstable/cluster/ClusterError.js.map +1 -1
- package/dist/unstable/cluster/ClusterMetrics.js.map +1 -1
- package/dist/unstable/cluster/ClusterSchema.d.ts +8 -8
- package/dist/unstable/cluster/ClusterSchema.js +8 -8
- package/dist/unstable/cluster/ClusterSchema.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +5 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/DeliverAt.js.map +1 -1
- package/dist/unstable/cluster/Entity.d.ts +10 -10
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.js +8 -8
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/EntityAddress.js.map +1 -1
- package/dist/unstable/cluster/EntityId.js.map +1 -1
- package/dist/unstable/cluster/EntityProxy.d.ts +4 -2
- package/dist/unstable/cluster/EntityProxy.d.ts.map +1 -1
- package/dist/unstable/cluster/EntityProxy.js +4 -2
- package/dist/unstable/cluster/EntityProxy.js.map +1 -1
- package/dist/unstable/cluster/EntityProxyServer.js.map +1 -1
- package/dist/unstable/cluster/EntityResource.d.ts +2 -2
- package/dist/unstable/cluster/EntityResource.js +2 -2
- package/dist/unstable/cluster/EntityResource.js.map +1 -1
- package/dist/unstable/cluster/EntityType.js.map +1 -1
- package/dist/unstable/cluster/Envelope.d.ts +3 -3
- package/dist/unstable/cluster/Envelope.js +3 -3
- package/dist/unstable/cluster/Envelope.js.map +1 -1
- package/dist/unstable/cluster/HttpRunner.d.ts +2 -2
- package/dist/unstable/cluster/HttpRunner.d.ts.map +1 -1
- package/dist/unstable/cluster/HttpRunner.js +6 -4
- package/dist/unstable/cluster/HttpRunner.js.map +1 -1
- package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
- package/dist/unstable/cluster/MachineId.js.map +1 -1
- package/dist/unstable/cluster/Message.d.ts +9 -9
- package/dist/unstable/cluster/Message.js +6 -6
- package/dist/unstable/cluster/Message.js.map +1 -1
- package/dist/unstable/cluster/MessageStorage.d.ts +15 -15
- package/dist/unstable/cluster/MessageStorage.js +5 -5
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Reply.d.ts.map +1 -1
- package/dist/unstable/cluster/Reply.js +4 -4
- package/dist/unstable/cluster/Reply.js.map +1 -1
- package/dist/unstable/cluster/Runner.js.map +1 -1
- package/dist/unstable/cluster/RunnerAddress.js.map +1 -1
- package/dist/unstable/cluster/RunnerHealth.d.ts +1 -1
- package/dist/unstable/cluster/RunnerHealth.js +1 -1
- package/dist/unstable/cluster/RunnerHealth.js.map +1 -1
- package/dist/unstable/cluster/RunnerServer.d.ts +2 -1
- package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerServer.js +16 -16
- package/dist/unstable/cluster/RunnerServer.js.map +1 -1
- package/dist/unstable/cluster/RunnerStorage.d.ts +2 -2
- package/dist/unstable/cluster/RunnerStorage.js +1 -1
- package/dist/unstable/cluster/RunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/Runners.d.ts +6 -6
- package/dist/unstable/cluster/Runners.d.ts.map +1 -1
- package/dist/unstable/cluster/Runners.js +19 -10
- package/dist/unstable/cluster/Runners.js.map +1 -1
- package/dist/unstable/cluster/ShardId.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +3 -2
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.d.ts +3 -3
- package/dist/unstable/cluster/ShardingConfig.js +3 -3
- package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
- package/dist/unstable/cluster/ShardingRegistrationEvent.js.map +1 -1
- package/dist/unstable/cluster/SingleRunner.js.map +1 -1
- package/dist/unstable/cluster/Singleton.js.map +1 -1
- package/dist/unstable/cluster/SingletonAddress.d.ts +1 -1
- package/dist/unstable/cluster/SingletonAddress.js +1 -1
- package/dist/unstable/cluster/SingletonAddress.js.map +1 -1
- package/dist/unstable/cluster/Snowflake.d.ts +8 -8
- package/dist/unstable/cluster/Snowflake.js +8 -8
- package/dist/unstable/cluster/Snowflake.js.map +1 -1
- package/dist/unstable/cluster/SocketRunner.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.js +20 -5
- package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/TestRunner.js.map +1 -1
- package/dist/unstable/cluster/index.js.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +5 -5
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/cluster/internal/entityReaper.js.map +1 -1
- package/dist/unstable/cluster/internal/hash.js.map +1 -1
- package/dist/unstable/cluster/internal/interruptors.js.map +1 -1
- package/dist/unstable/cluster/internal/resourceMap.js.map +1 -1
- package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
- package/dist/unstable/cluster/internal/shardLock.js.map +1 -1
- package/dist/unstable/devtools/DevTools.js.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.js.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
- package/dist/unstable/devtools/DevToolsServer.js.map +1 -1
- package/dist/unstable/devtools/index.js.map +1 -1
- package/dist/unstable/encoding/Msgpack.d.ts.map +1 -1
- package/dist/unstable/encoding/Msgpack.js +6 -8
- package/dist/unstable/encoding/Msgpack.js.map +1 -1
- package/dist/unstable/encoding/Ndjson.js.map +1 -1
- package/dist/unstable/encoding/Sse.d.ts +72 -8
- package/dist/unstable/encoding/Sse.d.ts.map +1 -1
- package/dist/unstable/encoding/Sse.js +58 -8
- package/dist/unstable/encoding/Sse.js.map +1 -1
- package/dist/unstable/encoding/index.js.map +1 -1
- package/dist/unstable/eventlog/Event.d.ts +20 -20
- package/dist/unstable/eventlog/Event.js.map +1 -1
- package/dist/unstable/eventlog/EventGroup.d.ts +4 -4
- package/dist/unstable/eventlog/EventGroup.js.map +1 -1
- package/dist/unstable/eventlog/EventJournal.d.ts +15 -15
- package/dist/unstable/eventlog/EventJournal.js +13 -13
- package/dist/unstable/eventlog/EventJournal.js.map +1 -1
- package/dist/unstable/eventlog/EventLog.d.ts +3 -3
- package/dist/unstable/eventlog/EventLog.js +3 -3
- package/dist/unstable/eventlog/EventLog.js.map +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.d.ts +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.js +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.js.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.d.ts +2 -2
- package/dist/unstable/eventlog/EventLogMessage.js +1 -1
- package/dist/unstable/eventlog/EventLogMessage.js.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts +15 -15
- package/dist/unstable/eventlog/EventLogRemote.js +1 -1
- package/dist/unstable/eventlog/EventLogRemote.js.map +1 -1
- package/dist/unstable/eventlog/EventLogServer.d.ts +11 -2
- package/dist/unstable/eventlog/EventLogServer.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogServer.js +45 -21
- package/dist/unstable/eventlog/EventLogServer.js.map +1 -1
- package/dist/unstable/eventlog/EventLogServerEncrypted.d.ts +4 -4
- package/dist/unstable/eventlog/EventLogServerEncrypted.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogServerEncrypted.js +13 -5
- package/dist/unstable/eventlog/EventLogServerEncrypted.js.map +1 -1
- package/dist/unstable/eventlog/EventLogServerUnencrypted.d.ts +5 -5
- package/dist/unstable/eventlog/EventLogServerUnencrypted.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogServerUnencrypted.js +14 -6
- package/dist/unstable/eventlog/EventLogServerUnencrypted.js.map +1 -1
- package/dist/unstable/eventlog/EventLogSessionAuth.d.ts +1 -1
- package/dist/unstable/eventlog/EventLogSessionAuth.js +1 -1
- package/dist/unstable/eventlog/EventLogSessionAuth.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventJournal.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerEncrypted.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js.map +1 -1
- package/dist/unstable/eventlog/index.js.map +1 -1
- package/dist/unstable/eventlog/internal/identityRootSecretDerivation.js.map +1 -1
- package/dist/unstable/http/Cookies.d.ts +2 -2
- package/dist/unstable/http/Cookies.d.ts.map +1 -1
- package/dist/unstable/http/Cookies.js +30 -18
- package/dist/unstable/http/Cookies.js.map +1 -1
- package/dist/unstable/http/Etag.d.ts +1 -1
- package/dist/unstable/http/Etag.js +1 -1
- package/dist/unstable/http/Etag.js.map +1 -1
- package/dist/unstable/http/FetchHttpClient.d.ts.map +1 -1
- package/dist/unstable/http/FetchHttpClient.js.map +1 -1
- package/dist/unstable/http/Headers.d.ts +2 -2
- package/dist/unstable/http/Headers.js +2 -2
- package/dist/unstable/http/Headers.js.map +1 -1
- package/dist/unstable/http/HttpBody.d.ts +5 -3
- package/dist/unstable/http/HttpBody.d.ts.map +1 -1
- package/dist/unstable/http/HttpBody.js +11 -5
- package/dist/unstable/http/HttpBody.js.map +1 -1
- package/dist/unstable/http/HttpClient.d.ts +51 -44
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.js +46 -17
- package/dist/unstable/http/HttpClient.js.map +1 -1
- package/dist/unstable/http/HttpClientError.js.map +1 -1
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +2 -0
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpClientResponse.d.ts +4 -4
- package/dist/unstable/http/HttpClientResponse.js +2 -2
- package/dist/unstable/http/HttpClientResponse.js.map +1 -1
- package/dist/unstable/http/HttpEffect.d.ts +6 -6
- package/dist/unstable/http/HttpEffect.js +3 -3
- package/dist/unstable/http/HttpEffect.js.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
- package/dist/unstable/http/HttpMethod.d.ts +6 -9
- package/dist/unstable/http/HttpMethod.d.ts.map +1 -1
- package/dist/unstable/http/HttpMethod.js +6 -9
- package/dist/unstable/http/HttpMethod.js.map +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts +75 -9
- package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/unstable/http/HttpMiddleware.js +164 -39
- package/dist/unstable/http/HttpMiddleware.js.map +1 -1
- package/dist/unstable/http/HttpPlatform.d.ts +76 -0
- package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
- package/dist/unstable/http/HttpPlatform.js +32 -0
- package/dist/unstable/http/HttpPlatform.js.map +1 -1
- package/dist/unstable/http/HttpRouter.d.ts +88 -89
- package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
- package/dist/unstable/http/HttpRouter.js +78 -79
- package/dist/unstable/http/HttpRouter.js.map +1 -1
- package/dist/unstable/http/HttpServer.d.ts +13 -13
- package/dist/unstable/http/HttpServer.js +6 -6
- package/dist/unstable/http/HttpServer.js.map +1 -1
- package/dist/unstable/http/HttpServerError.d.ts +2 -2
- package/dist/unstable/http/HttpServerError.js +2 -2
- package/dist/unstable/http/HttpServerError.js.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts +4 -4
- package/dist/unstable/http/HttpServerRequest.js +4 -4
- package/dist/unstable/http/HttpServerRequest.js.map +1 -1
- package/dist/unstable/http/HttpServerRespondable.js.map +1 -1
- package/dist/unstable/http/HttpServerResponse.d.ts +22 -0
- package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerResponse.js +10 -0
- package/dist/unstable/http/HttpServerResponse.js.map +1 -1
- package/dist/unstable/http/HttpStaticServer.d.ts +35 -7
- package/dist/unstable/http/HttpStaticServer.d.ts.map +1 -1
- package/dist/unstable/http/HttpStaticServer.js +35 -7
- package/dist/unstable/http/HttpStaticServer.js.map +1 -1
- package/dist/unstable/http/HttpTraceContext.js.map +1 -1
- package/dist/unstable/http/Multipart.d.ts +6 -6
- package/dist/unstable/http/Multipart.js +5 -5
- package/dist/unstable/http/Multipart.js.map +1 -1
- package/dist/unstable/http/Template.js.map +1 -1
- package/dist/unstable/http/Url.d.ts +33 -63
- package/dist/unstable/http/Url.d.ts.map +1 -1
- package/dist/unstable/http/Url.js +14 -28
- package/dist/unstable/http/Url.js.map +1 -1
- package/dist/unstable/http/UrlParams.d.ts +10 -18
- package/dist/unstable/http/UrlParams.d.ts.map +1 -1
- package/dist/unstable/http/UrlParams.js +9 -17
- package/dist/unstable/http/UrlParams.js.map +1 -1
- package/dist/unstable/http/index.js.map +1 -1
- package/dist/unstable/http/internal/compression.d.ts +2 -0
- package/dist/unstable/http/internal/compression.d.ts.map +1 -0
- package/dist/unstable/http/internal/compression.js +155 -0
- package/dist/unstable/http/internal/compression.js.map +1 -0
- package/dist/unstable/http/internal/preResponseHandler.js.map +1 -1
- package/dist/unstable/httpapi/HttpApi.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +10 -11
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.d.ts +4 -5
- package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js +11 -13
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +42 -42
- package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts +13 -13
- package/dist/unstable/httpapi/HttpApiError.js +13 -13
- package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.d.ts +15 -15
- package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +71 -24
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.js +57 -10
- package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.d.ts +0 -12
- package/dist/unstable/httpapi/HttpApiScalar.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.d.ts +6 -6
- package/dist/unstable/httpapi/HttpApiSchema.js +4 -4
- package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSecurity.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSwagger.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiTest.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts +13 -13
- package/dist/unstable/httpapi/OpenApi.js +13 -13
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/httpapi/index.js.map +1 -1
- package/dist/unstable/httpapi/internal/html.js.map +1 -1
- package/dist/unstable/httpapi/internal/httpApiScalar.js.map +1 -1
- package/dist/unstable/httpapi/internal/httpApiSwagger.js.map +1 -1
- package/dist/unstable/httpapi/internal/mediaType.js.map +1 -1
- package/dist/unstable/observability/Otlp.js.map +1 -1
- package/dist/unstable/observability/OtlpExporter.d.ts +12 -14
- package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +17 -4
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/observability/OtlpLogger.js.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.d.ts +4 -1
- package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.js.map +1 -1
- package/dist/unstable/observability/OtlpResource.d.ts +16 -7
- package/dist/unstable/observability/OtlpResource.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpResource.js +21 -12
- package/dist/unstable/observability/OtlpResource.js.map +1 -1
- package/dist/unstable/observability/OtlpSerialization.js.map +1 -1
- package/dist/unstable/observability/OtlpTracer.js.map +1 -1
- package/dist/unstable/observability/PrometheusMetrics.d.ts +13 -4
- package/dist/unstable/observability/PrometheusMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/PrometheusMetrics.js +10 -3
- package/dist/unstable/observability/PrometheusMetrics.js.map +1 -1
- package/dist/unstable/observability/index.js.map +1 -1
- package/dist/unstable/observability/internal/otlpEnv.js +1 -1
- package/dist/unstable/observability/internal/otlpEnv.js.map +1 -1
- package/dist/unstable/observability/internal/otlpProtobuf.js.map +1 -1
- package/dist/unstable/observability/internal/protobuf.js +3 -0
- package/dist/unstable/observability/internal/protobuf.js.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.d.ts +8 -3
- package/dist/unstable/persistence/KeyValueStore.d.ts.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.js +22 -13
- package/dist/unstable/persistence/KeyValueStore.js.map +1 -1
- package/dist/unstable/persistence/Persistable.d.ts +8 -8
- package/dist/unstable/persistence/Persistable.js.map +1 -1
- package/dist/unstable/persistence/PersistedCache.js.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.d.ts +6 -6
- package/dist/unstable/persistence/PersistedQueue.js +6 -6
- package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
- package/dist/unstable/persistence/Persistence.d.ts +3 -3
- package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
- package/dist/unstable/persistence/Persistence.js +91 -15
- package/dist/unstable/persistence/Persistence.js.map +1 -1
- package/dist/unstable/persistence/RateLimiter.d.ts +26 -15
- package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/unstable/persistence/RateLimiter.js +24 -13
- package/dist/unstable/persistence/RateLimiter.js.map +1 -1
- package/dist/unstable/persistence/Redis.d.ts +2 -2
- package/dist/unstable/persistence/Redis.js +1 -1
- package/dist/unstable/persistence/Redis.js.map +1 -1
- package/dist/unstable/persistence/index.js.map +1 -1
- package/dist/unstable/process/ChildProcess.d.ts +64 -21
- package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcess.js +14 -5
- package/dist/unstable/process/ChildProcess.js.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.d.ts +21 -10
- package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.js +1 -1
- package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
- package/dist/unstable/process/index.js.map +1 -1
- package/dist/unstable/reactivity/AsyncResult.d.ts +8 -8
- package/dist/unstable/reactivity/AsyncResult.d.ts.map +1 -1
- package/dist/unstable/reactivity/AsyncResult.js +10 -10
- package/dist/unstable/reactivity/AsyncResult.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts +25 -22
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +14 -13
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.js +4 -1
- package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/unstable/reactivity/AtomRef.js.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +24 -3
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.js +4 -1
- package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
- package/dist/unstable/reactivity/Hydration.d.ts +1 -1
- package/dist/unstable/reactivity/Hydration.js +1 -1
- package/dist/unstable/reactivity/Hydration.js.map +1 -1
- package/dist/unstable/reactivity/Reactivity.js.map +1 -1
- package/dist/unstable/reactivity/index.js.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts +35 -33
- package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.js +4 -2
- package/dist/unstable/rpc/Rpc.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts +12 -12
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +12 -11
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcClientError.js.map +1 -1
- package/dist/unstable/rpc/RpcGroup.d.ts +8 -8
- package/dist/unstable/rpc/RpcGroup.js +1 -1
- package/dist/unstable/rpc/RpcGroup.js.map +1 -1
- package/dist/unstable/rpc/RpcMessage.d.ts +31 -30
- package/dist/unstable/rpc/RpcMessage.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMessage.js +6 -6
- package/dist/unstable/rpc/RpcMessage.js.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.d.ts +10 -10
- package/dist/unstable/rpc/RpcMiddleware.js +1 -1
- package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
- package/dist/unstable/rpc/RpcSchema.d.ts +4 -4
- package/dist/unstable/rpc/RpcSchema.js +3 -3
- package/dist/unstable/rpc/RpcSchema.js.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.d.ts +58 -7
- package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +175 -96
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts +13 -13
- package/dist/unstable/rpc/RpcServer.js +17 -13
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/rpc/RpcTest.js.map +1 -1
- package/dist/unstable/rpc/RpcWorker.d.ts +5 -5
- package/dist/unstable/rpc/RpcWorker.js +4 -4
- package/dist/unstable/rpc/RpcWorker.js.map +1 -1
- package/dist/unstable/rpc/Utils.js.map +1 -1
- package/dist/unstable/rpc/index.js.map +1 -1
- package/dist/unstable/schema/Model.d.ts +52 -50
- package/dist/unstable/schema/Model.d.ts.map +1 -1
- package/dist/unstable/schema/Model.js +35 -33
- package/dist/unstable/schema/Model.js.map +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts +5 -5
- package/dist/unstable/schema/VariantSchema.js +2 -2
- package/dist/unstable/schema/VariantSchema.js.map +1 -1
- package/dist/unstable/schema/index.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts +11 -3
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +9 -4
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/socket/SocketServer.js.map +1 -1
- package/dist/unstable/socket/index.js.map +1 -1
- package/dist/unstable/sql/Migrator.js.map +1 -1
- package/dist/unstable/sql/SqlClient.d.ts +1 -1
- package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
- package/dist/unstable/sql/SqlClient.js +2 -2
- package/dist/unstable/sql/SqlClient.js.map +1 -1
- package/dist/unstable/sql/SqlConnection.js.map +1 -1
- package/dist/unstable/sql/SqlError.js.map +1 -1
- package/dist/unstable/sql/SqlModel.d.ts +2 -2
- package/dist/unstable/sql/SqlModel.js +2 -2
- package/dist/unstable/sql/SqlModel.js.map +1 -1
- package/dist/unstable/sql/SqlResolver.d.ts +5 -5
- package/dist/unstable/sql/SqlResolver.js +2 -2
- package/dist/unstable/sql/SqlResolver.js.map +1 -1
- package/dist/unstable/sql/SqlSchema.js.map +1 -1
- package/dist/unstable/sql/SqlStream.js.map +1 -1
- package/dist/unstable/sql/Statement.d.ts +6 -6
- package/dist/unstable/sql/Statement.js +15 -15
- package/dist/unstable/sql/Statement.js.map +1 -1
- package/dist/unstable/sql/index.js.map +1 -1
- package/dist/unstable/workers/Transferable.d.ts +1 -1
- package/dist/unstable/workers/Transferable.js +1 -1
- package/dist/unstable/workers/Transferable.js.map +1 -1
- package/dist/unstable/workers/Worker.d.ts +2 -2
- package/dist/unstable/workers/Worker.js +2 -2
- package/dist/unstable/workers/Worker.js.map +1 -1
- package/dist/unstable/workers/WorkerError.d.ts +7 -7
- package/dist/unstable/workers/WorkerError.js +6 -6
- package/dist/unstable/workers/WorkerError.js.map +1 -1
- package/dist/unstable/workers/WorkerRunner.d.ts +1 -1
- package/dist/unstable/workers/WorkerRunner.js +1 -1
- package/dist/unstable/workers/WorkerRunner.js.map +1 -1
- package/dist/unstable/workers/index.js.map +1 -1
- package/dist/unstable/workflow/Activity.d.ts +2 -2
- package/dist/unstable/workflow/Activity.js +2 -2
- package/dist/unstable/workflow/Activity.js.map +1 -1
- package/dist/unstable/workflow/DurableClock.d.ts +1 -1
- package/dist/unstable/workflow/DurableClock.js +1 -1
- package/dist/unstable/workflow/DurableClock.js.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.d.ts +10 -10
- package/dist/unstable/workflow/DurableDeferred.js +5 -5
- package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
- package/dist/unstable/workflow/DurableQueue.d.ts +22 -20
- package/dist/unstable/workflow/DurableQueue.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableQueue.js +22 -20
- package/dist/unstable/workflow/DurableQueue.js.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +21 -21
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/Workflow.js +13 -14
- package/dist/unstable/workflow/Workflow.js.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/dist/unstable/workflow/WorkflowProxy.d.ts +4 -2
- package/dist/unstable/workflow/WorkflowProxy.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowProxy.js +4 -2
- package/dist/unstable/workflow/WorkflowProxy.js.map +1 -1
- package/dist/unstable/workflow/WorkflowProxyServer.js.map +1 -1
- package/dist/unstable/workflow/index.js.map +1 -1
- package/dist/unstable/workflow/internal/crypto.js.map +1 -1
- package/package.json +5 -6
- package/src/Array.ts +982 -1045
- package/src/BigDecimal.ts +433 -756
- package/src/BigInt.ts +213 -269
- package/src/Boolean.ts +146 -188
- package/src/Cache.ts +409 -255
- package/src/Cause.ts +167 -277
- package/src/Channel.ts +891 -816
- package/src/ChannelSchema.ts +1 -1
- package/src/Chunk.ts +841 -1181
- package/src/Clock.ts +181 -49
- package/src/Combiner.ts +20 -33
- package/src/Config.ts +615 -332
- package/src/ConfigProvider.ts +214 -120
- package/src/Console.ts +289 -39
- package/src/Context.ts +319 -378
- package/src/Cron.ts +68 -77
- package/src/Crypto.ts +13 -15
- package/src/Data.ts +60 -80
- package/src/DateTime.ts +564 -660
- package/src/Deferred.ts +253 -256
- package/src/Duration.ts +216 -308
- package/src/Effect.ts +2893 -3279
- package/src/Encoding.ts +22 -40
- package/src/Equal.ts +49 -39
- package/src/Equivalence.ts +103 -105
- package/src/ErrorReporter.ts +51 -27
- package/src/ExecutionPlan.ts +13 -55
- package/src/Exit.ts +116 -192
- package/src/Fiber.ts +81 -148
- package/src/FiberHandle.ts +152 -105
- package/src/FiberMap.ts +225 -174
- package/src/FiberSet.ts +124 -82
- package/src/FileSystem.ts +155 -263
- package/src/Filter.ts +61 -33
- package/src/Formatter.ts +54 -56
- package/src/Function.ts +76 -145
- package/src/Graph.ts +416 -770
- package/src/HKT.ts +12 -6
- package/src/Hash.ts +52 -83
- package/src/HashMap.ts +319 -411
- package/src/HashRing.ts +1 -0
- package/src/HashSet.ts +177 -284
- package/src/Inspectable.ts +12 -12
- package/src/Iterable.ts +620 -786
- package/src/JsonPatch.ts +58 -112
- package/src/JsonPointer.ts +8 -8
- package/src/JsonSchema.ts +402 -244
- package/src/Latch.ts +23 -35
- package/src/Layer.ts +359 -260
- package/src/LayerMap.ts +49 -29
- package/src/LayerRef.ts +6 -2
- package/src/LogLevel.ts +114 -214
- package/src/Logger.ts +344 -697
- package/src/ManagedRuntime.ts +7 -5
- package/src/Match.ts +217 -252
- package/src/Metric.ts +516 -1089
- package/src/MutableHashMap.ts +218 -255
- package/src/MutableHashSet.ts +84 -89
- package/src/MutableList.ts +73 -370
- package/src/MutableRef.ts +420 -243
- package/src/Newtype.ts +21 -14
- package/src/NonEmptyIterable.ts +7 -137
- package/src/Number.ts +196 -233
- package/src/Optic.ts +243 -383
- package/src/Option.ts +447 -812
- package/src/Order.ts +109 -109
- package/src/Ordering.ts +20 -23
- package/src/Path.ts +38 -41
- package/src/Pipeable.ts +6 -5
- package/src/PlatformError.ts +4 -4
- package/src/Pool.ts +4 -2
- package/src/Predicate.ts +200 -181
- package/src/PrimaryKey.ts +7 -7
- package/src/PubSub.ts +526 -552
- package/src/Pull.ts +24 -18
- package/src/Queue.ts +200 -159
- package/src/Random.ts +49 -74
- package/src/RcMap.ts +121 -63
- package/src/RcRef.ts +24 -13
- package/src/Record.ts +291 -488
- package/src/Redactable.ts +10 -3
- package/src/Redacted.ts +25 -25
- package/src/Reducer.ts +8 -15
- package/src/Ref.ts +221 -361
- package/src/References.ts +102 -168
- package/src/RegExp.ts +10 -14
- package/src/Request.ts +31 -21
- package/src/RequestResolver.ts +202 -91
- package/src/Result.ts +312 -484
- package/src/Runtime.ts +50 -75
- package/src/Schedule.ts +308 -1734
- package/src/Scheduler.ts +20 -7
- package/src/Schema.ts +716 -745
- package/src/SchemaAST.ts +466 -358
- package/src/SchemaError.ts +7 -6
- package/src/SchemaGetter.ts +242 -190
- package/src/SchemaIssue.ts +89 -275
- package/src/SchemaParser.ts +180 -93
- package/src/SchemaRepresentation.ts +22 -40
- package/src/SchemaTransformation.ts +129 -88
- package/src/Scope.ts +123 -151
- package/src/ScopedRef.ts +4 -4
- package/src/Semaphore.ts +152 -51
- package/src/Sink.ts +128 -113
- package/src/Stdio.ts +1 -1
- package/src/Stream.ts +2602 -3123
- package/src/String.ts +275 -312
- package/src/Struct.ts +109 -114
- package/src/SubscriptionRef.ts +284 -252
- package/src/Symbol.ts +3 -3
- package/src/Terminal.ts +2 -2
- package/src/Tracer.ts +102 -55
- package/src/Trie.ts +287 -679
- package/src/Tuple.ts +92 -127
- package/src/TxChunk.ts +201 -121
- package/src/TxDeferred.ts +62 -46
- package/src/TxHashMap.ts +645 -799
- package/src/TxHashSet.ts +443 -356
- package/src/TxPriorityQueue.ts +130 -98
- package/src/TxPubSub.ts +107 -80
- package/src/TxQueue.ts +214 -183
- package/src/TxReentrantLock.ts +97 -66
- package/src/TxRef.ts +51 -32
- package/src/TxSemaphore.ts +129 -95
- package/src/TxSubscriptionRef.ts +97 -70
- package/src/Types.ts +126 -67
- package/src/Unify.ts +45 -65
- package/src/Utils.ts +23 -16
- package/src/internal/core.ts +2 -2
- package/src/internal/dateTime.ts +6 -0
- package/src/internal/effect.ts +93 -48
- package/src/internal/persistence.ts +2 -0
- package/src/internal/references.ts +3 -2
- package/src/internal/schema/fromJsonSchemaDocument.ts +15 -13
- package/src/internal/schema/fromRepresentation.ts +10 -16
- package/src/internal/schema/parser.ts +22 -0
- package/src/internal/schema/toJsonSchemaDocument.ts +60 -6
- package/src/internal/schema/toRepresentation.ts +104 -119
- package/src/internal/trie.ts +10 -11
- package/src/testing/FastCheck.ts +8 -7
- package/src/testing/TestClock.ts +72 -30
- package/src/testing/TestConsole.ts +32 -31
- package/src/testing/TestSchema.ts +29 -29
- package/src/unstable/ai/AiError.ts +95 -118
- package/src/unstable/ai/AnthropicStructuredOutput.ts +1 -1
- package/src/unstable/ai/Chat.ts +132 -97
- package/src/unstable/ai/IdGenerator.ts +32 -28
- package/src/unstable/ai/LanguageModel.ts +107 -67
- package/src/unstable/ai/McpProtocol.ts +48 -0
- package/src/unstable/ai/McpSchema.ts +60 -50
- package/src/unstable/ai/McpServer.ts +930 -304
- package/src/unstable/ai/Model.ts +9 -20
- package/src/unstable/ai/OpenAiStructuredOutput.ts +1 -1
- package/src/unstable/ai/Prompt.ts +145 -43
- package/src/unstable/ai/Response.ts +28 -14
- package/src/unstable/ai/Telemetry.ts +46 -13
- package/src/unstable/ai/Tokenizer.ts +14 -3
- package/src/unstable/ai/Tool.ts +59 -44
- package/src/unstable/ai/Toolkit.ts +26 -8
- package/src/unstable/ai/index.ts +5 -0
- package/src/unstable/ai/internal/mcpProtocol.ts +85 -0
- package/src/unstable/ai/internal/mcpProtocolRegistry.ts +70 -0
- package/src/unstable/ai/internal/structured-output.ts +13 -18
- package/src/unstable/cli/Argument.ts +273 -69
- package/src/unstable/cli/CliError.ts +69 -76
- package/src/unstable/cli/CliOutput.ts +44 -58
- package/src/unstable/cli/Command.ts +705 -107
- package/src/unstable/cli/Flag.ts +418 -138
- package/src/unstable/cli/GlobalFlag.ts +1 -1
- package/src/unstable/cli/HelpDoc.ts +12 -4
- package/src/unstable/cli/Param.ts +292 -78
- package/src/unstable/cli/Primitive.ts +370 -149
- package/src/unstable/cli/Prompt.ts +28 -14
- package/src/unstable/cli/internal/lexer.ts +8 -2
- package/src/unstable/cli/internal/parser.ts +2 -2
- package/src/unstable/cluster/ClusterSchema.ts +8 -8
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +5 -1
- package/src/unstable/cluster/Entity.ts +15 -16
- package/src/unstable/cluster/EntityProxy.ts +4 -2
- package/src/unstable/cluster/EntityResource.ts +2 -2
- package/src/unstable/cluster/Envelope.ts +3 -3
- package/src/unstable/cluster/HttpRunner.ts +6 -4
- package/src/unstable/cluster/Message.ts +9 -9
- package/src/unstable/cluster/MessageStorage.ts +15 -15
- package/src/unstable/cluster/Reply.ts +4 -6
- package/src/unstable/cluster/RunnerHealth.ts +1 -1
- package/src/unstable/cluster/RunnerServer.ts +41 -8
- package/src/unstable/cluster/RunnerStorage.ts +2 -2
- package/src/unstable/cluster/Runners.ts +23 -12
- package/src/unstable/cluster/Sharding.ts +7 -8
- package/src/unstable/cluster/ShardingConfig.ts +3 -3
- package/src/unstable/cluster/SingletonAddress.ts +1 -1
- package/src/unstable/cluster/Snowflake.ts +8 -8
- package/src/unstable/cluster/SqlMessageStorage.ts +1 -1
- package/src/unstable/cluster/SqlRunnerStorage.ts +21 -5
- package/src/unstable/cluster/internal/entityManager.ts +11 -15
- package/src/unstable/encoding/Msgpack.ts +6 -8
- package/src/unstable/encoding/Sse.ts +98 -16
- package/src/unstable/eventlog/Event.ts +20 -20
- package/src/unstable/eventlog/EventGroup.ts +4 -4
- package/src/unstable/eventlog/EventJournal.ts +15 -15
- package/src/unstable/eventlog/EventLog.ts +3 -3
- package/src/unstable/eventlog/EventLogEncryption.ts +1 -1
- package/src/unstable/eventlog/EventLogMessage.ts +2 -2
- package/src/unstable/eventlog/EventLogRemote.ts +1 -1
- package/src/unstable/eventlog/EventLogServer.ts +41 -7
- package/src/unstable/eventlog/EventLogServerEncrypted.ts +13 -5
- package/src/unstable/eventlog/EventLogServerUnencrypted.ts +14 -6
- package/src/unstable/eventlog/EventLogSessionAuth.ts +1 -1
- package/src/unstable/http/Cookies.ts +35 -21
- package/src/unstable/http/Etag.ts +1 -1
- package/src/unstable/http/FetchHttpClient.ts +3 -1
- package/src/unstable/http/Headers.ts +2 -2
- package/src/unstable/http/HttpBody.ts +20 -5
- package/src/unstable/http/HttpClient.ts +83 -55
- package/src/unstable/http/HttpClientRequest.ts +2 -0
- package/src/unstable/http/HttpClientResponse.ts +4 -4
- package/src/unstable/http/HttpEffect.ts +8 -8
- package/src/unstable/http/HttpMethod.ts +6 -9
- package/src/unstable/http/HttpMiddleware.ts +202 -39
- package/src/unstable/http/HttpPlatform.ts +95 -0
- package/src/unstable/http/HttpRouter.ts +102 -98
- package/src/unstable/http/HttpServer.ts +13 -13
- package/src/unstable/http/HttpServerError.ts +2 -2
- package/src/unstable/http/HttpServerRequest.ts +4 -4
- package/src/unstable/http/HttpServerResponse.ts +30 -0
- package/src/unstable/http/HttpStaticServer.ts +35 -7
- package/src/unstable/http/Multipart.ts +6 -6
- package/src/unstable/http/Url.ts +33 -63
- package/src/unstable/http/UrlParams.ts +10 -18
- package/src/unstable/http/internal/compression.ts +196 -0
- package/src/unstable/httpapi/HttpApiBuilder.ts +10 -9
- package/src/unstable/httpapi/HttpApiClient.ts +14 -14
- package/src/unstable/httpapi/HttpApiEndpoint.ts +42 -42
- package/src/unstable/httpapi/HttpApiError.ts +13 -13
- package/src/unstable/httpapi/HttpApiGroup.ts +15 -15
- package/src/unstable/httpapi/HttpApiMiddleware.ts +71 -24
- package/src/unstable/httpapi/HttpApiScalar.ts +0 -12
- package/src/unstable/httpapi/HttpApiSchema.ts +6 -6
- package/src/unstable/httpapi/OpenApi.ts +13 -13
- package/src/unstable/observability/OtlpExporter.ts +31 -19
- package/src/unstable/observability/OtlpMetrics.ts +4 -1
- package/src/unstable/observability/OtlpResource.ts +26 -17
- package/src/unstable/observability/PrometheusMetrics.ts +13 -4
- package/src/unstable/observability/internal/otlpEnv.ts +1 -1
- package/src/unstable/observability/internal/protobuf.ts +3 -0
- package/src/unstable/persistence/KeyValueStore.ts +72 -49
- package/src/unstable/persistence/Persistable.ts +8 -8
- package/src/unstable/persistence/PersistedQueue.ts +6 -6
- package/src/unstable/persistence/Persistence.ts +126 -19
- package/src/unstable/persistence/RateLimiter.ts +26 -15
- package/src/unstable/persistence/Redis.ts +2 -2
- package/src/unstable/process/ChildProcess.ts +64 -21
- package/src/unstable/process/ChildProcessSpawner.ts +21 -10
- package/src/unstable/reactivity/AsyncResult.ts +12 -13
- package/src/unstable/reactivity/Atom.ts +28 -25
- package/src/unstable/reactivity/AtomHttpApi.ts +5 -4
- package/src/unstable/reactivity/AtomRegistry.ts +24 -3
- package/src/unstable/reactivity/AtomRpc.ts +5 -4
- package/src/unstable/reactivity/Hydration.ts +1 -1
- package/src/unstable/rpc/Rpc.ts +35 -33
- package/src/unstable/rpc/RpcClient.ts +16 -15
- package/src/unstable/rpc/RpcGroup.ts +8 -8
- package/src/unstable/rpc/RpcMessage.ts +31 -30
- package/src/unstable/rpc/RpcMiddleware.ts +10 -10
- package/src/unstable/rpc/RpcSchema.ts +4 -4
- package/src/unstable/rpc/RpcSerialization.ts +167 -68
- package/src/unstable/rpc/RpcServer.ts +18 -15
- package/src/unstable/rpc/RpcWorker.ts +5 -5
- package/src/unstable/schema/Model.ts +52 -50
- package/src/unstable/schema/VariantSchema.ts +5 -5
- package/src/unstable/socket/Socket.ts +17 -4
- package/src/unstable/sql/SqlClient.ts +5 -6
- package/src/unstable/sql/SqlModel.ts +2 -2
- package/src/unstable/sql/SqlResolver.ts +5 -5
- package/src/unstable/sql/Statement.ts +24 -23
- package/src/unstable/workers/Transferable.ts +1 -1
- package/src/unstable/workers/Worker.ts +2 -2
- package/src/unstable/workers/WorkerError.ts +7 -7
- package/src/unstable/workers/WorkerRunner.ts +1 -1
- package/src/unstable/workflow/Activity.ts +2 -2
- package/src/unstable/workflow/DurableClock.ts +1 -1
- package/src/unstable/workflow/DurableDeferred.ts +10 -10
- package/src/unstable/workflow/DurableQueue.ts +22 -20
- package/src/unstable/workflow/Workflow.ts +23 -23
- package/src/unstable/workflow/WorkflowEngine.ts +1 -1
- package/src/unstable/workflow/WorkflowProxy.ts +4 -2
- package/dist/internal/version.d.ts +0 -3
- package/dist/internal/version.d.ts.map +0 -1
- package/dist/internal/version.js +0 -2
- package/dist/internal/version.js.map +0 -1
- package/src/internal/version.ts +0 -2
package/src/Schedule.ts
CHANGED
|
@@ -34,42 +34,17 @@ const randomNext: Effect<number> = random.Random.useSync((random) => random.next
|
|
|
34
34
|
*
|
|
35
35
|
* **Example** (Defining retry and repeat schedules)
|
|
36
36
|
*
|
|
37
|
-
* ```ts
|
|
38
|
-
* import {
|
|
39
|
-
*
|
|
40
|
-
* class NetworkError extends Data.TaggedError("NetworkError")<{
|
|
41
|
-
* readonly attempt: number
|
|
42
|
-
* }> {}
|
|
43
|
-
*
|
|
44
|
-
* // Basic retry schedule - retry up to 3 times with exponential backoff
|
|
45
|
-
* const retrySchedule = Schedule.max([
|
|
46
|
-
* Schedule.exponential("100 millis"),
|
|
47
|
-
* Schedule.recurs(3)
|
|
48
|
-
* ])
|
|
37
|
+
* ```ts import.meta.vitest
|
|
38
|
+
* import { Effect, Schedule } from "effect"
|
|
39
|
+
* import { TestClock } from "effect/testing"
|
|
49
40
|
*
|
|
50
|
-
*
|
|
51
|
-
* const
|
|
52
|
-
* .
|
|
41
|
+
* const executions: Array<number> = []
|
|
42
|
+
* const program = Effect.sync(() => executions.push(executions.length + 1)).pipe(
|
|
43
|
+
* Effect.repeat(Schedule.recurs(2)),
|
|
44
|
+
* Effect.as(executions)
|
|
45
|
+
* )
|
|
53
46
|
*
|
|
54
|
-
*
|
|
55
|
-
* let attempts = 0
|
|
56
|
-
*
|
|
57
|
-
* const result1 = yield* Effect.retry(
|
|
58
|
-
* Effect.gen(function*() {
|
|
59
|
-
* attempts++
|
|
60
|
-
* if (attempts < 3) {
|
|
61
|
-
* return yield* Effect.fail(new NetworkError({ attempt: attempts }))
|
|
62
|
-
* }
|
|
63
|
-
* return "Success"
|
|
64
|
-
* }),
|
|
65
|
-
* retrySchedule
|
|
66
|
-
* )
|
|
67
|
-
* console.log(result1) // "Success"
|
|
68
|
-
*
|
|
69
|
-
* yield* Console.log("heartbeat").pipe(
|
|
70
|
-
* Effect.repeat(repeatSchedule.pipe(Schedule.upTo({ times: 5 })))
|
|
71
|
-
* )
|
|
72
|
-
* })
|
|
47
|
+
* await Effect.runPromise(Effect.provide(program, TestClock.layer())) // => [1, 2, 3]
|
|
73
48
|
* ```
|
|
74
49
|
*
|
|
75
50
|
* @category models
|
|
@@ -115,7 +90,7 @@ export interface Metadata<Output = unknown, Input = unknown> extends InputMetada
|
|
|
115
90
|
* input and output values, zero duration, and zeroed timing fields before any
|
|
116
91
|
* schedule step has produced metadata.
|
|
117
92
|
*
|
|
118
|
-
* @category
|
|
93
|
+
* @category services
|
|
119
94
|
* @since 4.0.0
|
|
120
95
|
*/
|
|
121
96
|
export const CurrentMetadata = Context.Reference<Metadata>("effect/Schedule/CurrentMetadata", {
|
|
@@ -142,27 +117,11 @@ export declare namespace Schedule {
|
|
|
142
117
|
*
|
|
143
118
|
* **Example** (Understanding schedule variance)
|
|
144
119
|
*
|
|
145
|
-
* ```ts
|
|
146
|
-
* import {
|
|
147
|
-
*
|
|
148
|
-
* // Understanding Schedule variance:
|
|
149
|
-
* // - Output: covariant (can be a subtype)
|
|
150
|
-
* // - Input: contravariant (can accept supertypes)
|
|
151
|
-
* // - Error: covariant (can be a subtype)
|
|
152
|
-
* // - Env: covariant (can be a subtype)
|
|
153
|
-
*
|
|
154
|
-
* // Schedule that produces strings, accepts any input
|
|
155
|
-
* const stringSchedule = Schedule.spaced("1 second").pipe(
|
|
156
|
-
* Schedule.map(() => Effect.succeed("tick"))
|
|
157
|
-
* )
|
|
120
|
+
* ```ts import.meta.vitest
|
|
121
|
+
* import { Schedule } from "effect"
|
|
158
122
|
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
* Schedule.upTo({ times: 5 })
|
|
162
|
-
* )
|
|
163
|
-
*
|
|
164
|
-
* // Schedule requiring a service environment
|
|
165
|
-
* const serviceSchedule = Schedule.spaced("5 seconds")
|
|
123
|
+
* const schedule: Schedule.Schedule<number, unknown, never, never> = Schedule.recurs(2)
|
|
124
|
+
* Schedule.isSchedule(schedule) // => true
|
|
166
125
|
* ```
|
|
167
126
|
*
|
|
168
127
|
* @category models
|
|
@@ -195,7 +154,7 @@ export declare namespace Schedule {
|
|
|
195
154
|
/**
|
|
196
155
|
* Extracts the output type from a `Schedule`.
|
|
197
156
|
*
|
|
198
|
-
* @category
|
|
157
|
+
* @category utility types
|
|
199
158
|
* @since 4.0.0
|
|
200
159
|
*/
|
|
201
160
|
export type Output<S> = S extends Schedule<infer Output, any, any, any> ? Output : never
|
|
@@ -203,7 +162,7 @@ export type Output<S> = S extends Schedule<infer Output, any, any, any> ? Output
|
|
|
203
162
|
/**
|
|
204
163
|
* Extracts the input type from a `Schedule`.
|
|
205
164
|
*
|
|
206
|
-
* @category
|
|
165
|
+
* @category utility types
|
|
207
166
|
* @since 4.0.0
|
|
208
167
|
*/
|
|
209
168
|
export type Input<S> = S extends Schedule<any, infer Input, any, any> ? Input : never
|
|
@@ -211,7 +170,7 @@ export type Input<S> = S extends Schedule<any, infer Input, any, any> ? Input :
|
|
|
211
170
|
/**
|
|
212
171
|
* Extracts the error type from a `Schedule`.
|
|
213
172
|
*
|
|
214
|
-
* @category
|
|
173
|
+
* @category utility types
|
|
215
174
|
* @since 4.0.0
|
|
216
175
|
*/
|
|
217
176
|
export type Error<S> = S extends Schedule<any, any, infer Error, any> ? Error : never
|
|
@@ -219,7 +178,7 @@ export type Error<S> = S extends Schedule<any, any, infer Error, any> ? Error :
|
|
|
219
178
|
/**
|
|
220
179
|
* Extracts the service requirements from a `Schedule`.
|
|
221
180
|
*
|
|
222
|
-
* @category
|
|
181
|
+
* @category utility types
|
|
223
182
|
* @since 4.0.0
|
|
224
183
|
*/
|
|
225
184
|
export type Env<S> = S extends Schedule<any, any, any, infer Env> ? Env : never
|
|
@@ -240,16 +199,16 @@ const ScheduleProto = {
|
|
|
240
199
|
*
|
|
241
200
|
* **Example** (Checking for schedules)
|
|
242
201
|
*
|
|
243
|
-
* ```ts
|
|
202
|
+
* ```ts import.meta.vitest
|
|
244
203
|
* import { Schedule } from "effect"
|
|
245
204
|
*
|
|
246
205
|
* const schedule = Schedule.exponential("100 millis")
|
|
247
206
|
* const notSchedule = { foo: "bar" }
|
|
248
207
|
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
208
|
+
* Schedule.isSchedule(schedule) // => true
|
|
209
|
+
* Schedule.isSchedule(notSchedule) // => false
|
|
210
|
+
* Schedule.isSchedule(null) // => false
|
|
211
|
+
* Schedule.isSchedule(undefined) // => false
|
|
253
212
|
* ```
|
|
254
213
|
*
|
|
255
214
|
* @category guards
|
|
@@ -262,7 +221,7 @@ export const isSchedule = (u: unknown): u is Schedule<unknown, never, unknown, u
|
|
|
262
221
|
*
|
|
263
222
|
* **Example** (Creating a custom schedule from a step function)
|
|
264
223
|
*
|
|
265
|
-
* ```ts
|
|
224
|
+
* ```ts import.meta.vitest
|
|
266
225
|
* import { Cause, Duration, Effect, Schedule } from "effect"
|
|
267
226
|
*
|
|
268
227
|
* const schedule = Schedule.fromStep(Effect.sync(() => {
|
|
@@ -275,6 +234,14 @@ export const isSchedule = (u: unknown): u is Schedule<unknown, never, unknown, u
|
|
|
275
234
|
* return Effect.succeed([count++, Duration.millis(100)] as [number, Duration.Duration])
|
|
276
235
|
* }
|
|
277
236
|
* }))
|
|
237
|
+
*
|
|
238
|
+
* const program = Effect.gen(function*() {
|
|
239
|
+
* const step = yield* Schedule.toStep(schedule)
|
|
240
|
+
* const [output] = yield* step(0, "input")
|
|
241
|
+
* return output
|
|
242
|
+
* })
|
|
243
|
+
*
|
|
244
|
+
* await Effect.runPromise(program) // => 0
|
|
278
245
|
* ```
|
|
279
246
|
*
|
|
280
247
|
* @category constructors
|
|
@@ -310,7 +277,7 @@ const metadataFn = () => {
|
|
|
310
277
|
*
|
|
311
278
|
* **Example** (Creating a metadata-aware schedule)
|
|
312
279
|
*
|
|
313
|
-
* ```ts
|
|
280
|
+
* ```ts import.meta.vitest
|
|
314
281
|
* import { Cause, Duration, Effect, Schedule } from "effect"
|
|
315
282
|
*
|
|
316
283
|
* const firstThreeInputs = Schedule.fromStepWithMetadata(Effect.succeed((metadata: Schedule.InputMetadata<string>) => {
|
|
@@ -323,6 +290,14 @@ const metadataFn = () => {
|
|
|
323
290
|
* Duration.millis(250)
|
|
324
291
|
* ] as [string, Duration.Duration])
|
|
325
292
|
* }))
|
|
293
|
+
*
|
|
294
|
+
* const program = Effect.gen(function*() {
|
|
295
|
+
* const step = yield* Schedule.toStep(firstThreeInputs)
|
|
296
|
+
* const [output] = yield* step(0, "input")
|
|
297
|
+
* return output
|
|
298
|
+
* })
|
|
299
|
+
*
|
|
300
|
+
* await Effect.runPromise(program) // => "attempt 1: input"
|
|
326
301
|
* ```
|
|
327
302
|
*
|
|
328
303
|
* @category constructors
|
|
@@ -345,8 +320,8 @@ export const fromStepWithMetadata = <Input, Output, EnvX, ErrorX, Error, Env>(
|
|
|
345
320
|
*
|
|
346
321
|
* **Example** (Extracting a schedule step function)
|
|
347
322
|
*
|
|
348
|
-
* ```ts
|
|
349
|
-
* import { Effect, Schedule } from "effect"
|
|
323
|
+
* ```ts import.meta.vitest
|
|
324
|
+
* import { Duration, Effect, Schedule } from "effect"
|
|
350
325
|
*
|
|
351
326
|
* // Extract step function from an existing schedule
|
|
352
327
|
* const schedule = Schedule.exponential("100 millis").pipe(Schedule.upTo({ times: 3 }))
|
|
@@ -357,10 +332,10 @@ export const fromStepWithMetadata = <Input, Output, EnvX, ErrorX, Error, Env>(
|
|
|
357
332
|
* // Use the step function directly for custom logic. The timestamp is
|
|
358
333
|
* // supplied by the caller, so tests can pass a deterministic value.
|
|
359
334
|
* const now = 0
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
-
* console.log(`Step result: ${result}`)
|
|
335
|
+
* return yield* stepFn(now, "input")
|
|
363
336
|
* })
|
|
337
|
+
*
|
|
338
|
+
* await Effect.runPromise(program) // => [Duration.millis(100), Duration.millis(100)]
|
|
364
339
|
* ```
|
|
365
340
|
*
|
|
366
341
|
* @category destructors
|
|
@@ -433,26 +408,19 @@ export const toStepWithMetadata = <Output, Input, Error, Env>(
|
|
|
433
408
|
*
|
|
434
409
|
* **Example** (Extracting a sleeping step function)
|
|
435
410
|
*
|
|
436
|
-
* ```ts
|
|
411
|
+
* ```ts import.meta.vitest
|
|
437
412
|
* import { Effect, Schedule } from "effect"
|
|
413
|
+
* import { TestClock } from "effect/testing"
|
|
438
414
|
*
|
|
439
|
-
*
|
|
440
|
-
* const schedule = Schedule.spaced("1 second").pipe(Schedule.upTo({ times: 3 }))
|
|
415
|
+
* const schedule = Schedule.recurs(3)
|
|
441
416
|
*
|
|
442
417
|
* const program = Effect.gen(function*() {
|
|
443
418
|
* const stepWithSleep = yield* Schedule.toStepWithSleep(schedule)
|
|
444
419
|
*
|
|
445
|
-
*
|
|
446
|
-
* console.log("Starting...")
|
|
447
|
-
* const result1 = yield* stepWithSleep("first")
|
|
448
|
-
* console.log(`First result: ${result1}`)
|
|
449
|
-
*
|
|
450
|
-
* const result2 = yield* stepWithSleep("second")
|
|
451
|
-
* console.log(`Second result: ${result2}`)
|
|
452
|
-
*
|
|
453
|
-
* const result3 = yield* stepWithSleep("third")
|
|
454
|
-
* console.log(`Third result: ${result3}`)
|
|
420
|
+
* return [yield* stepWithSleep("first"), yield* stepWithSleep("second")]
|
|
455
421
|
* })
|
|
422
|
+
*
|
|
423
|
+
* await Effect.runPromise(Effect.provide(program, TestClock.layer())) // => [0, 1]
|
|
456
424
|
* ```
|
|
457
425
|
*
|
|
458
426
|
* @category destructors
|
|
@@ -476,94 +444,19 @@ export const toStepWithSleep = <Output, Input, Error, Env>(
|
|
|
476
444
|
*
|
|
477
445
|
* **Example** (Adding extra delay to a schedule)
|
|
478
446
|
*
|
|
479
|
-
* ```ts
|
|
480
|
-
* import {
|
|
481
|
-
*
|
|
482
|
-
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
447
|
+
* ```ts import.meta.vitest
|
|
448
|
+
* import { Duration, Effect, Schedule } from "effect"
|
|
483
449
|
*
|
|
484
|
-
*
|
|
485
|
-
*
|
|
486
|
-
* Schedule.exponential("100 millis").pipe(Schedule.upTo({ times: 5 })),
|
|
487
|
-
* ({ output }) =>
|
|
488
|
-
* Effect.succeed(Duration.millis(Duration.toMillis(output) * 0.25))
|
|
489
|
-
* )
|
|
490
|
-
*
|
|
491
|
-
* const repeatProgram = Effect.gen(function*() {
|
|
492
|
-
* yield* Effect.repeat(
|
|
493
|
-
* Effect.succeed("delayed task"),
|
|
494
|
-
* delayedSchedule.pipe(
|
|
495
|
-
* Schedule.tap(({ output: delay }) =>
|
|
496
|
-
* Console.log(`Base delay: ${delay}`)
|
|
497
|
-
* )
|
|
498
|
-
* )
|
|
499
|
-
* )
|
|
500
|
-
* })
|
|
501
|
-
*
|
|
502
|
-
* // Add adaptive delay based on execution count
|
|
503
|
-
* const adaptiveSchedule = Schedule.addDelay(
|
|
504
|
-
* Schedule.recurs(6),
|
|
505
|
-
* ({ output: executionCount }) =>
|
|
506
|
-
* // Increase delay as execution count grows
|
|
507
|
-
* Effect.succeed(Duration.millis(executionCount * 200))
|
|
508
|
-
* )
|
|
509
|
-
*
|
|
510
|
-
* const adaptiveProgram = Effect.gen(function*() {
|
|
511
|
-
* yield* Effect.repeat(
|
|
512
|
-
* Effect.gen(function*() {
|
|
513
|
-
* yield* Console.log("Adaptive delay task")
|
|
514
|
-
* return "adaptive"
|
|
515
|
-
* }),
|
|
516
|
-
* adaptiveSchedule.pipe(
|
|
517
|
-
* Schedule.tap(({ output: count }) =>
|
|
518
|
-
* Console.log(`Execution ${count + 1} with adaptive delay`)
|
|
519
|
-
* )
|
|
520
|
-
* )
|
|
521
|
-
* )
|
|
522
|
-
* })
|
|
523
|
-
*
|
|
524
|
-
* // Add effectful delay computation from deterministic service data
|
|
525
|
-
* const loadByExecution = [1, 3, 2, 4] as const
|
|
526
|
-
*
|
|
527
|
-
* const dynamicSchedule = Schedule.addDelay(
|
|
528
|
-
* Schedule.spaced("1 second").pipe(Schedule.upTo({ times: 4 })),
|
|
529
|
-
* ({ output: executionNumber }) => {
|
|
530
|
-
* const load = loadByExecution[executionNumber] ?? 1
|
|
531
|
-
* return Effect.succeed(Duration.millis(load * 100))
|
|
532
|
-
* }
|
|
450
|
+
* const schedule = Schedule.recurs(1).pipe(
|
|
451
|
+
* Schedule.addDelay(() => Effect.succeed("25 millis"))
|
|
533
452
|
* )
|
|
534
|
-
*
|
|
535
|
-
*
|
|
536
|
-
* yield*
|
|
537
|
-
*
|
|
538
|
-
* yield* Console.log("Dynamic delay task")
|
|
539
|
-
* return "dynamic"
|
|
540
|
-
* }),
|
|
541
|
-
* dynamicSchedule
|
|
542
|
-
* )
|
|
453
|
+
* const program = Effect.gen(function*() {
|
|
454
|
+
* const step = yield* Schedule.toStep(schedule)
|
|
455
|
+
* const [, delay] = yield* step(0, undefined)
|
|
456
|
+
* return delay
|
|
543
457
|
* })
|
|
544
458
|
*
|
|
545
|
-
*
|
|
546
|
-
* const progressiveRetrySchedule = Schedule.addDelay(
|
|
547
|
-
* Schedule.exponential("50 millis").pipe(Schedule.upTo({ times: 4 })),
|
|
548
|
-
* () => Effect.succeed(Duration.millis(100)) // Fixed additional delay
|
|
549
|
-
* )
|
|
550
|
-
*
|
|
551
|
-
* const retryProgram = Effect.gen(function*() {
|
|
552
|
-
* let attempt = 0
|
|
553
|
-
*
|
|
554
|
-
* const result = yield* Effect.retry(
|
|
555
|
-
* Effect.gen(function*() {
|
|
556
|
-
* attempt++
|
|
557
|
-
* if (attempt < 5) {
|
|
558
|
-
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
559
|
-
* }
|
|
560
|
-
* return `Success on attempt ${attempt}`
|
|
561
|
-
* }),
|
|
562
|
-
* progressiveRetrySchedule
|
|
563
|
-
* )
|
|
564
|
-
*
|
|
565
|
-
* yield* Console.log(`Final result: ${result}`)
|
|
566
|
-
* })
|
|
459
|
+
* await Effect.runPromise(program) // => Duration.millis(25)
|
|
567
460
|
* ```
|
|
568
461
|
*
|
|
569
462
|
* @category delays & timeouts
|
|
@@ -576,94 +469,19 @@ export const addDelay: {
|
|
|
576
469
|
*
|
|
577
470
|
* **Example** (Adding extra delay to a schedule)
|
|
578
471
|
*
|
|
579
|
-
* ```ts
|
|
580
|
-
* import {
|
|
581
|
-
*
|
|
582
|
-
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
472
|
+
* ```ts import.meta.vitest
|
|
473
|
+
* import { Duration, Effect, Schedule } from "effect"
|
|
583
474
|
*
|
|
584
|
-
*
|
|
585
|
-
*
|
|
586
|
-
* Schedule.exponential("100 millis").pipe(Schedule.upTo({ times: 5 })),
|
|
587
|
-
* ({ output }) =>
|
|
588
|
-
* Effect.succeed(Duration.millis(Duration.toMillis(output) * 0.25))
|
|
475
|
+
* const schedule = Schedule.recurs(1).pipe(
|
|
476
|
+
* Schedule.addDelay(() => Effect.succeed("25 millis"))
|
|
589
477
|
* )
|
|
590
|
-
*
|
|
591
|
-
*
|
|
592
|
-
* yield*
|
|
593
|
-
*
|
|
594
|
-
* delayedSchedule.pipe(
|
|
595
|
-
* Schedule.tap(({ output: delay }) =>
|
|
596
|
-
* Console.log(`Base delay: ${delay}`)
|
|
597
|
-
* )
|
|
598
|
-
* )
|
|
599
|
-
* )
|
|
600
|
-
* })
|
|
601
|
-
*
|
|
602
|
-
* // Add adaptive delay based on execution count
|
|
603
|
-
* const adaptiveSchedule = Schedule.addDelay(
|
|
604
|
-
* Schedule.recurs(6),
|
|
605
|
-
* ({ output: executionCount }) =>
|
|
606
|
-
* // Increase delay as execution count grows
|
|
607
|
-
* Effect.succeed(Duration.millis(executionCount * 200))
|
|
608
|
-
* )
|
|
609
|
-
*
|
|
610
|
-
* const adaptiveProgram = Effect.gen(function*() {
|
|
611
|
-
* yield* Effect.repeat(
|
|
612
|
-
* Effect.gen(function*() {
|
|
613
|
-
* yield* Console.log("Adaptive delay task")
|
|
614
|
-
* return "adaptive"
|
|
615
|
-
* }),
|
|
616
|
-
* adaptiveSchedule.pipe(
|
|
617
|
-
* Schedule.tap(({ output: count }) =>
|
|
618
|
-
* Console.log(`Execution ${count + 1} with adaptive delay`)
|
|
619
|
-
* )
|
|
620
|
-
* )
|
|
621
|
-
* )
|
|
622
|
-
* })
|
|
623
|
-
*
|
|
624
|
-
* // Add effectful delay computation from deterministic service data
|
|
625
|
-
* const loadByExecution = [1, 3, 2, 4] as const
|
|
626
|
-
*
|
|
627
|
-
* const dynamicSchedule = Schedule.addDelay(
|
|
628
|
-
* Schedule.spaced("1 second").pipe(Schedule.upTo({ times: 4 })),
|
|
629
|
-
* ({ output: executionNumber }) => {
|
|
630
|
-
* const load = loadByExecution[executionNumber] ?? 1
|
|
631
|
-
* return Effect.succeed(Duration.millis(load * 100))
|
|
632
|
-
* }
|
|
633
|
-
* )
|
|
634
|
-
*
|
|
635
|
-
* const dynamicProgram = Effect.gen(function*() {
|
|
636
|
-
* yield* Effect.repeat(
|
|
637
|
-
* Effect.gen(function*() {
|
|
638
|
-
* yield* Console.log("Dynamic delay task")
|
|
639
|
-
* return "dynamic"
|
|
640
|
-
* }),
|
|
641
|
-
* dynamicSchedule
|
|
642
|
-
* )
|
|
478
|
+
* const program = Effect.gen(function*() {
|
|
479
|
+
* const step = yield* Schedule.toStep(schedule)
|
|
480
|
+
* const [, delay] = yield* step(0, undefined)
|
|
481
|
+
* return delay
|
|
643
482
|
* })
|
|
644
483
|
*
|
|
645
|
-
*
|
|
646
|
-
* const progressiveRetrySchedule = Schedule.addDelay(
|
|
647
|
-
* Schedule.exponential("50 millis").pipe(Schedule.upTo({ times: 4 })),
|
|
648
|
-
* () => Effect.succeed(Duration.millis(100)) // Fixed additional delay
|
|
649
|
-
* )
|
|
650
|
-
*
|
|
651
|
-
* const retryProgram = Effect.gen(function*() {
|
|
652
|
-
* let attempt = 0
|
|
653
|
-
*
|
|
654
|
-
* const result = yield* Effect.retry(
|
|
655
|
-
* Effect.gen(function*() {
|
|
656
|
-
* attempt++
|
|
657
|
-
* if (attempt < 5) {
|
|
658
|
-
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
659
|
-
* }
|
|
660
|
-
* return `Success on attempt ${attempt}`
|
|
661
|
-
* }),
|
|
662
|
-
* progressiveRetrySchedule
|
|
663
|
-
* )
|
|
664
|
-
*
|
|
665
|
-
* yield* Console.log(`Final result: ${result}`)
|
|
666
|
-
* })
|
|
484
|
+
* await Effect.runPromise(program) // => Duration.millis(25)
|
|
667
485
|
* ```
|
|
668
486
|
*
|
|
669
487
|
* @category delays & timeouts
|
|
@@ -680,94 +498,19 @@ export const addDelay: {
|
|
|
680
498
|
*
|
|
681
499
|
* **Example** (Adding extra delay to a schedule)
|
|
682
500
|
*
|
|
683
|
-
* ```ts
|
|
684
|
-
* import {
|
|
685
|
-
*
|
|
686
|
-
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
501
|
+
* ```ts import.meta.vitest
|
|
502
|
+
* import { Duration, Effect, Schedule } from "effect"
|
|
687
503
|
*
|
|
688
|
-
*
|
|
689
|
-
*
|
|
690
|
-
* Schedule.exponential("100 millis").pipe(Schedule.upTo({ times: 5 })),
|
|
691
|
-
* ({ output }) =>
|
|
692
|
-
* Effect.succeed(Duration.millis(Duration.toMillis(output) * 0.25))
|
|
504
|
+
* const schedule = Schedule.recurs(1).pipe(
|
|
505
|
+
* Schedule.addDelay(() => Effect.succeed("25 millis"))
|
|
693
506
|
* )
|
|
694
|
-
*
|
|
695
|
-
*
|
|
696
|
-
* yield*
|
|
697
|
-
*
|
|
698
|
-
* delayedSchedule.pipe(
|
|
699
|
-
* Schedule.tap(({ output: delay }) =>
|
|
700
|
-
* Console.log(`Base delay: ${delay}`)
|
|
701
|
-
* )
|
|
702
|
-
* )
|
|
703
|
-
* )
|
|
704
|
-
* })
|
|
705
|
-
*
|
|
706
|
-
* // Add adaptive delay based on execution count
|
|
707
|
-
* const adaptiveSchedule = Schedule.addDelay(
|
|
708
|
-
* Schedule.recurs(6),
|
|
709
|
-
* ({ output: executionCount }) =>
|
|
710
|
-
* // Increase delay as execution count grows
|
|
711
|
-
* Effect.succeed(Duration.millis(executionCount * 200))
|
|
712
|
-
* )
|
|
713
|
-
*
|
|
714
|
-
* const adaptiveProgram = Effect.gen(function*() {
|
|
715
|
-
* yield* Effect.repeat(
|
|
716
|
-
* Effect.gen(function*() {
|
|
717
|
-
* yield* Console.log("Adaptive delay task")
|
|
718
|
-
* return "adaptive"
|
|
719
|
-
* }),
|
|
720
|
-
* adaptiveSchedule.pipe(
|
|
721
|
-
* Schedule.tap(({ output: count }) =>
|
|
722
|
-
* Console.log(`Execution ${count + 1} with adaptive delay`)
|
|
723
|
-
* )
|
|
724
|
-
* )
|
|
725
|
-
* )
|
|
726
|
-
* })
|
|
727
|
-
*
|
|
728
|
-
* // Add effectful delay computation from deterministic service data
|
|
729
|
-
* const loadByExecution = [1, 3, 2, 4] as const
|
|
730
|
-
*
|
|
731
|
-
* const dynamicSchedule = Schedule.addDelay(
|
|
732
|
-
* Schedule.spaced("1 second").pipe(Schedule.upTo({ times: 4 })),
|
|
733
|
-
* ({ output: executionNumber }) => {
|
|
734
|
-
* const load = loadByExecution[executionNumber] ?? 1
|
|
735
|
-
* return Effect.succeed(Duration.millis(load * 100))
|
|
736
|
-
* }
|
|
737
|
-
* )
|
|
738
|
-
*
|
|
739
|
-
* const dynamicProgram = Effect.gen(function*() {
|
|
740
|
-
* yield* Effect.repeat(
|
|
741
|
-
* Effect.gen(function*() {
|
|
742
|
-
* yield* Console.log("Dynamic delay task")
|
|
743
|
-
* return "dynamic"
|
|
744
|
-
* }),
|
|
745
|
-
* dynamicSchedule
|
|
746
|
-
* )
|
|
507
|
+
* const program = Effect.gen(function*() {
|
|
508
|
+
* const step = yield* Schedule.toStep(schedule)
|
|
509
|
+
* const [, delay] = yield* step(0, undefined)
|
|
510
|
+
* return delay
|
|
747
511
|
* })
|
|
748
512
|
*
|
|
749
|
-
*
|
|
750
|
-
* const progressiveRetrySchedule = Schedule.addDelay(
|
|
751
|
-
* Schedule.exponential("50 millis").pipe(Schedule.upTo({ times: 4 })),
|
|
752
|
-
* () => Effect.succeed(Duration.millis(100)) // Fixed additional delay
|
|
753
|
-
* )
|
|
754
|
-
*
|
|
755
|
-
* const retryProgram = Effect.gen(function*() {
|
|
756
|
-
* let attempt = 0
|
|
757
|
-
*
|
|
758
|
-
* const result = yield* Effect.retry(
|
|
759
|
-
* Effect.gen(function*() {
|
|
760
|
-
* attempt++
|
|
761
|
-
* if (attempt < 5) {
|
|
762
|
-
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
763
|
-
* }
|
|
764
|
-
* return `Success on attempt ${attempt}`
|
|
765
|
-
* }),
|
|
766
|
-
* progressiveRetrySchedule
|
|
767
|
-
* )
|
|
768
|
-
*
|
|
769
|
-
* yield* Console.log(`Final result: ${result}`)
|
|
770
|
-
* })
|
|
513
|
+
* await Effect.runPromise(program) // => Duration.millis(25)
|
|
771
514
|
* ```
|
|
772
515
|
*
|
|
773
516
|
* @category delays & timeouts
|
|
@@ -792,35 +535,11 @@ export const addDelay: {
|
|
|
792
535
|
*
|
|
793
536
|
* **Example** (Sequencing quick and slow retries)
|
|
794
537
|
*
|
|
795
|
-
* ```ts
|
|
796
|
-
* import {
|
|
797
|
-
*
|
|
798
|
-
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
799
|
-
*
|
|
800
|
-
* // First retry 3 times quickly, then switch to slower retries
|
|
801
|
-
* const quickRetries = Schedule.exponential("100 millis").pipe(
|
|
802
|
-
* Schedule.upTo({ times: 3 })
|
|
803
|
-
* )
|
|
804
|
-
* const slowRetries = Schedule.exponential("1 second").pipe(
|
|
805
|
-
* Schedule.upTo({ times: 2 })
|
|
806
|
-
* )
|
|
807
|
-
*
|
|
808
|
-
* const combinedRetries = Schedule.andThen(quickRetries, slowRetries)
|
|
538
|
+
* ```ts import.meta.vitest
|
|
539
|
+
* import { Schedule } from "effect"
|
|
809
540
|
*
|
|
810
|
-
* const
|
|
811
|
-
*
|
|
812
|
-
* yield* Effect.retry(
|
|
813
|
-
* Effect.gen(function*() {
|
|
814
|
-
* attempt++
|
|
815
|
-
* yield* Console.log(`Attempt ${attempt}`)
|
|
816
|
-
* if (attempt < 6) {
|
|
817
|
-
* return yield* Effect.fail(new RetryAttemptError({ message: `Failure ${attempt}` }))
|
|
818
|
-
* }
|
|
819
|
-
* return `Success on attempt ${attempt}`
|
|
820
|
-
* }),
|
|
821
|
-
* combinedRetries
|
|
822
|
-
* )
|
|
823
|
-
* })
|
|
541
|
+
* const schedule = Schedule.andThen(Schedule.recurs(1), Schedule.recurs(2))
|
|
542
|
+
* Schedule.isSchedule(schedule) // => true
|
|
824
543
|
* ```
|
|
825
544
|
*
|
|
826
545
|
* @category sequencing
|
|
@@ -833,35 +552,11 @@ export const andThen: {
|
|
|
833
552
|
*
|
|
834
553
|
* **Example** (Sequencing quick and slow retries)
|
|
835
554
|
*
|
|
836
|
-
* ```ts
|
|
837
|
-
* import {
|
|
838
|
-
*
|
|
839
|
-
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
840
|
-
*
|
|
841
|
-
* // First retry 3 times quickly, then switch to slower retries
|
|
842
|
-
* const quickRetries = Schedule.exponential("100 millis").pipe(
|
|
843
|
-
* Schedule.upTo({ times: 3 })
|
|
844
|
-
* )
|
|
845
|
-
* const slowRetries = Schedule.exponential("1 second").pipe(
|
|
846
|
-
* Schedule.upTo({ times: 2 })
|
|
847
|
-
* )
|
|
848
|
-
*
|
|
849
|
-
* const combinedRetries = Schedule.andThen(quickRetries, slowRetries)
|
|
555
|
+
* ```ts import.meta.vitest
|
|
556
|
+
* import { Schedule } from "effect"
|
|
850
557
|
*
|
|
851
|
-
* const
|
|
852
|
-
*
|
|
853
|
-
* yield* Effect.retry(
|
|
854
|
-
* Effect.gen(function*() {
|
|
855
|
-
* attempt++
|
|
856
|
-
* yield* Console.log(`Attempt ${attempt}`)
|
|
857
|
-
* if (attempt < 6) {
|
|
858
|
-
* return yield* Effect.fail(new RetryAttemptError({ message: `Failure ${attempt}` }))
|
|
859
|
-
* }
|
|
860
|
-
* return `Success on attempt ${attempt}`
|
|
861
|
-
* }),
|
|
862
|
-
* combinedRetries
|
|
863
|
-
* )
|
|
864
|
-
* })
|
|
558
|
+
* const schedule = Schedule.andThen(Schedule.recurs(1), Schedule.recurs(2))
|
|
559
|
+
* Schedule.isSchedule(schedule) // => true
|
|
865
560
|
* ```
|
|
866
561
|
*
|
|
867
562
|
* @category sequencing
|
|
@@ -876,35 +571,11 @@ export const andThen: {
|
|
|
876
571
|
*
|
|
877
572
|
* **Example** (Sequencing quick and slow retries)
|
|
878
573
|
*
|
|
879
|
-
* ```ts
|
|
880
|
-
* import {
|
|
881
|
-
*
|
|
882
|
-
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
574
|
+
* ```ts import.meta.vitest
|
|
575
|
+
* import { Schedule } from "effect"
|
|
883
576
|
*
|
|
884
|
-
*
|
|
885
|
-
*
|
|
886
|
-
* Schedule.upTo({ times: 3 })
|
|
887
|
-
* )
|
|
888
|
-
* const slowRetries = Schedule.exponential("1 second").pipe(
|
|
889
|
-
* Schedule.upTo({ times: 2 })
|
|
890
|
-
* )
|
|
891
|
-
*
|
|
892
|
-
* const combinedRetries = Schedule.andThen(quickRetries, slowRetries)
|
|
893
|
-
*
|
|
894
|
-
* const program = Effect.gen(function*() {
|
|
895
|
-
* let attempt = 0
|
|
896
|
-
* yield* Effect.retry(
|
|
897
|
-
* Effect.gen(function*() {
|
|
898
|
-
* attempt++
|
|
899
|
-
* yield* Console.log(`Attempt ${attempt}`)
|
|
900
|
-
* if (attempt < 6) {
|
|
901
|
-
* return yield* Effect.fail(new RetryAttemptError({ message: `Failure ${attempt}` }))
|
|
902
|
-
* }
|
|
903
|
-
* return `Success on attempt ${attempt}`
|
|
904
|
-
* }),
|
|
905
|
-
* combinedRetries
|
|
906
|
-
* )
|
|
907
|
-
* })
|
|
577
|
+
* const schedule = Schedule.andThen(Schedule.recurs(1), Schedule.recurs(2))
|
|
578
|
+
* Schedule.isSchedule(schedule) // => true
|
|
908
579
|
* ```
|
|
909
580
|
*
|
|
910
581
|
* @category sequencing
|
|
@@ -932,31 +603,11 @@ export const andThen: {
|
|
|
932
603
|
*
|
|
933
604
|
* **Example** (Tracking sequential schedule phases)
|
|
934
605
|
*
|
|
935
|
-
* ```ts
|
|
936
|
-
* import {
|
|
937
|
-
*
|
|
938
|
-
* // Track which phase of the schedule we're in
|
|
939
|
-
* const phaseTracker = Schedule.andThenResult(
|
|
940
|
-
* Schedule.exponential("100 millis").pipe(Schedule.upTo({ times: 2 })),
|
|
941
|
-
* Schedule.spaced("500 millis").pipe(Schedule.upTo({ times: 2 }))
|
|
942
|
-
* )
|
|
606
|
+
* ```ts import.meta.vitest
|
|
607
|
+
* import { Schedule } from "effect"
|
|
943
608
|
*
|
|
944
|
-
* const
|
|
945
|
-
*
|
|
946
|
-
* Effect.gen(function*() {
|
|
947
|
-
* yield* Console.log("Task executed")
|
|
948
|
-
* return "task-result"
|
|
949
|
-
* }),
|
|
950
|
-
* phaseTracker.pipe(
|
|
951
|
-
* Schedule.tap(({ output: result }) =>
|
|
952
|
-
* Result.match(result, {
|
|
953
|
-
* onFailure: (phase1Output) => Console.log(`Phase 1: ${phase1Output}`),
|
|
954
|
-
* onSuccess: (phase2Output) => Console.log(`Phase 2: ${phase2Output}`)
|
|
955
|
-
* })
|
|
956
|
-
* )
|
|
957
|
-
* )
|
|
958
|
-
* )
|
|
959
|
-
* })
|
|
609
|
+
* const schedule = Schedule.andThenResult(Schedule.recurs(1), Schedule.recurs(2))
|
|
610
|
+
* Schedule.isSchedule(schedule) // => true
|
|
960
611
|
* ```
|
|
961
612
|
*
|
|
962
613
|
* @category sequencing
|
|
@@ -975,31 +626,11 @@ export const andThenResult: {
|
|
|
975
626
|
*
|
|
976
627
|
* **Example** (Tracking sequential schedule phases)
|
|
977
628
|
*
|
|
978
|
-
* ```ts
|
|
979
|
-
* import {
|
|
980
|
-
*
|
|
981
|
-
* // Track which phase of the schedule we're in
|
|
982
|
-
* const phaseTracker = Schedule.andThenResult(
|
|
983
|
-
* Schedule.exponential("100 millis").pipe(Schedule.upTo({ times: 2 })),
|
|
984
|
-
* Schedule.spaced("500 millis").pipe(Schedule.upTo({ times: 2 }))
|
|
985
|
-
* )
|
|
629
|
+
* ```ts import.meta.vitest
|
|
630
|
+
* import { Schedule } from "effect"
|
|
986
631
|
*
|
|
987
|
-
* const
|
|
988
|
-
*
|
|
989
|
-
* Effect.gen(function*() {
|
|
990
|
-
* yield* Console.log("Task executed")
|
|
991
|
-
* return "task-result"
|
|
992
|
-
* }),
|
|
993
|
-
* phaseTracker.pipe(
|
|
994
|
-
* Schedule.tap(({ output: result }) =>
|
|
995
|
-
* Result.match(result, {
|
|
996
|
-
* onFailure: (phase1Output) => Console.log(`Phase 1: ${phase1Output}`),
|
|
997
|
-
* onSuccess: (phase2Output) => Console.log(`Phase 2: ${phase2Output}`)
|
|
998
|
-
* })
|
|
999
|
-
* )
|
|
1000
|
-
* )
|
|
1001
|
-
* )
|
|
1002
|
-
* })
|
|
632
|
+
* const schedule = Schedule.andThenResult(Schedule.recurs(1), Schedule.recurs(2))
|
|
633
|
+
* Schedule.isSchedule(schedule) // => true
|
|
1003
634
|
* ```
|
|
1004
635
|
*
|
|
1005
636
|
* @category sequencing
|
|
@@ -1020,31 +651,11 @@ export const andThenResult: {
|
|
|
1020
651
|
*
|
|
1021
652
|
* **Example** (Tracking sequential schedule phases)
|
|
1022
653
|
*
|
|
1023
|
-
* ```ts
|
|
1024
|
-
* import {
|
|
654
|
+
* ```ts import.meta.vitest
|
|
655
|
+
* import { Schedule } from "effect"
|
|
1025
656
|
*
|
|
1026
|
-
*
|
|
1027
|
-
*
|
|
1028
|
-
* Schedule.exponential("100 millis").pipe(Schedule.upTo({ times: 2 })),
|
|
1029
|
-
* Schedule.spaced("500 millis").pipe(Schedule.upTo({ times: 2 }))
|
|
1030
|
-
* )
|
|
1031
|
-
*
|
|
1032
|
-
* const program = Effect.gen(function*() {
|
|
1033
|
-
* yield* Effect.repeat(
|
|
1034
|
-
* Effect.gen(function*() {
|
|
1035
|
-
* yield* Console.log("Task executed")
|
|
1036
|
-
* return "task-result"
|
|
1037
|
-
* }),
|
|
1038
|
-
* phaseTracker.pipe(
|
|
1039
|
-
* Schedule.tap(({ output: result }) =>
|
|
1040
|
-
* Result.match(result, {
|
|
1041
|
-
* onFailure: (phase1Output) => Console.log(`Phase 1: ${phase1Output}`),
|
|
1042
|
-
* onSuccess: (phase2Output) => Console.log(`Phase 2: ${phase2Output}`)
|
|
1043
|
-
* })
|
|
1044
|
-
* )
|
|
1045
|
-
* )
|
|
1046
|
-
* )
|
|
1047
|
-
* })
|
|
657
|
+
* const schedule = Schedule.andThenResult(Schedule.recurs(1), Schedule.recurs(2))
|
|
658
|
+
* Schedule.isSchedule(schedule) // => true
|
|
1048
659
|
* ```
|
|
1049
660
|
*
|
|
1050
661
|
* @category sequencing
|
|
@@ -1093,31 +704,11 @@ export const andThenResult: {
|
|
|
1093
704
|
*
|
|
1094
705
|
* **Example** (Tracking sequential schedule phases)
|
|
1095
706
|
*
|
|
1096
|
-
* ```ts
|
|
1097
|
-
* import {
|
|
1098
|
-
*
|
|
1099
|
-
* // Track which phase of the schedule we're in
|
|
1100
|
-
* const phaseTracker = Schedule.andThenResult(
|
|
1101
|
-
* Schedule.exponential("100 millis").pipe(Schedule.upTo({ times: 2 })),
|
|
1102
|
-
* Schedule.spaced("500 millis").pipe(Schedule.upTo({ times: 2 }))
|
|
1103
|
-
* )
|
|
707
|
+
* ```ts import.meta.vitest
|
|
708
|
+
* import { Schedule } from "effect"
|
|
1104
709
|
*
|
|
1105
|
-
* const
|
|
1106
|
-
*
|
|
1107
|
-
* Effect.gen(function*() {
|
|
1108
|
-
* yield* Console.log("Task executed")
|
|
1109
|
-
* return "task-result"
|
|
1110
|
-
* }),
|
|
1111
|
-
* phaseTracker.pipe(
|
|
1112
|
-
* Schedule.tap(({ output: result }) =>
|
|
1113
|
-
* Result.match(result, {
|
|
1114
|
-
* onFailure: (phase1Output) => Console.log(`Phase 1: ${phase1Output}`),
|
|
1115
|
-
* onSuccess: (phase2Output) => Console.log(`Phase 2: ${phase2Output}`)
|
|
1116
|
-
* })
|
|
1117
|
-
* )
|
|
1118
|
-
* )
|
|
1119
|
-
* )
|
|
1120
|
-
* })
|
|
710
|
+
* const schedule = Schedule.andThenResult(Schedule.recurs(1), Schedule.recurs(2))
|
|
711
|
+
* Schedule.isSchedule(schedule) // => true
|
|
1121
712
|
* ```
|
|
1122
713
|
*
|
|
1123
714
|
* @category sequencing
|
|
@@ -1136,31 +727,11 @@ export const andThenResult: {
|
|
|
1136
727
|
*
|
|
1137
728
|
* **Example** (Tracking sequential schedule phases)
|
|
1138
729
|
*
|
|
1139
|
-
* ```ts
|
|
1140
|
-
* import {
|
|
1141
|
-
*
|
|
1142
|
-
* // Track which phase of the schedule we're in
|
|
1143
|
-
* const phaseTracker = Schedule.andThenResult(
|
|
1144
|
-
* Schedule.exponential("100 millis").pipe(Schedule.upTo({ times: 2 })),
|
|
1145
|
-
* Schedule.spaced("500 millis").pipe(Schedule.upTo({ times: 2 }))
|
|
1146
|
-
* )
|
|
730
|
+
* ```ts import.meta.vitest
|
|
731
|
+
* import { Schedule } from "effect"
|
|
1147
732
|
*
|
|
1148
|
-
* const
|
|
1149
|
-
*
|
|
1150
|
-
* Effect.gen(function*() {
|
|
1151
|
-
* yield* Console.log("Task executed")
|
|
1152
|
-
* return "task-result"
|
|
1153
|
-
* }),
|
|
1154
|
-
* phaseTracker.pipe(
|
|
1155
|
-
* Schedule.tap(({ output: result }) =>
|
|
1156
|
-
* Result.match(result, {
|
|
1157
|
-
* onFailure: (phase1Output) => Console.log(`Phase 1: ${phase1Output}`),
|
|
1158
|
-
* onSuccess: (phase2Output) => Console.log(`Phase 2: ${phase2Output}`)
|
|
1159
|
-
* })
|
|
1160
|
-
* )
|
|
1161
|
-
* )
|
|
1162
|
-
* )
|
|
1163
|
-
* })
|
|
733
|
+
* const schedule = Schedule.andThenResult(Schedule.recurs(1), Schedule.recurs(2))
|
|
734
|
+
* Schedule.isSchedule(schedule) // => true
|
|
1164
735
|
* ```
|
|
1165
736
|
*
|
|
1166
737
|
* @category sequencing
|
|
@@ -1179,31 +750,11 @@ export const andThenResult: {
|
|
|
1179
750
|
*
|
|
1180
751
|
* **Example** (Tracking sequential schedule phases)
|
|
1181
752
|
*
|
|
1182
|
-
* ```ts
|
|
1183
|
-
* import {
|
|
753
|
+
* ```ts import.meta.vitest
|
|
754
|
+
* import { Schedule } from "effect"
|
|
1184
755
|
*
|
|
1185
|
-
*
|
|
1186
|
-
*
|
|
1187
|
-
* Schedule.exponential("100 millis").pipe(Schedule.upTo({ times: 2 })),
|
|
1188
|
-
* Schedule.spaced("500 millis").pipe(Schedule.upTo({ times: 2 }))
|
|
1189
|
-
* )
|
|
1190
|
-
*
|
|
1191
|
-
* const program = Effect.gen(function*() {
|
|
1192
|
-
* yield* Effect.repeat(
|
|
1193
|
-
* Effect.gen(function*() {
|
|
1194
|
-
* yield* Console.log("Task executed")
|
|
1195
|
-
* return "task-result"
|
|
1196
|
-
* }),
|
|
1197
|
-
* phaseTracker.pipe(
|
|
1198
|
-
* Schedule.tap(({ output: result }) =>
|
|
1199
|
-
* Result.match(result, {
|
|
1200
|
-
* onFailure: (phase1Output) => Console.log(`Phase 1: ${phase1Output}`),
|
|
1201
|
-
* onSuccess: (phase2Output) => Console.log(`Phase 2: ${phase2Output}`)
|
|
1202
|
-
* })
|
|
1203
|
-
* )
|
|
1204
|
-
* )
|
|
1205
|
-
* )
|
|
1206
|
-
* })
|
|
756
|
+
* const schedule = Schedule.andThenResult(Schedule.recurs(1), Schedule.recurs(2))
|
|
757
|
+
* Schedule.isSchedule(schedule) // => true
|
|
1207
758
|
* ```
|
|
1208
759
|
*
|
|
1209
760
|
* @category sequencing
|
|
@@ -1222,31 +773,11 @@ export const andThenResult: {
|
|
|
1222
773
|
*
|
|
1223
774
|
* **Example** (Tracking sequential schedule phases)
|
|
1224
775
|
*
|
|
1225
|
-
* ```ts
|
|
1226
|
-
* import {
|
|
1227
|
-
*
|
|
1228
|
-
* // Track which phase of the schedule we're in
|
|
1229
|
-
* const phaseTracker = Schedule.andThenResult(
|
|
1230
|
-
* Schedule.exponential("100 millis").pipe(Schedule.upTo({ times: 2 })),
|
|
1231
|
-
* Schedule.spaced("500 millis").pipe(Schedule.upTo({ times: 2 }))
|
|
1232
|
-
* )
|
|
776
|
+
* ```ts import.meta.vitest
|
|
777
|
+
* import { Schedule } from "effect"
|
|
1233
778
|
*
|
|
1234
|
-
* const
|
|
1235
|
-
*
|
|
1236
|
-
* Effect.gen(function*() {
|
|
1237
|
-
* yield* Console.log("Task executed")
|
|
1238
|
-
* return "task-result"
|
|
1239
|
-
* }),
|
|
1240
|
-
* phaseTracker.pipe(
|
|
1241
|
-
* Schedule.tap(({ output: result }) =>
|
|
1242
|
-
* Result.match(result, {
|
|
1243
|
-
* onFailure: (phase1Output) => Console.log(`Phase 1: ${phase1Output}`),
|
|
1244
|
-
* onSuccess: (phase2Output) => Console.log(`Phase 2: ${phase2Output}`)
|
|
1245
|
-
* })
|
|
1246
|
-
* )
|
|
1247
|
-
* )
|
|
1248
|
-
* )
|
|
1249
|
-
* })
|
|
779
|
+
* const schedule = Schedule.andThenResult(Schedule.recurs(1), Schedule.recurs(2))
|
|
780
|
+
* Schedule.isSchedule(schedule) // => true
|
|
1250
781
|
* ```
|
|
1251
782
|
*
|
|
1252
783
|
* @category sequencing
|
|
@@ -1282,36 +813,11 @@ export const andThenResult: {
|
|
|
1282
813
|
*
|
|
1283
814
|
* **Example** (Combining retry schedules by their maximum delay)
|
|
1284
815
|
*
|
|
1285
|
-
* ```ts
|
|
1286
|
-
* import {
|
|
1287
|
-
*
|
|
1288
|
-
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
1289
|
-
*
|
|
1290
|
-
* const retrySchedule = Schedule.max([
|
|
1291
|
-
* Schedule.fixed("5 seconds"),
|
|
1292
|
-
* Schedule.exponential("5 seconds"),
|
|
1293
|
-
* Schedule.spaced("10 seconds")
|
|
1294
|
-
* ])
|
|
816
|
+
* ```ts import.meta.vitest
|
|
817
|
+
* import { Schedule } from "effect"
|
|
1295
818
|
*
|
|
1296
|
-
* const
|
|
1297
|
-
*
|
|
1298
|
-
*
|
|
1299
|
-
* yield* Effect.retry(
|
|
1300
|
-
* Effect.gen(function*() {
|
|
1301
|
-
* attempt++
|
|
1302
|
-
* yield* Console.log(`Retry attempt ${attempt}`)
|
|
1303
|
-
* if (attempt < 3) {
|
|
1304
|
-
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
1305
|
-
* }
|
|
1306
|
-
* return "success"
|
|
1307
|
-
* }),
|
|
1308
|
-
* retrySchedule.pipe(
|
|
1309
|
-
* Schedule.tap(({ output: duration }) =>
|
|
1310
|
-
* Console.log(`Waiting for the slowest schedule: ${duration}`)
|
|
1311
|
-
* )
|
|
1312
|
-
* )
|
|
1313
|
-
* )
|
|
1314
|
-
* })
|
|
819
|
+
* const schedule = Schedule.max([Schedule.fixed("5 seconds"), Schedule.spaced("10 seconds")])
|
|
820
|
+
* Schedule.isSchedule(schedule) // => true
|
|
1315
821
|
* ```
|
|
1316
822
|
*
|
|
1317
823
|
* @category combining
|
|
@@ -1367,126 +873,11 @@ const maxDuration = (results: ReadonlyArray<Duration.Duration | undefined>): Dur
|
|
|
1367
873
|
*
|
|
1368
874
|
* **Example** (Scheduling work with cron expressions)
|
|
1369
875
|
*
|
|
1370
|
-
* ```ts
|
|
1371
|
-
* import {
|
|
1372
|
-
*
|
|
1373
|
-
* class ScheduledTaskError extends Data.TaggedError("ScheduledTaskError")<{ readonly message: string }> {}
|
|
876
|
+
* ```ts import.meta.vitest
|
|
877
|
+
* import { Schedule } from "effect"
|
|
1374
878
|
*
|
|
1375
|
-
* // Run every minute
|
|
1376
879
|
* const everyMinute = Schedule.cron("* * * * *")
|
|
1377
|
-
*
|
|
1378
|
-
* const minutelyProgram = Effect.gen(function*() {
|
|
1379
|
-
* yield* Effect.repeat(
|
|
1380
|
-
* Effect.gen(function*() {
|
|
1381
|
-
* yield* Console.log("Running minutely task")
|
|
1382
|
-
* return "minute"
|
|
1383
|
-
* }),
|
|
1384
|
-
* everyMinute.pipe(
|
|
1385
|
-
* Schedule.upTo({ times: 3 }), // Run only 3 times for demo
|
|
1386
|
-
* Schedule.tap(({ output: duration }) =>
|
|
1387
|
-
* Console.log(`Next execution in: ${duration}`)
|
|
1388
|
-
* )
|
|
1389
|
-
* )
|
|
1390
|
-
* )
|
|
1391
|
-
* })
|
|
1392
|
-
*
|
|
1393
|
-
* // Run every day at 2:30 AM
|
|
1394
|
-
* const dailyBackup = Schedule.cron("30 2 * * *")
|
|
1395
|
-
*
|
|
1396
|
-
* const backupProgram = Effect.gen(function*() {
|
|
1397
|
-
* yield* Effect.repeat(
|
|
1398
|
-
* Effect.gen(function*() {
|
|
1399
|
-
* yield* Console.log("Running daily backup...")
|
|
1400
|
-
* // Simulate backup process
|
|
1401
|
-
* yield* Effect.sleep("2 seconds")
|
|
1402
|
-
* yield* Console.log("Backup completed")
|
|
1403
|
-
* return "backup-done"
|
|
1404
|
-
* }),
|
|
1405
|
-
* dailyBackup.pipe(
|
|
1406
|
-
* Schedule.upTo({ times: 2 }) // Run 2 times for demo
|
|
1407
|
-
* )
|
|
1408
|
-
* )
|
|
1409
|
-
* })
|
|
1410
|
-
*
|
|
1411
|
-
* // Run every Monday at 9:00 AM with timezone
|
|
1412
|
-
* const weeklyReport = Schedule.cron("0 9 * * 1", "America/New_York")
|
|
1413
|
-
*
|
|
1414
|
-
* const reportProgram = Effect.gen(function*() {
|
|
1415
|
-
* yield* Effect.repeat(
|
|
1416
|
-
* Effect.gen(function*() {
|
|
1417
|
-
* yield* Console.log("Generating weekly report...")
|
|
1418
|
-
* const report = {
|
|
1419
|
-
* week: 42,
|
|
1420
|
-
* status: "ready" as const
|
|
1421
|
-
* }
|
|
1422
|
-
* yield* Console.log(`Report generated: ${JSON.stringify(report)}`)
|
|
1423
|
-
* return report
|
|
1424
|
-
* }),
|
|
1425
|
-
* weeklyReport.pipe(Schedule.upTo({ times: 1 }))
|
|
1426
|
-
* )
|
|
1427
|
-
* })
|
|
1428
|
-
*
|
|
1429
|
-
* // Run every 15 minutes during business hours (9 AM - 5 PM)
|
|
1430
|
-
* const businessHoursCheck = Schedule.cron("0,15,30,45 9-17 * * 1-5")
|
|
1431
|
-
*
|
|
1432
|
-
* const businessProgram = Effect.gen(function*() {
|
|
1433
|
-
* const statuses = ["healthy", "healthy", "degraded", "healthy"] as const
|
|
1434
|
-
* let index = 0
|
|
1435
|
-
*
|
|
1436
|
-
* yield* Effect.repeat(
|
|
1437
|
-
* Effect.gen(function*() {
|
|
1438
|
-
* yield* Console.log("Business hours health check...")
|
|
1439
|
-
* const status = statuses[index++]
|
|
1440
|
-
* yield* Console.log(`System status: ${status}`)
|
|
1441
|
-
* return status
|
|
1442
|
-
* }),
|
|
1443
|
-
* businessHoursCheck.pipe(
|
|
1444
|
-
* Schedule.upTo({ times: 4 }) // Demo with 4 checks
|
|
1445
|
-
* )
|
|
1446
|
-
* )
|
|
1447
|
-
* })
|
|
1448
|
-
*
|
|
1449
|
-
* // Run on specific days of the month
|
|
1450
|
-
* const monthlyInvoice = Schedule.cron("0 10 1,15 * *") // 1st and 15th at 10 AM
|
|
1451
|
-
*
|
|
1452
|
-
* const invoiceProgram = Effect.gen(function*() {
|
|
1453
|
-
* yield* Effect.repeat(
|
|
1454
|
-
* Effect.gen(function*() {
|
|
1455
|
-
* yield* Console.log("Processing monthly invoices...")
|
|
1456
|
-
* const invoiceCount = 72
|
|
1457
|
-
* yield* Console.log(`Processed ${invoiceCount} invoices`)
|
|
1458
|
-
* return { count: invoiceCount, batch: "2024-01-a" }
|
|
1459
|
-
* }),
|
|
1460
|
-
* monthlyInvoice.pipe(Schedule.upTo({ times: 1 }))
|
|
1461
|
-
* )
|
|
1462
|
-
* })
|
|
1463
|
-
*
|
|
1464
|
-
* // Complex cron with error handling
|
|
1465
|
-
* const complexCron = Schedule.cron("0 2,4,6 * * *").pipe(
|
|
1466
|
-
* Schedule.tap(({ output: duration }) =>
|
|
1467
|
-
* Console.log(`Scheduled to run again in ${duration}`)
|
|
1468
|
-
* )
|
|
1469
|
-
* )
|
|
1470
|
-
*
|
|
1471
|
-
* const robustProgram = Effect.gen(function*() {
|
|
1472
|
-
* let attempt = 0
|
|
1473
|
-
*
|
|
1474
|
-
* yield* Effect.repeat(
|
|
1475
|
-
* Effect.gen(function*() {
|
|
1476
|
-
* attempt++
|
|
1477
|
-
* yield* Console.log("Complex scheduled task...")
|
|
1478
|
-
* if (attempt === 1) {
|
|
1479
|
-
* return yield* Effect.fail(new ScheduledTaskError({ message: "Scheduled task failed" }))
|
|
1480
|
-
* }
|
|
1481
|
-
* return "success"
|
|
1482
|
-
* }),
|
|
1483
|
-
* complexCron.pipe(Schedule.upTo({ times: 3 }))
|
|
1484
|
-
* ).pipe(
|
|
1485
|
-
* Effect.catch((error: unknown) =>
|
|
1486
|
-
* Console.log(`Cron task error: ${String(error)}`)
|
|
1487
|
-
* )
|
|
1488
|
-
* )
|
|
1489
|
-
* })
|
|
880
|
+
* Schedule.isSchedule(everyMinute) // => true
|
|
1490
881
|
* ```
|
|
1491
882
|
*
|
|
1492
883
|
* @category constructors
|
|
@@ -1499,126 +890,11 @@ export const cron: {
|
|
|
1499
890
|
*
|
|
1500
891
|
* **Example** (Scheduling work with cron expressions)
|
|
1501
892
|
*
|
|
1502
|
-
* ```ts
|
|
1503
|
-
* import {
|
|
893
|
+
* ```ts import.meta.vitest
|
|
894
|
+
* import { Schedule } from "effect"
|
|
1504
895
|
*
|
|
1505
|
-
* class ScheduledTaskError extends Data.TaggedError("ScheduledTaskError")<{ readonly message: string }> {}
|
|
1506
|
-
*
|
|
1507
|
-
* // Run every minute
|
|
1508
896
|
* const everyMinute = Schedule.cron("* * * * *")
|
|
1509
|
-
*
|
|
1510
|
-
* const minutelyProgram = Effect.gen(function*() {
|
|
1511
|
-
* yield* Effect.repeat(
|
|
1512
|
-
* Effect.gen(function*() {
|
|
1513
|
-
* yield* Console.log("Running minutely task")
|
|
1514
|
-
* return "minute"
|
|
1515
|
-
* }),
|
|
1516
|
-
* everyMinute.pipe(
|
|
1517
|
-
* Schedule.upTo({ times: 3 }), // Run only 3 times for demo
|
|
1518
|
-
* Schedule.tap(({ output: duration }) =>
|
|
1519
|
-
* Console.log(`Next execution in: ${duration}`)
|
|
1520
|
-
* )
|
|
1521
|
-
* )
|
|
1522
|
-
* )
|
|
1523
|
-
* })
|
|
1524
|
-
*
|
|
1525
|
-
* // Run every day at 2:30 AM
|
|
1526
|
-
* const dailyBackup = Schedule.cron("30 2 * * *")
|
|
1527
|
-
*
|
|
1528
|
-
* const backupProgram = Effect.gen(function*() {
|
|
1529
|
-
* yield* Effect.repeat(
|
|
1530
|
-
* Effect.gen(function*() {
|
|
1531
|
-
* yield* Console.log("Running daily backup...")
|
|
1532
|
-
* // Simulate backup process
|
|
1533
|
-
* yield* Effect.sleep("2 seconds")
|
|
1534
|
-
* yield* Console.log("Backup completed")
|
|
1535
|
-
* return "backup-done"
|
|
1536
|
-
* }),
|
|
1537
|
-
* dailyBackup.pipe(
|
|
1538
|
-
* Schedule.upTo({ times: 2 }) // Run 2 times for demo
|
|
1539
|
-
* )
|
|
1540
|
-
* )
|
|
1541
|
-
* })
|
|
1542
|
-
*
|
|
1543
|
-
* // Run every Monday at 9:00 AM with timezone
|
|
1544
|
-
* const weeklyReport = Schedule.cron("0 9 * * 1", "America/New_York")
|
|
1545
|
-
*
|
|
1546
|
-
* const reportProgram = Effect.gen(function*() {
|
|
1547
|
-
* yield* Effect.repeat(
|
|
1548
|
-
* Effect.gen(function*() {
|
|
1549
|
-
* yield* Console.log("Generating weekly report...")
|
|
1550
|
-
* const report = {
|
|
1551
|
-
* week: 42,
|
|
1552
|
-
* status: "ready" as const
|
|
1553
|
-
* }
|
|
1554
|
-
* yield* Console.log(`Report generated: ${JSON.stringify(report)}`)
|
|
1555
|
-
* return report
|
|
1556
|
-
* }),
|
|
1557
|
-
* weeklyReport.pipe(Schedule.upTo({ times: 1 }))
|
|
1558
|
-
* )
|
|
1559
|
-
* })
|
|
1560
|
-
*
|
|
1561
|
-
* // Run every 15 minutes during business hours (9 AM - 5 PM)
|
|
1562
|
-
* const businessHoursCheck = Schedule.cron("0,15,30,45 9-17 * * 1-5")
|
|
1563
|
-
*
|
|
1564
|
-
* const businessProgram = Effect.gen(function*() {
|
|
1565
|
-
* const statuses = ["healthy", "healthy", "degraded", "healthy"] as const
|
|
1566
|
-
* let index = 0
|
|
1567
|
-
*
|
|
1568
|
-
* yield* Effect.repeat(
|
|
1569
|
-
* Effect.gen(function*() {
|
|
1570
|
-
* yield* Console.log("Business hours health check...")
|
|
1571
|
-
* const status = statuses[index++]
|
|
1572
|
-
* yield* Console.log(`System status: ${status}`)
|
|
1573
|
-
* return status
|
|
1574
|
-
* }),
|
|
1575
|
-
* businessHoursCheck.pipe(
|
|
1576
|
-
* Schedule.upTo({ times: 4 }) // Demo with 4 checks
|
|
1577
|
-
* )
|
|
1578
|
-
* )
|
|
1579
|
-
* })
|
|
1580
|
-
*
|
|
1581
|
-
* // Run on specific days of the month
|
|
1582
|
-
* const monthlyInvoice = Schedule.cron("0 10 1,15 * *") // 1st and 15th at 10 AM
|
|
1583
|
-
*
|
|
1584
|
-
* const invoiceProgram = Effect.gen(function*() {
|
|
1585
|
-
* yield* Effect.repeat(
|
|
1586
|
-
* Effect.gen(function*() {
|
|
1587
|
-
* yield* Console.log("Processing monthly invoices...")
|
|
1588
|
-
* const invoiceCount = 72
|
|
1589
|
-
* yield* Console.log(`Processed ${invoiceCount} invoices`)
|
|
1590
|
-
* return { count: invoiceCount, batch: "2024-01-a" }
|
|
1591
|
-
* }),
|
|
1592
|
-
* monthlyInvoice.pipe(Schedule.upTo({ times: 1 }))
|
|
1593
|
-
* )
|
|
1594
|
-
* })
|
|
1595
|
-
*
|
|
1596
|
-
* // Complex cron with error handling
|
|
1597
|
-
* const complexCron = Schedule.cron("0 2,4,6 * * *").pipe(
|
|
1598
|
-
* Schedule.tap(({ output: duration }) =>
|
|
1599
|
-
* Console.log(`Scheduled to run again in ${duration}`)
|
|
1600
|
-
* )
|
|
1601
|
-
* )
|
|
1602
|
-
*
|
|
1603
|
-
* const robustProgram = Effect.gen(function*() {
|
|
1604
|
-
* let attempt = 0
|
|
1605
|
-
*
|
|
1606
|
-
* yield* Effect.repeat(
|
|
1607
|
-
* Effect.gen(function*() {
|
|
1608
|
-
* attempt++
|
|
1609
|
-
* yield* Console.log("Complex scheduled task...")
|
|
1610
|
-
* if (attempt === 1) {
|
|
1611
|
-
* return yield* Effect.fail(new ScheduledTaskError({ message: "Scheduled task failed" }))
|
|
1612
|
-
* }
|
|
1613
|
-
* return "success"
|
|
1614
|
-
* }),
|
|
1615
|
-
* complexCron.pipe(Schedule.upTo({ times: 3 }))
|
|
1616
|
-
* ).pipe(
|
|
1617
|
-
* Effect.catch((error: unknown) =>
|
|
1618
|
-
* Console.log(`Cron task error: ${String(error)}`)
|
|
1619
|
-
* )
|
|
1620
|
-
* )
|
|
1621
|
-
* })
|
|
897
|
+
* Schedule.isSchedule(everyMinute) // => true
|
|
1622
898
|
* ```
|
|
1623
899
|
*
|
|
1624
900
|
* @category constructors
|
|
@@ -1631,126 +907,11 @@ export const cron: {
|
|
|
1631
907
|
*
|
|
1632
908
|
* **Example** (Scheduling work with cron expressions)
|
|
1633
909
|
*
|
|
1634
|
-
* ```ts
|
|
1635
|
-
* import {
|
|
1636
|
-
*
|
|
1637
|
-
* class ScheduledTaskError extends Data.TaggedError("ScheduledTaskError")<{ readonly message: string }> {}
|
|
910
|
+
* ```ts import.meta.vitest
|
|
911
|
+
* import { Schedule } from "effect"
|
|
1638
912
|
*
|
|
1639
|
-
* // Run every minute
|
|
1640
913
|
* const everyMinute = Schedule.cron("* * * * *")
|
|
1641
|
-
*
|
|
1642
|
-
* const minutelyProgram = Effect.gen(function*() {
|
|
1643
|
-
* yield* Effect.repeat(
|
|
1644
|
-
* Effect.gen(function*() {
|
|
1645
|
-
* yield* Console.log("Running minutely task")
|
|
1646
|
-
* return "minute"
|
|
1647
|
-
* }),
|
|
1648
|
-
* everyMinute.pipe(
|
|
1649
|
-
* Schedule.upTo({ times: 3 }), // Run only 3 times for demo
|
|
1650
|
-
* Schedule.tap(({ output: duration }) =>
|
|
1651
|
-
* Console.log(`Next execution in: ${duration}`)
|
|
1652
|
-
* )
|
|
1653
|
-
* )
|
|
1654
|
-
* )
|
|
1655
|
-
* })
|
|
1656
|
-
*
|
|
1657
|
-
* // Run every day at 2:30 AM
|
|
1658
|
-
* const dailyBackup = Schedule.cron("30 2 * * *")
|
|
1659
|
-
*
|
|
1660
|
-
* const backupProgram = Effect.gen(function*() {
|
|
1661
|
-
* yield* Effect.repeat(
|
|
1662
|
-
* Effect.gen(function*() {
|
|
1663
|
-
* yield* Console.log("Running daily backup...")
|
|
1664
|
-
* // Simulate backup process
|
|
1665
|
-
* yield* Effect.sleep("2 seconds")
|
|
1666
|
-
* yield* Console.log("Backup completed")
|
|
1667
|
-
* return "backup-done"
|
|
1668
|
-
* }),
|
|
1669
|
-
* dailyBackup.pipe(
|
|
1670
|
-
* Schedule.upTo({ times: 2 }) // Run 2 times for demo
|
|
1671
|
-
* )
|
|
1672
|
-
* )
|
|
1673
|
-
* })
|
|
1674
|
-
*
|
|
1675
|
-
* // Run every Monday at 9:00 AM with timezone
|
|
1676
|
-
* const weeklyReport = Schedule.cron("0 9 * * 1", "America/New_York")
|
|
1677
|
-
*
|
|
1678
|
-
* const reportProgram = Effect.gen(function*() {
|
|
1679
|
-
* yield* Effect.repeat(
|
|
1680
|
-
* Effect.gen(function*() {
|
|
1681
|
-
* yield* Console.log("Generating weekly report...")
|
|
1682
|
-
* const report = {
|
|
1683
|
-
* week: 42,
|
|
1684
|
-
* status: "ready" as const
|
|
1685
|
-
* }
|
|
1686
|
-
* yield* Console.log(`Report generated: ${JSON.stringify(report)}`)
|
|
1687
|
-
* return report
|
|
1688
|
-
* }),
|
|
1689
|
-
* weeklyReport.pipe(Schedule.upTo({ times: 1 }))
|
|
1690
|
-
* )
|
|
1691
|
-
* })
|
|
1692
|
-
*
|
|
1693
|
-
* // Run every 15 minutes during business hours (9 AM - 5 PM)
|
|
1694
|
-
* const businessHoursCheck = Schedule.cron("0,15,30,45 9-17 * * 1-5")
|
|
1695
|
-
*
|
|
1696
|
-
* const businessProgram = Effect.gen(function*() {
|
|
1697
|
-
* const statuses = ["healthy", "healthy", "degraded", "healthy"] as const
|
|
1698
|
-
* let index = 0
|
|
1699
|
-
*
|
|
1700
|
-
* yield* Effect.repeat(
|
|
1701
|
-
* Effect.gen(function*() {
|
|
1702
|
-
* yield* Console.log("Business hours health check...")
|
|
1703
|
-
* const status = statuses[index++]
|
|
1704
|
-
* yield* Console.log(`System status: ${status}`)
|
|
1705
|
-
* return status
|
|
1706
|
-
* }),
|
|
1707
|
-
* businessHoursCheck.pipe(
|
|
1708
|
-
* Schedule.upTo({ times: 4 }) // Demo with 4 checks
|
|
1709
|
-
* )
|
|
1710
|
-
* )
|
|
1711
|
-
* })
|
|
1712
|
-
*
|
|
1713
|
-
* // Run on specific days of the month
|
|
1714
|
-
* const monthlyInvoice = Schedule.cron("0 10 1,15 * *") // 1st and 15th at 10 AM
|
|
1715
|
-
*
|
|
1716
|
-
* const invoiceProgram = Effect.gen(function*() {
|
|
1717
|
-
* yield* Effect.repeat(
|
|
1718
|
-
* Effect.gen(function*() {
|
|
1719
|
-
* yield* Console.log("Processing monthly invoices...")
|
|
1720
|
-
* const invoiceCount = 72
|
|
1721
|
-
* yield* Console.log(`Processed ${invoiceCount} invoices`)
|
|
1722
|
-
* return { count: invoiceCount, batch: "2024-01-a" }
|
|
1723
|
-
* }),
|
|
1724
|
-
* monthlyInvoice.pipe(Schedule.upTo({ times: 1 }))
|
|
1725
|
-
* )
|
|
1726
|
-
* })
|
|
1727
|
-
*
|
|
1728
|
-
* // Complex cron with error handling
|
|
1729
|
-
* const complexCron = Schedule.cron("0 2,4,6 * * *").pipe(
|
|
1730
|
-
* Schedule.tap(({ output: duration }) =>
|
|
1731
|
-
* Console.log(`Scheduled to run again in ${duration}`)
|
|
1732
|
-
* )
|
|
1733
|
-
* )
|
|
1734
|
-
*
|
|
1735
|
-
* const robustProgram = Effect.gen(function*() {
|
|
1736
|
-
* let attempt = 0
|
|
1737
|
-
*
|
|
1738
|
-
* yield* Effect.repeat(
|
|
1739
|
-
* Effect.gen(function*() {
|
|
1740
|
-
* attempt++
|
|
1741
|
-
* yield* Console.log("Complex scheduled task...")
|
|
1742
|
-
* if (attempt === 1) {
|
|
1743
|
-
* return yield* Effect.fail(new ScheduledTaskError({ message: "Scheduled task failed" }))
|
|
1744
|
-
* }
|
|
1745
|
-
* return "success"
|
|
1746
|
-
* }),
|
|
1747
|
-
* complexCron.pipe(Schedule.upTo({ times: 3 }))
|
|
1748
|
-
* ).pipe(
|
|
1749
|
-
* Effect.catch((error: unknown) =>
|
|
1750
|
-
* Console.log(`Cron task error: ${String(error)}`)
|
|
1751
|
-
* )
|
|
1752
|
-
* )
|
|
1753
|
-
* })
|
|
914
|
+
* Schedule.isSchedule(everyMinute) // => true
|
|
1754
915
|
* ```
|
|
1755
916
|
*
|
|
1756
917
|
* @category constructors
|
|
@@ -1785,13 +946,10 @@ export const cron: {
|
|
|
1785
946
|
*
|
|
1786
947
|
* **Example** (Recurring once after a duration)
|
|
1787
948
|
*
|
|
1788
|
-
* ```ts
|
|
1789
|
-
* import {
|
|
949
|
+
* ```ts import.meta.vitest
|
|
950
|
+
* import { Schedule } from "effect"
|
|
1790
951
|
*
|
|
1791
|
-
*
|
|
1792
|
-
* Console.log("runs again after one second"),
|
|
1793
|
-
* Schedule.duration("1 second")
|
|
1794
|
-
* )
|
|
952
|
+
* Schedule.isSchedule(Schedule.duration("1 second")) // => true
|
|
1795
953
|
* ```
|
|
1796
954
|
*
|
|
1797
955
|
* @see {@link during} for recurring until a duration has elapsed
|
|
@@ -1818,82 +976,10 @@ export const duration = (durationInput: Duration.Input): Schedule<Duration.Durat
|
|
|
1818
976
|
*
|
|
1819
977
|
* **Example** (Repeating work during a duration)
|
|
1820
978
|
*
|
|
1821
|
-
* ```ts
|
|
1822
|
-
* import {
|
|
1823
|
-
*
|
|
1824
|
-
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
1825
|
-
*
|
|
1826
|
-
* // Run a task for exactly 5 seconds, regardless of how many iterations
|
|
1827
|
-
* const fiveSecondSchedule = Schedule.during("5 seconds")
|
|
1828
|
-
*
|
|
1829
|
-
* const timedProgram = Effect.gen(function*() {
|
|
1830
|
-
* yield* Effect.repeat(
|
|
1831
|
-
* Effect.gen(function*() {
|
|
1832
|
-
* yield* Console.log("Task executed inside the time window")
|
|
1833
|
-
* yield* Effect.sleep("500 millis") // Each task takes 500ms
|
|
1834
|
-
* return "task done"
|
|
1835
|
-
* }),
|
|
1836
|
-
* fiveSecondSchedule.pipe(
|
|
1837
|
-
* Schedule.tap(({ output: elapsedDuration }) =>
|
|
1838
|
-
* Console.log(`Total elapsed: ${elapsedDuration}`)
|
|
1839
|
-
* )
|
|
1840
|
-
* )
|
|
1841
|
-
* )
|
|
1842
|
-
*
|
|
1843
|
-
* yield* Console.log("Time limit reached!")
|
|
1844
|
-
* })
|
|
1845
|
-
*
|
|
1846
|
-
* // Combine with other schedules for time-bounded execution
|
|
1847
|
-
* const timeAndCountLimited = Schedule.max([
|
|
1848
|
-
* Schedule.spaced("1 second"),
|
|
1849
|
-
* Schedule.during("10 seconds"), // Stop after 10 seconds OR
|
|
1850
|
-
* Schedule.recurs(15) // 15 attempts, whichever comes first
|
|
1851
|
-
* ])
|
|
1852
|
-
*
|
|
1853
|
-
* // Burst execution within time window
|
|
1854
|
-
* const burstWindow = Schedule.during("3 seconds")
|
|
1855
|
-
*
|
|
1856
|
-
* const burstProgram = Effect.gen(function*() {
|
|
1857
|
-
* yield* Console.log("Starting burst execution...")
|
|
1858
|
-
*
|
|
1859
|
-
* yield* Effect.repeat(
|
|
1860
|
-
* Effect.gen(function*() {
|
|
1861
|
-
* yield* Console.log("Burst task")
|
|
1862
|
-
* return "burst"
|
|
1863
|
-
* }),
|
|
1864
|
-
* burstWindow
|
|
1865
|
-
* )
|
|
1866
|
-
*
|
|
1867
|
-
* yield* Console.log("Burst window completed")
|
|
1868
|
-
* })
|
|
1869
|
-
*
|
|
1870
|
-
* // Timed retry window - retry for up to 30 seconds
|
|
1871
|
-
* const timedRetry = Schedule.max([
|
|
1872
|
-
* Schedule.exponential("200 millis"),
|
|
1873
|
-
* Schedule.during("30 seconds")
|
|
1874
|
-
* ])
|
|
1875
|
-
*
|
|
1876
|
-
* const retryProgram = Effect.gen(function*() {
|
|
1877
|
-
* let attempt = 0
|
|
1878
|
-
*
|
|
1879
|
-
* const result = yield* Effect.retry(
|
|
1880
|
-
* Effect.gen(function*() {
|
|
1881
|
-
* attempt++
|
|
1882
|
-
* yield* Console.log(`Retry attempt ${attempt}`)
|
|
1883
|
-
*
|
|
1884
|
-
* if (attempt < 4) {
|
|
1885
|
-
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
1886
|
-
* }
|
|
1887
|
-
*
|
|
1888
|
-
* return `Success on attempt ${attempt}`
|
|
1889
|
-
* }),
|
|
1890
|
-
* timedRetry
|
|
1891
|
-
* )
|
|
979
|
+
* ```ts import.meta.vitest
|
|
980
|
+
* import { Schedule } from "effect"
|
|
1892
981
|
*
|
|
1893
|
-
*
|
|
1894
|
-
* }).pipe(
|
|
1895
|
-
* Effect.catch((error: unknown) => Console.log(`Timed out: ${String(error)}`))
|
|
1896
|
-
* )
|
|
982
|
+
* Schedule.isSchedule(Schedule.during("5 seconds")) // => true
|
|
1897
983
|
* ```
|
|
1898
984
|
*
|
|
1899
985
|
* @see {@link duration} for one delayed recurrence
|
|
@@ -1907,8 +993,8 @@ export const during = (duration: Duration.Input): Schedule<Duration.Duration> =>
|
|
|
1907
993
|
effect.succeed((meta) => {
|
|
1908
994
|
const elapsed = Duration.millis(meta.elapsed)
|
|
1909
995
|
return meta.elapsed > durationMillis
|
|
1910
|
-
?
|
|
1911
|
-
:
|
|
996
|
+
? Cause.done(elapsed)
|
|
997
|
+
: effect.succeed([elapsed, Duration.zero])
|
|
1912
998
|
})
|
|
1913
999
|
)
|
|
1914
1000
|
}
|
|
@@ -1924,36 +1010,11 @@ export const during = (duration: Duration.Input): Schedule<Duration.Duration> =>
|
|
|
1924
1010
|
*
|
|
1925
1011
|
* **Example** (Combining retry schedules by their minimum delay)
|
|
1926
1012
|
*
|
|
1927
|
-
* ```ts
|
|
1928
|
-
* import {
|
|
1929
|
-
*
|
|
1930
|
-
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
1931
|
-
*
|
|
1932
|
-
* const retrySchedule = Schedule.min([
|
|
1933
|
-
* Schedule.fixed("5 seconds"),
|
|
1934
|
-
* Schedule.exponential("5 seconds"),
|
|
1935
|
-
* Schedule.spaced("10 seconds")
|
|
1936
|
-
* ])
|
|
1013
|
+
* ```ts import.meta.vitest
|
|
1014
|
+
* import { Schedule } from "effect"
|
|
1937
1015
|
*
|
|
1938
|
-
* const
|
|
1939
|
-
*
|
|
1940
|
-
*
|
|
1941
|
-
* yield* Effect.retry(
|
|
1942
|
-
* Effect.gen(function*() {
|
|
1943
|
-
* attempt++
|
|
1944
|
-
* yield* Console.log(`Retry attempt ${attempt}`)
|
|
1945
|
-
* if (attempt < 3) {
|
|
1946
|
-
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
1947
|
-
* }
|
|
1948
|
-
* return "success"
|
|
1949
|
-
* }),
|
|
1950
|
-
* retrySchedule.pipe(
|
|
1951
|
-
* Schedule.tap(({ output: duration }) =>
|
|
1952
|
-
* Console.log(`Waiting for the fastest schedule: ${duration}`)
|
|
1953
|
-
* )
|
|
1954
|
-
* )
|
|
1955
|
-
* )
|
|
1956
|
-
* })
|
|
1016
|
+
* const schedule = Schedule.min([Schedule.fixed("5 seconds"), Schedule.spaced("10 seconds")])
|
|
1017
|
+
* Schedule.isSchedule(schedule) // => true
|
|
1957
1018
|
* ```
|
|
1958
1019
|
*
|
|
1959
1020
|
* @category combining
|
|
@@ -2012,44 +1073,15 @@ const minDuration = (results: ReadonlyArray<Duration.Duration | undefined>): Dur
|
|
|
2012
1073
|
*
|
|
2013
1074
|
* **Example** (Retrying with exponential backoff)
|
|
2014
1075
|
*
|
|
2015
|
-
* ```ts
|
|
2016
|
-
* import {
|
|
2017
|
-
*
|
|
2018
|
-
* class RetryFailure extends Data.TaggedError("RetryFailure")<{ readonly message: string }> {}
|
|
2019
|
-
*
|
|
2020
|
-
* // Basic exponential backoff with default factor of 2
|
|
2021
|
-
* const basicExponential = Schedule.exponential("100 millis")
|
|
2022
|
-
* // Delays: 100ms, 200ms, 400ms, 800ms, 1600ms, ...
|
|
2023
|
-
*
|
|
2024
|
-
* // Custom exponential backoff with factor 1.5
|
|
2025
|
-
* const gentleExponential = Schedule.exponential("200 millis", 1.5)
|
|
2026
|
-
* // Delays: 200ms, 300ms, 450ms, 675ms, 1012ms, ...
|
|
2027
|
-
*
|
|
2028
|
-
* // Retry with exponential backoff (limited to 5 attempts)
|
|
2029
|
-
* const retryPolicy = Schedule.max([
|
|
2030
|
-
* Schedule.exponential("50 millis"),
|
|
2031
|
-
* Schedule.recurs(5)
|
|
2032
|
-
* ])
|
|
1076
|
+
* ```ts import.meta.vitest
|
|
1077
|
+
* import { Duration, Effect, Schedule } from "effect"
|
|
2033
1078
|
*
|
|
2034
1079
|
* const program = Effect.gen(function*() {
|
|
2035
|
-
*
|
|
2036
|
-
*
|
|
2037
|
-
* const result = yield* Effect.retry(
|
|
2038
|
-
* Effect.gen(function*() {
|
|
2039
|
-
* attempt++
|
|
2040
|
-
* if (attempt < 4) {
|
|
2041
|
-
* yield* Console.log(`Attempt ${attempt} failed, retrying...`)
|
|
2042
|
-
* return yield* Effect.fail(new RetryFailure({ message: `Failure ${attempt}` }))
|
|
2043
|
-
* }
|
|
2044
|
-
* return `Success on attempt ${attempt}`
|
|
2045
|
-
* }),
|
|
2046
|
-
* retryPolicy
|
|
2047
|
-
* )
|
|
2048
|
-
*
|
|
2049
|
-
* yield* Console.log(`Final result: ${result}`)
|
|
1080
|
+
* const step = yield* Schedule.toStep(Schedule.exponential("100 millis"))
|
|
1081
|
+
* return yield* step(0, undefined)
|
|
2050
1082
|
* })
|
|
2051
1083
|
*
|
|
2052
|
-
*
|
|
1084
|
+
* await Effect.runPromise(program) // => [Duration.millis(100), Duration.millis(100)]
|
|
2053
1085
|
* ```
|
|
2054
1086
|
*
|
|
2055
1087
|
* @category constructors
|
|
@@ -2073,63 +1105,15 @@ export const exponential = (
|
|
|
2073
1105
|
*
|
|
2074
1106
|
* **Example** (Retrying with Fibonacci backoff)
|
|
2075
1107
|
*
|
|
2076
|
-
* ```ts
|
|
2077
|
-
* import {
|
|
2078
|
-
*
|
|
2079
|
-
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
2080
|
-
*
|
|
2081
|
-
* // Basic Fibonacci schedule starting with 100ms
|
|
2082
|
-
* const fibSchedule = Schedule.fibonacci("100 millis")
|
|
2083
|
-
* // Delays: 100ms, 100ms, 200ms, 300ms, 500ms, 800ms, 1300ms, ...
|
|
2084
|
-
*
|
|
2085
|
-
* // Retry with Fibonacci backoff for gradual increase
|
|
2086
|
-
* const retryWithFib = Effect.gen(function*() {
|
|
2087
|
-
* let attempt = 0
|
|
1108
|
+
* ```ts import.meta.vitest
|
|
1109
|
+
* import { Duration, Effect, Schedule } from "effect"
|
|
2088
1110
|
*
|
|
2089
|
-
*
|
|
2090
|
-
*
|
|
2091
|
-
*
|
|
2092
|
-
* yield* Console.log(`Attempt ${attempt}`)
|
|
2093
|
-
*
|
|
2094
|
-
* if (attempt < 5) {
|
|
2095
|
-
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
2096
|
-
* }
|
|
2097
|
-
*
|
|
2098
|
-
* return `Success on attempt ${attempt}`
|
|
2099
|
-
* }),
|
|
2100
|
-
* Schedule.max([
|
|
2101
|
-
* Schedule.fibonacci("50 millis"),
|
|
2102
|
-
* Schedule.recurs(6) // Maximum 6 retries
|
|
2103
|
-
* ]).pipe(
|
|
2104
|
-
* Schedule.tap(({ output: delay }) => Console.log(`Next retry in ${delay}`))
|
|
2105
|
-
* )
|
|
2106
|
-
* )
|
|
2107
|
-
*
|
|
2108
|
-
* yield* Console.log(`Final result: ${result}`)
|
|
1111
|
+
* const program = Effect.gen(function*() {
|
|
1112
|
+
* const step = yield* Schedule.toStep(Schedule.fibonacci("100 millis"))
|
|
1113
|
+
* return yield* step(0, undefined)
|
|
2109
1114
|
* })
|
|
2110
1115
|
*
|
|
2111
|
-
*
|
|
2112
|
-
* const adaptiveHeartbeat = Effect.gen(function*() {
|
|
2113
|
-
* yield* Console.log("Heartbeat")
|
|
2114
|
-
* return "pulse"
|
|
2115
|
-
* }).pipe(
|
|
2116
|
-
* Effect.repeat(
|
|
2117
|
-
* Schedule.fibonacci("200 millis").pipe(
|
|
2118
|
-
* Schedule.upTo({ times: 8 }) // First 8 heartbeats
|
|
2119
|
-
* )
|
|
2120
|
-
* )
|
|
2121
|
-
* )
|
|
2122
|
-
*
|
|
2123
|
-
* // Fibonacci vs exponential comparison
|
|
2124
|
-
* const compareSchedules = Effect.gen(function*() {
|
|
2125
|
-
* yield* Console.log("=== Fibonacci Delays ===")
|
|
2126
|
-
* // 100ms, 100ms, 200ms, 300ms, 500ms, 800ms
|
|
2127
|
-
*
|
|
2128
|
-
* yield* Console.log("=== Exponential Delays ===")
|
|
2129
|
-
* // 100ms, 200ms, 400ms, 800ms, 1600ms, 3200ms
|
|
2130
|
-
*
|
|
2131
|
-
* // Fibonacci grows more slowly than exponential
|
|
2132
|
-
* })
|
|
1116
|
+
* await Effect.runPromise(program) // => [Duration.millis(100), Duration.millis(100)]
|
|
2133
1117
|
* ```
|
|
2134
1118
|
*
|
|
2135
1119
|
* @category constructors
|
|
@@ -2170,50 +1154,15 @@ export const fibonacci = (one: Duration.Input): Schedule<Duration.Duration> => {
|
|
|
2170
1154
|
*
|
|
2171
1155
|
* **Example** (Repeating on fixed intervals)
|
|
2172
1156
|
*
|
|
2173
|
-
* ```ts
|
|
2174
|
-
* import {
|
|
2175
|
-
*
|
|
2176
|
-
* // Fixed interval schedule - recurs on a one-second cadence
|
|
2177
|
-
* const everySecond = Schedule.fixed("1 second")
|
|
2178
|
-
*
|
|
2179
|
-
* // Health check that runs at fixed intervals
|
|
2180
|
-
* const healthCheck = Effect.gen(function*() {
|
|
2181
|
-
* yield* Console.log("Health check")
|
|
2182
|
-
* yield* Effect.sleep("200 millis") // simulate health check work
|
|
2183
|
-
* return "healthy"
|
|
2184
|
-
* }).pipe(
|
|
2185
|
-
* Effect.repeat(Schedule.fixed("2 seconds").pipe(Schedule.upTo({ times: 5 })))
|
|
2186
|
-
* )
|
|
2187
|
-
*
|
|
2188
|
-
* // Difference between fixed and spaced:
|
|
2189
|
-
* // - fixed: maintains constant rate regardless of action duration
|
|
2190
|
-
* // - spaced: waits for the duration AFTER each action completes
|
|
2191
|
-
*
|
|
2192
|
-
* const longRunningTask = Effect.gen(function*() {
|
|
2193
|
-
* yield* Console.log("Task started")
|
|
2194
|
-
* yield* Effect.sleep("1.5 seconds") // Longer than interval
|
|
2195
|
-
* yield* Console.log("Task completed")
|
|
2196
|
-
* return "done"
|
|
2197
|
-
* })
|
|
2198
|
-
*
|
|
2199
|
-
* // Fixed schedule: if task takes 1.5s but interval is 1s,
|
|
2200
|
-
* // next execution happens immediately (no pile-up)
|
|
2201
|
-
* const fixedSchedule = longRunningTask.pipe(
|
|
2202
|
-
* Effect.repeat(Schedule.fixed("1 second").pipe(Schedule.upTo({ times: 3 })))
|
|
2203
|
-
* )
|
|
2204
|
-
*
|
|
2205
|
-
* // Comparing with spaced (waits 1s AFTER each task)
|
|
2206
|
-
* const spacedSchedule = longRunningTask.pipe(
|
|
2207
|
-
* Effect.repeat(Schedule.spaced("1 second").pipe(Schedule.upTo({ times: 3 })))
|
|
2208
|
-
* )
|
|
1157
|
+
* ```ts import.meta.vitest
|
|
1158
|
+
* import { Duration, Effect, Schedule } from "effect"
|
|
2209
1159
|
*
|
|
2210
1160
|
* const program = Effect.gen(function*() {
|
|
2211
|
-
* yield*
|
|
2212
|
-
* yield*
|
|
2213
|
-
*
|
|
2214
|
-
* yield* Console.log("=== Spaced Schedule Demo ===")
|
|
2215
|
-
* yield* spacedSchedule
|
|
1161
|
+
* const step = yield* Schedule.toStep(Schedule.fixed("1 second"))
|
|
1162
|
+
* return yield* step(0, undefined)
|
|
2216
1163
|
* })
|
|
1164
|
+
*
|
|
1165
|
+
* await Effect.runPromise(program) // => [0, Duration.seconds(1)]
|
|
2217
1166
|
* ```
|
|
2218
1167
|
*
|
|
2219
1168
|
* @see {@link spaced} for delaying after each action completes
|
|
@@ -2257,59 +1206,19 @@ export const fixed = (interval: Duration.Input): Schedule<number> => {
|
|
|
2257
1206
|
*
|
|
2258
1207
|
* **Example** (Mapping schedule outputs)
|
|
2259
1208
|
*
|
|
2260
|
-
* ```ts
|
|
2261
|
-
* import {
|
|
1209
|
+
* ```ts import.meta.vitest
|
|
1210
|
+
* import { Effect, Schedule } from "effect"
|
|
2262
1211
|
*
|
|
2263
|
-
* // Transform schedule output from number to string
|
|
2264
1212
|
* const countSchedule = Schedule.recurs(5).pipe(
|
|
2265
1213
|
* Schedule.map(({ output: count }) => Effect.succeed(`Execution #${count + 1}`))
|
|
2266
1214
|
* )
|
|
2267
|
-
*
|
|
2268
|
-
* // Map schedule delays to human-readable format
|
|
2269
|
-
* const readableDelays = Schedule.exponential("100 millis").pipe(
|
|
2270
|
-
* Schedule.map(({ output: delay }) => Effect.succeed(`Next retry in ${delay}`))
|
|
2271
|
-
* )
|
|
2272
|
-
*
|
|
2273
|
-
* // Transform numeric output to structured data
|
|
2274
|
-
* const structuredSchedule = Schedule.spaced("1 second").pipe(
|
|
2275
|
-
* Schedule.map(({ output: recurrence }) => Effect.succeed({
|
|
2276
|
-
* iteration: recurrence + 1,
|
|
2277
|
-
* phase: recurrence < 5 ? "warmup" as const : "steady" as const
|
|
2278
|
-
* }))
|
|
2279
|
-
* )
|
|
2280
|
-
*
|
|
2281
1215
|
* const program = Effect.gen(function*() {
|
|
2282
|
-
* const
|
|
2283
|
-
*
|
|
2284
|
-
*
|
|
2285
|
-
* Schedule.upTo({ times: 8 }),
|
|
2286
|
-
* Schedule.tap(({ output: info }) =>
|
|
2287
|
-
* Console.log(
|
|
2288
|
-
* `${info.phase} phase - iteration ${info.iteration}`
|
|
2289
|
-
* )
|
|
2290
|
-
* )
|
|
2291
|
-
* )
|
|
2292
|
-
* )
|
|
2293
|
-
*
|
|
2294
|
-
* yield* Console.log(`Completed iterations`)
|
|
1216
|
+
* const step = yield* Schedule.toStep(countSchedule)
|
|
1217
|
+
* const [output] = yield* step(0, undefined)
|
|
1218
|
+
* return output
|
|
2295
1219
|
* })
|
|
2296
1220
|
*
|
|
2297
|
-
* //
|
|
2298
|
-
* const effectfulMap = Schedule.fixed("2 seconds").pipe(
|
|
2299
|
-
* Schedule.map(({ output: count }) =>
|
|
2300
|
-
* Effect.gen(function*() {
|
|
2301
|
-
* yield* Console.log(`Processing count: ${count}`)
|
|
2302
|
-
* return count * 10
|
|
2303
|
-
* })
|
|
2304
|
-
* )
|
|
2305
|
-
* )
|
|
2306
|
-
*
|
|
2307
|
-
* // Use timing metadata in the mapped output
|
|
2308
|
-
* const complexSchedule = Schedule.fibonacci("100 millis").pipe(
|
|
2309
|
-
* Schedule.map(({ output: delay, attempt }) =>
|
|
2310
|
-
* Effect.succeed(`Attempt ${attempt} delay: ${delay}`)
|
|
2311
|
-
* )
|
|
2312
|
-
* )
|
|
1221
|
+
* await Effect.runPromise(program) // => "Execution #1"
|
|
2313
1222
|
* ```
|
|
2314
1223
|
*
|
|
2315
1224
|
* @category mapping
|
|
@@ -2328,59 +1237,19 @@ export const map: {
|
|
|
2328
1237
|
*
|
|
2329
1238
|
* **Example** (Mapping schedule outputs)
|
|
2330
1239
|
*
|
|
2331
|
-
* ```ts
|
|
2332
|
-
* import {
|
|
1240
|
+
* ```ts import.meta.vitest
|
|
1241
|
+
* import { Effect, Schedule } from "effect"
|
|
2333
1242
|
*
|
|
2334
|
-
* // Transform schedule output from number to string
|
|
2335
1243
|
* const countSchedule = Schedule.recurs(5).pipe(
|
|
2336
1244
|
* Schedule.map(({ output: count }) => Effect.succeed(`Execution #${count + 1}`))
|
|
2337
1245
|
* )
|
|
2338
|
-
*
|
|
2339
|
-
* // Map schedule delays to human-readable format
|
|
2340
|
-
* const readableDelays = Schedule.exponential("100 millis").pipe(
|
|
2341
|
-
* Schedule.map(({ output: delay }) => Effect.succeed(`Next retry in ${delay}`))
|
|
2342
|
-
* )
|
|
2343
|
-
*
|
|
2344
|
-
* // Transform numeric output to structured data
|
|
2345
|
-
* const structuredSchedule = Schedule.spaced("1 second").pipe(
|
|
2346
|
-
* Schedule.map(({ output: recurrence }) => Effect.succeed({
|
|
2347
|
-
* iteration: recurrence + 1,
|
|
2348
|
-
* phase: recurrence < 5 ? "warmup" as const : "steady" as const
|
|
2349
|
-
* }))
|
|
2350
|
-
* )
|
|
2351
|
-
*
|
|
2352
1246
|
* const program = Effect.gen(function*() {
|
|
2353
|
-
* const
|
|
2354
|
-
*
|
|
2355
|
-
*
|
|
2356
|
-
* Schedule.upTo({ times: 8 }),
|
|
2357
|
-
* Schedule.tap(({ output: info }) =>
|
|
2358
|
-
* Console.log(
|
|
2359
|
-
* `${info.phase} phase - iteration ${info.iteration}`
|
|
2360
|
-
* )
|
|
2361
|
-
* )
|
|
2362
|
-
* )
|
|
2363
|
-
* )
|
|
2364
|
-
*
|
|
2365
|
-
* yield* Console.log(`Completed iterations`)
|
|
1247
|
+
* const step = yield* Schedule.toStep(countSchedule)
|
|
1248
|
+
* const [output] = yield* step(0, undefined)
|
|
1249
|
+
* return output
|
|
2366
1250
|
* })
|
|
2367
1251
|
*
|
|
2368
|
-
* //
|
|
2369
|
-
* const effectfulMap = Schedule.fixed("2 seconds").pipe(
|
|
2370
|
-
* Schedule.map(({ output: count }) =>
|
|
2371
|
-
* Effect.gen(function*() {
|
|
2372
|
-
* yield* Console.log(`Processing count: ${count}`)
|
|
2373
|
-
* return count * 10
|
|
2374
|
-
* })
|
|
2375
|
-
* )
|
|
2376
|
-
* )
|
|
2377
|
-
*
|
|
2378
|
-
* // Use timing metadata in the mapped output
|
|
2379
|
-
* const complexSchedule = Schedule.fibonacci("100 millis").pipe(
|
|
2380
|
-
* Schedule.map(({ output: delay, attempt }) =>
|
|
2381
|
-
* Effect.succeed(`Attempt ${attempt} delay: ${delay}`)
|
|
2382
|
-
* )
|
|
2383
|
-
* )
|
|
1252
|
+
* await Effect.runPromise(program) // => "Execution #1"
|
|
2384
1253
|
* ```
|
|
2385
1254
|
*
|
|
2386
1255
|
* @category mapping
|
|
@@ -2403,59 +1272,19 @@ export const map: {
|
|
|
2403
1272
|
*
|
|
2404
1273
|
* **Example** (Mapping schedule outputs)
|
|
2405
1274
|
*
|
|
2406
|
-
* ```ts
|
|
2407
|
-
* import {
|
|
1275
|
+
* ```ts import.meta.vitest
|
|
1276
|
+
* import { Effect, Schedule } from "effect"
|
|
2408
1277
|
*
|
|
2409
|
-
* // Transform schedule output from number to string
|
|
2410
1278
|
* const countSchedule = Schedule.recurs(5).pipe(
|
|
2411
1279
|
* Schedule.map(({ output: count }) => Effect.succeed(`Execution #${count + 1}`))
|
|
2412
1280
|
* )
|
|
2413
|
-
*
|
|
2414
|
-
* // Map schedule delays to human-readable format
|
|
2415
|
-
* const readableDelays = Schedule.exponential("100 millis").pipe(
|
|
2416
|
-
* Schedule.map(({ output: delay }) => Effect.succeed(`Next retry in ${delay}`))
|
|
2417
|
-
* )
|
|
2418
|
-
*
|
|
2419
|
-
* // Transform numeric output to structured data
|
|
2420
|
-
* const structuredSchedule = Schedule.spaced("1 second").pipe(
|
|
2421
|
-
* Schedule.map(({ output: recurrence }) => Effect.succeed({
|
|
2422
|
-
* iteration: recurrence + 1,
|
|
2423
|
-
* phase: recurrence < 5 ? "warmup" as const : "steady" as const
|
|
2424
|
-
* }))
|
|
2425
|
-
* )
|
|
2426
|
-
*
|
|
2427
1281
|
* const program = Effect.gen(function*() {
|
|
2428
|
-
* const
|
|
2429
|
-
*
|
|
2430
|
-
*
|
|
2431
|
-
* Schedule.upTo({ times: 8 }),
|
|
2432
|
-
* Schedule.tap(({ output: info }) =>
|
|
2433
|
-
* Console.log(
|
|
2434
|
-
* `${info.phase} phase - iteration ${info.iteration}`
|
|
2435
|
-
* )
|
|
2436
|
-
* )
|
|
2437
|
-
* )
|
|
2438
|
-
* )
|
|
2439
|
-
*
|
|
2440
|
-
* yield* Console.log(`Completed iterations`)
|
|
1282
|
+
* const step = yield* Schedule.toStep(countSchedule)
|
|
1283
|
+
* const [output] = yield* step(0, undefined)
|
|
1284
|
+
* return output
|
|
2441
1285
|
* })
|
|
2442
1286
|
*
|
|
2443
|
-
* //
|
|
2444
|
-
* const effectfulMap = Schedule.fixed("2 seconds").pipe(
|
|
2445
|
-
* Schedule.map(({ output: count }) =>
|
|
2446
|
-
* Effect.gen(function*() {
|
|
2447
|
-
* yield* Console.log(`Processing count: ${count}`)
|
|
2448
|
-
* return count * 10
|
|
2449
|
-
* })
|
|
2450
|
-
* )
|
|
2451
|
-
* )
|
|
2452
|
-
*
|
|
2453
|
-
* // Use timing metadata in the mapped output
|
|
2454
|
-
* const complexSchedule = Schedule.fibonacci("100 millis").pipe(
|
|
2455
|
-
* Schedule.map(({ output: delay, attempt }) =>
|
|
2456
|
-
* Effect.succeed(`Attempt ${attempt} delay: ${delay}`)
|
|
2457
|
-
* )
|
|
2458
|
-
* )
|
|
1287
|
+
* await Effect.runPromise(program) // => "Execution #1"
|
|
2459
1288
|
* ```
|
|
2460
1289
|
*
|
|
2461
1290
|
* @category mapping
|
|
@@ -2493,28 +1322,19 @@ export const map: {
|
|
|
2493
1322
|
*
|
|
2494
1323
|
* **Example** (Modifying delays from schedule metadata)
|
|
2495
1324
|
*
|
|
2496
|
-
* ```ts
|
|
2497
|
-
* import {
|
|
1325
|
+
* ```ts import.meta.vitest
|
|
1326
|
+
* import { Duration, Effect, Schedule } from "effect"
|
|
2498
1327
|
*
|
|
2499
|
-
*
|
|
2500
|
-
*
|
|
2501
|
-
* Schedule.modifyDelay(({ output, duration }) => {
|
|
2502
|
-
* // Double the delay if we're seeing high iteration counts
|
|
2503
|
-
* return Effect.succeed(output > 5 ? Duration.times(duration, 2) : duration)
|
|
2504
|
-
* })
|
|
1328
|
+
* const schedule = Schedule.spaced("10 millis").pipe(
|
|
1329
|
+
* Schedule.modifyDelay(({ duration }) => Effect.succeed(Duration.times(duration, 2)))
|
|
2505
1330
|
* )
|
|
2506
|
-
*
|
|
2507
1331
|
* const program = Effect.gen(function*() {
|
|
2508
|
-
*
|
|
2509
|
-
* yield*
|
|
2510
|
-
*
|
|
2511
|
-
* counter++
|
|
2512
|
-
* yield* Console.log(`Attempt ${counter}`)
|
|
2513
|
-
* return counter
|
|
2514
|
-
* }),
|
|
2515
|
-
* adaptiveDelay.pipe(Schedule.upTo({ times: 8 }))
|
|
2516
|
-
* )
|
|
1332
|
+
* const step = yield* Schedule.toStep(schedule)
|
|
1333
|
+
* const [, delay] = yield* step(0, undefined)
|
|
1334
|
+
* return delay
|
|
2517
1335
|
* })
|
|
1336
|
+
*
|
|
1337
|
+
* await Effect.runPromise(program) // => Duration.millis(20)
|
|
2518
1338
|
* ```
|
|
2519
1339
|
*
|
|
2520
1340
|
* @category delays & timeouts
|
|
@@ -2527,28 +1347,19 @@ export const modifyDelay: {
|
|
|
2527
1347
|
*
|
|
2528
1348
|
* **Example** (Modifying delays from schedule metadata)
|
|
2529
1349
|
*
|
|
2530
|
-
* ```ts
|
|
2531
|
-
* import {
|
|
1350
|
+
* ```ts import.meta.vitest
|
|
1351
|
+
* import { Duration, Effect, Schedule } from "effect"
|
|
2532
1352
|
*
|
|
2533
|
-
*
|
|
2534
|
-
*
|
|
2535
|
-
* Schedule.modifyDelay(({ output, duration }) => {
|
|
2536
|
-
* // Double the delay if we're seeing high iteration counts
|
|
2537
|
-
* return Effect.succeed(output > 5 ? Duration.times(duration, 2) : duration)
|
|
2538
|
-
* })
|
|
1353
|
+
* const schedule = Schedule.spaced("10 millis").pipe(
|
|
1354
|
+
* Schedule.modifyDelay(({ duration }) => Effect.succeed(Duration.times(duration, 2)))
|
|
2539
1355
|
* )
|
|
2540
|
-
*
|
|
2541
1356
|
* const program = Effect.gen(function*() {
|
|
2542
|
-
*
|
|
2543
|
-
* yield*
|
|
2544
|
-
*
|
|
2545
|
-
* counter++
|
|
2546
|
-
* yield* Console.log(`Attempt ${counter}`)
|
|
2547
|
-
* return counter
|
|
2548
|
-
* }),
|
|
2549
|
-
* adaptiveDelay.pipe(Schedule.upTo({ times: 8 }))
|
|
2550
|
-
* )
|
|
1357
|
+
* const step = yield* Schedule.toStep(schedule)
|
|
1358
|
+
* const [, delay] = yield* step(0, undefined)
|
|
1359
|
+
* return delay
|
|
2551
1360
|
* })
|
|
1361
|
+
*
|
|
1362
|
+
* await Effect.runPromise(program) // => Duration.millis(20)
|
|
2552
1363
|
* ```
|
|
2553
1364
|
*
|
|
2554
1365
|
* @category delays & timeouts
|
|
@@ -2567,28 +1378,19 @@ export const modifyDelay: {
|
|
|
2567
1378
|
*
|
|
2568
1379
|
* **Example** (Modifying delays from schedule metadata)
|
|
2569
1380
|
*
|
|
2570
|
-
* ```ts
|
|
2571
|
-
* import {
|
|
1381
|
+
* ```ts import.meta.vitest
|
|
1382
|
+
* import { Duration, Effect, Schedule } from "effect"
|
|
2572
1383
|
*
|
|
2573
|
-
*
|
|
2574
|
-
*
|
|
2575
|
-
* Schedule.modifyDelay(({ output, duration }) => {
|
|
2576
|
-
* // Double the delay if we're seeing high iteration counts
|
|
2577
|
-
* return Effect.succeed(output > 5 ? Duration.times(duration, 2) : duration)
|
|
2578
|
-
* })
|
|
1384
|
+
* const schedule = Schedule.spaced("10 millis").pipe(
|
|
1385
|
+
* Schedule.modifyDelay(({ duration }) => Effect.succeed(Duration.times(duration, 2)))
|
|
2579
1386
|
* )
|
|
2580
|
-
*
|
|
2581
1387
|
* const program = Effect.gen(function*() {
|
|
2582
|
-
*
|
|
2583
|
-
* yield*
|
|
2584
|
-
*
|
|
2585
|
-
* counter++
|
|
2586
|
-
* yield* Console.log(`Attempt ${counter}`)
|
|
2587
|
-
* return counter
|
|
2588
|
-
* }),
|
|
2589
|
-
* adaptiveDelay.pipe(Schedule.upTo({ times: 8 }))
|
|
2590
|
-
* )
|
|
1388
|
+
* const step = yield* Schedule.toStep(schedule)
|
|
1389
|
+
* const [, delay] = yield* step(0, undefined)
|
|
1390
|
+
* return delay
|
|
2591
1391
|
* })
|
|
1392
|
+
*
|
|
1393
|
+
* await Effect.runPromise(program) // => Duration.millis(20)
|
|
2592
1394
|
* ```
|
|
2593
1395
|
*
|
|
2594
1396
|
* @category delays & timeouts
|
|
@@ -2650,25 +1452,19 @@ export const jittered = <Output, Input, Error, Env>(
|
|
|
2650
1452
|
*
|
|
2651
1453
|
* **Example** (Passing inputs through as outputs)
|
|
2652
1454
|
*
|
|
2653
|
-
* ```ts
|
|
2654
|
-
* import {
|
|
1455
|
+
* ```ts import.meta.vitest
|
|
1456
|
+
* import { Effect, Schedule } from "effect"
|
|
2655
1457
|
*
|
|
2656
|
-
* // Create a schedule that outputs the inputs instead of original outputs
|
|
2657
1458
|
* const inputSchedule = Schedule.passthrough(
|
|
2658
1459
|
* Schedule.exponential("100 millis").pipe(Schedule.upTo({ times: 3 }))
|
|
2659
1460
|
* )
|
|
2660
|
-
*
|
|
2661
1461
|
* const program = Effect.gen(function*() {
|
|
2662
|
-
*
|
|
2663
|
-
* yield*
|
|
2664
|
-
*
|
|
2665
|
-
* counter++
|
|
2666
|
-
* yield* Console.log(`Task ${counter} executed`)
|
|
2667
|
-
* return `result-${counter}`
|
|
2668
|
-
* }),
|
|
2669
|
-
* inputSchedule
|
|
2670
|
-
* )
|
|
1462
|
+
* const step = yield* Schedule.toStep(inputSchedule)
|
|
1463
|
+
* const [output] = yield* step(0, "input")
|
|
1464
|
+
* return output
|
|
2671
1465
|
* })
|
|
1466
|
+
*
|
|
1467
|
+
* await Effect.runPromise(program) // => "input"
|
|
2672
1468
|
* ```
|
|
2673
1469
|
*
|
|
2674
1470
|
* @category mapping
|
|
@@ -2700,53 +1496,17 @@ export const passthrough = <Output, Input, Error, Env>(
|
|
|
2700
1496
|
*
|
|
2701
1497
|
* **Example** (Limiting recurrences)
|
|
2702
1498
|
*
|
|
2703
|
-
* ```ts
|
|
2704
|
-
* import {
|
|
2705
|
-
*
|
|
2706
|
-
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
2707
|
-
*
|
|
2708
|
-
* // Basic recurs - retry at most 3 times
|
|
2709
|
-
* const maxThreeAttempts = Schedule.recurs(3)
|
|
2710
|
-
*
|
|
2711
|
-
* // Retry a failing operation at most 5 times
|
|
2712
|
-
* const program = Effect.gen(function*() {
|
|
2713
|
-
* let attempt = 0
|
|
2714
|
-
*
|
|
2715
|
-
* const result = yield* Effect.retry(
|
|
2716
|
-
* Effect.gen(function*() {
|
|
2717
|
-
* attempt++
|
|
2718
|
-
* yield* Console.log(`Attempt ${attempt}`)
|
|
2719
|
-
*
|
|
2720
|
-
* if (attempt < 4) {
|
|
2721
|
-
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
2722
|
-
* }
|
|
2723
|
-
*
|
|
2724
|
-
* return `Success on attempt ${attempt}`
|
|
2725
|
-
* }),
|
|
2726
|
-
* Schedule.recurs(5) // Will retry up to 5 times
|
|
2727
|
-
* )
|
|
2728
|
-
*
|
|
2729
|
-
* yield* Console.log(`Final result: ${result}`)
|
|
2730
|
-
* })
|
|
1499
|
+
* ```ts import.meta.vitest
|
|
1500
|
+
* import { Effect, Schedule } from "effect"
|
|
1501
|
+
* import { TestClock } from "effect/testing"
|
|
2731
1502
|
*
|
|
2732
|
-
*
|
|
2733
|
-
* const
|
|
2734
|
-
* Schedule.
|
|
2735
|
-
*
|
|
2736
|
-
* ])
|
|
2737
|
-
*
|
|
2738
|
-
* // Allow ten recurrences after the initial run
|
|
2739
|
-
* const tenRecurrences = Effect.gen(function*() {
|
|
2740
|
-
* yield* Console.log("Executing task...")
|
|
2741
|
-
* return "completed"
|
|
2742
|
-
* }).pipe(
|
|
2743
|
-
* Effect.repeat(Schedule.recurs(10))
|
|
1503
|
+
* const executions: Array<number> = []
|
|
1504
|
+
* const program = Effect.sync(() => executions.push(executions.length + 1)).pipe(
|
|
1505
|
+
* Effect.repeat(Schedule.recurs(3)),
|
|
1506
|
+
* Effect.as(executions)
|
|
2744
1507
|
* )
|
|
2745
1508
|
*
|
|
2746
|
-
*
|
|
2747
|
-
* const countingSchedule = Schedule.recurs(3).pipe(
|
|
2748
|
-
* Schedule.tap(({ output: count }) => Console.log(`Execution #${count + 1}`))
|
|
2749
|
-
* )
|
|
1509
|
+
* await Effect.runPromise(Effect.provide(program, TestClock.layer())) // => [1, 2, 3, 4]
|
|
2750
1510
|
* ```
|
|
2751
1511
|
*
|
|
2752
1512
|
* @see {@link upTo} for limiting an existing schedule
|
|
@@ -2767,46 +1527,15 @@ export const recurs = (times: number): Schedule<number> =>
|
|
|
2767
1527
|
*
|
|
2768
1528
|
* **Example** (Repeating with fixed spacing)
|
|
2769
1529
|
*
|
|
2770
|
-
* ```ts
|
|
2771
|
-
* import {
|
|
2772
|
-
*
|
|
2773
|
-
* // Basic spaced schedule - runs every 2 seconds
|
|
2774
|
-
* const everyTwoSeconds = Schedule.spaced("2 seconds")
|
|
2775
|
-
*
|
|
2776
|
-
* // Heartbeat that runs indefinitely with fixed spacing
|
|
2777
|
-
* const heartbeat = Effect.gen(function*() {
|
|
2778
|
-
* yield* Console.log("Heartbeat")
|
|
2779
|
-
* }).pipe(
|
|
2780
|
-
* Effect.repeat(everyTwoSeconds)
|
|
2781
|
-
* )
|
|
2782
|
-
*
|
|
2783
|
-
* // Limited repeat - run only 5 times with 1-second spacing
|
|
2784
|
-
* const limitedTask = Effect.gen(function*() {
|
|
2785
|
-
* yield* Console.log("Executing scheduled task...")
|
|
2786
|
-
* yield* Effect.sleep("500 millis") // simulate work
|
|
2787
|
-
* return "Task completed"
|
|
2788
|
-
* }).pipe(
|
|
2789
|
-
* Effect.repeat(
|
|
2790
|
-
* Schedule.spaced("1 second").pipe(Schedule.upTo({ times: 5 }))
|
|
2791
|
-
* )
|
|
2792
|
-
* )
|
|
2793
|
-
*
|
|
2794
|
-
* // Simple spaced schedule with limited repetitions
|
|
2795
|
-
* const limitedSpaced = Schedule.max([
|
|
2796
|
-
* Schedule.spaced("100 millis"),
|
|
2797
|
-
* Schedule.recurs(5) // at most 5 times
|
|
2798
|
-
* ])
|
|
1530
|
+
* ```ts import.meta.vitest
|
|
1531
|
+
* import { Duration, Effect, Schedule } from "effect"
|
|
2799
1532
|
*
|
|
2800
1533
|
* const program = Effect.gen(function*() {
|
|
2801
|
-
* yield*
|
|
2802
|
-
*
|
|
2803
|
-
* yield* Effect.repeat(
|
|
2804
|
-
* Effect.succeed("work item"),
|
|
2805
|
-
* limitedSpaced
|
|
2806
|
-
* )
|
|
2807
|
-
*
|
|
2808
|
-
* yield* Console.log("Completed executions")
|
|
1534
|
+
* const step = yield* Schedule.toStep(Schedule.spaced("2 seconds"))
|
|
1535
|
+
* return yield* step(0, undefined)
|
|
2809
1536
|
* })
|
|
1537
|
+
*
|
|
1538
|
+
* await Effect.runPromise(program) // => [0, Duration.seconds(2)]
|
|
2810
1539
|
* ```
|
|
2811
1540
|
*
|
|
2812
1541
|
* @see {@link fixed} for recurrence aligned to a regular cadence
|
|
@@ -2831,23 +1560,20 @@ export const spaced = (duration: Duration.Input): Schedule<number> => {
|
|
|
2831
1560
|
*
|
|
2832
1561
|
* **Example** (Tapping schedule metadata)
|
|
2833
1562
|
*
|
|
2834
|
-
* ```ts
|
|
2835
|
-
* import {
|
|
2836
|
-
*
|
|
2837
|
-
* const monitoredSchedule = Schedule.exponential("100 millis").pipe(
|
|
2838
|
-
* Schedule.upTo({ times: 5 }),
|
|
2839
|
-
* Schedule.tap((metadata) =>
|
|
2840
|
-
* Console.log(
|
|
2841
|
-
* `Attempt ${metadata.attempt} produced ${metadata.output} ` +
|
|
2842
|
-
* `after ${metadata.elapsed}ms; next delay is ${metadata.duration}`
|
|
2843
|
-
* )
|
|
2844
|
-
* )
|
|
2845
|
-
* )
|
|
1563
|
+
* ```ts import.meta.vitest
|
|
1564
|
+
* import { Effect, Schedule } from "effect"
|
|
2846
1565
|
*
|
|
2847
|
-
* const
|
|
2848
|
-
*
|
|
2849
|
-
*
|
|
1566
|
+
* const attempts: Array<number> = []
|
|
1567
|
+
* const monitoredSchedule = Schedule.recurs(2).pipe(
|
|
1568
|
+
* Schedule.tap((metadata) => Effect.sync(() => attempts.push(metadata.attempt)))
|
|
2850
1569
|
* )
|
|
1570
|
+
* const program = Effect.gen(function*() {
|
|
1571
|
+
* const step = yield* Schedule.toStep(monitoredSchedule)
|
|
1572
|
+
* const [output] = yield* step(0, undefined)
|
|
1573
|
+
* return { attempts, output }
|
|
1574
|
+
* })
|
|
1575
|
+
*
|
|
1576
|
+
* await Effect.runPromise(program) // => { attempts: [1], output: 0 }
|
|
2851
1577
|
* ```
|
|
2852
1578
|
*
|
|
2853
1579
|
* @category sequencing
|
|
@@ -2866,23 +1592,20 @@ export const tap: {
|
|
|
2866
1592
|
*
|
|
2867
1593
|
* **Example** (Tapping schedule metadata)
|
|
2868
1594
|
*
|
|
2869
|
-
* ```ts
|
|
2870
|
-
* import {
|
|
2871
|
-
*
|
|
2872
|
-
* const monitoredSchedule = Schedule.exponential("100 millis").pipe(
|
|
2873
|
-
* Schedule.upTo({ times: 5 }),
|
|
2874
|
-
* Schedule.tap((metadata) =>
|
|
2875
|
-
* Console.log(
|
|
2876
|
-
* `Attempt ${metadata.attempt} produced ${metadata.output} ` +
|
|
2877
|
-
* `after ${metadata.elapsed}ms; next delay is ${metadata.duration}`
|
|
2878
|
-
* )
|
|
2879
|
-
* )
|
|
2880
|
-
* )
|
|
1595
|
+
* ```ts import.meta.vitest
|
|
1596
|
+
* import { Effect, Schedule } from "effect"
|
|
2881
1597
|
*
|
|
2882
|
-
* const
|
|
2883
|
-
*
|
|
2884
|
-
*
|
|
1598
|
+
* const attempts: Array<number> = []
|
|
1599
|
+
* const monitoredSchedule = Schedule.recurs(2).pipe(
|
|
1600
|
+
* Schedule.tap((metadata) => Effect.sync(() => attempts.push(metadata.attempt)))
|
|
2885
1601
|
* )
|
|
1602
|
+
* const program = Effect.gen(function*() {
|
|
1603
|
+
* const step = yield* Schedule.toStep(monitoredSchedule)
|
|
1604
|
+
* const [output] = yield* step(0, undefined)
|
|
1605
|
+
* return { attempts, output }
|
|
1606
|
+
* })
|
|
1607
|
+
*
|
|
1608
|
+
* await Effect.runPromise(program) // => { attempts: [1], output: 0 }
|
|
2886
1609
|
* ```
|
|
2887
1610
|
*
|
|
2888
1611
|
* @category sequencing
|
|
@@ -2903,23 +1626,20 @@ export const tap: {
|
|
|
2903
1626
|
*
|
|
2904
1627
|
* **Example** (Tapping schedule metadata)
|
|
2905
1628
|
*
|
|
2906
|
-
* ```ts
|
|
2907
|
-
* import {
|
|
2908
|
-
*
|
|
2909
|
-
* const monitoredSchedule = Schedule.exponential("100 millis").pipe(
|
|
2910
|
-
* Schedule.upTo({ times: 5 }),
|
|
2911
|
-
* Schedule.tap((metadata) =>
|
|
2912
|
-
* Console.log(
|
|
2913
|
-
* `Attempt ${metadata.attempt} produced ${metadata.output} ` +
|
|
2914
|
-
* `after ${metadata.elapsed}ms; next delay is ${metadata.duration}`
|
|
2915
|
-
* )
|
|
2916
|
-
* )
|
|
2917
|
-
* )
|
|
1629
|
+
* ```ts import.meta.vitest
|
|
1630
|
+
* import { Effect, Schedule } from "effect"
|
|
2918
1631
|
*
|
|
2919
|
-
* const
|
|
2920
|
-
*
|
|
2921
|
-
*
|
|
1632
|
+
* const attempts: Array<number> = []
|
|
1633
|
+
* const monitoredSchedule = Schedule.recurs(2).pipe(
|
|
1634
|
+
* Schedule.tap((metadata) => Effect.sync(() => attempts.push(metadata.attempt)))
|
|
2922
1635
|
* )
|
|
1636
|
+
* const program = Effect.gen(function*() {
|
|
1637
|
+
* const step = yield* Schedule.toStep(monitoredSchedule)
|
|
1638
|
+
* const [output] = yield* step(0, undefined)
|
|
1639
|
+
* return { attempts, output }
|
|
1640
|
+
* })
|
|
1641
|
+
*
|
|
1642
|
+
* await Effect.runPromise(program) // => { attempts: [1], output: 0 }
|
|
2923
1643
|
* ```
|
|
2924
1644
|
*
|
|
2925
1645
|
* @category sequencing
|
|
@@ -2962,64 +1682,18 @@ export const tap: {
|
|
|
2962
1682
|
*
|
|
2963
1683
|
* **Example** (Limiting by duration and recurrence count)
|
|
2964
1684
|
*
|
|
2965
|
-
* ```ts
|
|
2966
|
-
* import {
|
|
2967
|
-
*
|
|
2968
|
-
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
2969
|
-
*
|
|
2970
|
-
* // Limit an infinite schedule to five recurrences
|
|
2971
|
-
* const limitedHeartbeat = Schedule.spaced("1 second").pipe(
|
|
2972
|
-
* Schedule.upTo({ times: 5 })
|
|
2973
|
-
* )
|
|
2974
|
-
*
|
|
2975
|
-
* const heartbeatProgram = Effect.gen(function*() {
|
|
2976
|
-
* yield* Effect.repeat(
|
|
2977
|
-
* Effect.gen(function*() {
|
|
2978
|
-
* yield* Console.log("Heartbeat")
|
|
2979
|
-
* return "pulse"
|
|
2980
|
-
* }),
|
|
2981
|
-
* limitedHeartbeat
|
|
2982
|
-
* )
|
|
2983
|
-
*
|
|
2984
|
-
* yield* Console.log("Heartbeat sequence completed")
|
|
2985
|
-
* })
|
|
2986
|
-
*
|
|
2987
|
-
* // Limit retry attempts by both count and elapsed time
|
|
2988
|
-
* const limitedRetry = Schedule.exponential("100 millis").pipe(
|
|
2989
|
-
* Schedule.upTo({
|
|
2990
|
-
* duration: "5 seconds",
|
|
2991
|
-
* times: 3
|
|
2992
|
-
* })
|
|
2993
|
-
* )
|
|
2994
|
-
*
|
|
2995
|
-
* const retryProgram = Effect.gen(function*() {
|
|
2996
|
-
* let attempt = 0
|
|
2997
|
-
*
|
|
2998
|
-
* const result = yield* Effect.retry(
|
|
2999
|
-
* Effect.gen(function*() {
|
|
3000
|
-
* attempt++
|
|
3001
|
-
* yield* Console.log(`Attempt ${attempt}`)
|
|
3002
|
-
*
|
|
3003
|
-
* if (attempt < 5) { // Will fail more than 3 times
|
|
3004
|
-
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
3005
|
-
* }
|
|
3006
|
-
*
|
|
3007
|
-
* return `Success on attempt ${attempt}`
|
|
3008
|
-
* }),
|
|
3009
|
-
* limitedRetry
|
|
3010
|
-
* )
|
|
1685
|
+
* ```ts import.meta.vitest
|
|
1686
|
+
* import { Effect, Schedule } from "effect"
|
|
1687
|
+
* import { TestClock } from "effect/testing"
|
|
3011
1688
|
*
|
|
3012
|
-
*
|
|
3013
|
-
*
|
|
3014
|
-
*
|
|
3015
|
-
*
|
|
3016
|
-
* )
|
|
1689
|
+
* const executions: Array<number> = []
|
|
1690
|
+
* const schedule = Schedule.forever.pipe(Schedule.upTo({ times: 2 }))
|
|
1691
|
+
* const program = Effect.sync(() => executions.push(executions.length + 1)).pipe(
|
|
1692
|
+
* Effect.repeat(schedule),
|
|
1693
|
+
* Effect.as(executions)
|
|
3017
1694
|
* )
|
|
3018
1695
|
*
|
|
3019
|
-
*
|
|
3020
|
-
* const unchanged = Schedule.fixed("500 millis").pipe(
|
|
3021
|
-
* Schedule.upTo({})
|
|
3022
|
-
* )
|
|
1696
|
+
* await Effect.runPromise(Effect.provide(program, TestClock.layer())) // => [1, 2, 3]
|
|
3023
1697
|
* ```
|
|
3024
1698
|
*
|
|
3025
1699
|
* @category filtering
|
|
@@ -3049,64 +1723,18 @@ export const upTo: {
|
|
|
3049
1723
|
*
|
|
3050
1724
|
* **Example** (Limiting by duration and recurrence count)
|
|
3051
1725
|
*
|
|
3052
|
-
* ```ts
|
|
3053
|
-
* import {
|
|
3054
|
-
*
|
|
3055
|
-
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
3056
|
-
*
|
|
3057
|
-
* // Limit an infinite schedule to five recurrences
|
|
3058
|
-
* const limitedHeartbeat = Schedule.spaced("1 second").pipe(
|
|
3059
|
-
* Schedule.upTo({ times: 5 })
|
|
3060
|
-
* )
|
|
3061
|
-
*
|
|
3062
|
-
* const heartbeatProgram = Effect.gen(function*() {
|
|
3063
|
-
* yield* Effect.repeat(
|
|
3064
|
-
* Effect.gen(function*() {
|
|
3065
|
-
* yield* Console.log("Heartbeat")
|
|
3066
|
-
* return "pulse"
|
|
3067
|
-
* }),
|
|
3068
|
-
* limitedHeartbeat
|
|
3069
|
-
* )
|
|
3070
|
-
*
|
|
3071
|
-
* yield* Console.log("Heartbeat sequence completed")
|
|
3072
|
-
* })
|
|
3073
|
-
*
|
|
3074
|
-
* // Limit retry attempts by both count and elapsed time
|
|
3075
|
-
* const limitedRetry = Schedule.exponential("100 millis").pipe(
|
|
3076
|
-
* Schedule.upTo({
|
|
3077
|
-
* duration: "5 seconds",
|
|
3078
|
-
* times: 3
|
|
3079
|
-
* })
|
|
3080
|
-
* )
|
|
3081
|
-
*
|
|
3082
|
-
* const retryProgram = Effect.gen(function*() {
|
|
3083
|
-
* let attempt = 0
|
|
3084
|
-
*
|
|
3085
|
-
* const result = yield* Effect.retry(
|
|
3086
|
-
* Effect.gen(function*() {
|
|
3087
|
-
* attempt++
|
|
3088
|
-
* yield* Console.log(`Attempt ${attempt}`)
|
|
3089
|
-
*
|
|
3090
|
-
* if (attempt < 5) { // Will fail more than 3 times
|
|
3091
|
-
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
3092
|
-
* }
|
|
3093
|
-
*
|
|
3094
|
-
* return `Success on attempt ${attempt}`
|
|
3095
|
-
* }),
|
|
3096
|
-
* limitedRetry
|
|
3097
|
-
* )
|
|
1726
|
+
* ```ts import.meta.vitest
|
|
1727
|
+
* import { Effect, Schedule } from "effect"
|
|
1728
|
+
* import { TestClock } from "effect/testing"
|
|
3098
1729
|
*
|
|
3099
|
-
*
|
|
3100
|
-
*
|
|
3101
|
-
*
|
|
3102
|
-
*
|
|
3103
|
-
* )
|
|
1730
|
+
* const executions: Array<number> = []
|
|
1731
|
+
* const schedule = Schedule.forever.pipe(Schedule.upTo({ times: 2 }))
|
|
1732
|
+
* const program = Effect.sync(() => executions.push(executions.length + 1)).pipe(
|
|
1733
|
+
* Effect.repeat(schedule),
|
|
1734
|
+
* Effect.as(executions)
|
|
3104
1735
|
* )
|
|
3105
1736
|
*
|
|
3106
|
-
*
|
|
3107
|
-
* const unchanged = Schedule.fixed("500 millis").pipe(
|
|
3108
|
-
* Schedule.upTo({})
|
|
3109
|
-
* )
|
|
1737
|
+
* await Effect.runPromise(Effect.provide(program, TestClock.layer())) // => [1, 2, 3]
|
|
3110
1738
|
* ```
|
|
3111
1739
|
*
|
|
3112
1740
|
* @category filtering
|
|
@@ -3143,64 +1771,18 @@ export const upTo: {
|
|
|
3143
1771
|
*
|
|
3144
1772
|
* **Example** (Limiting by duration and recurrence count)
|
|
3145
1773
|
*
|
|
3146
|
-
* ```ts
|
|
3147
|
-
* import {
|
|
3148
|
-
*
|
|
3149
|
-
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
3150
|
-
*
|
|
3151
|
-
* // Limit an infinite schedule to five recurrences
|
|
3152
|
-
* const limitedHeartbeat = Schedule.spaced("1 second").pipe(
|
|
3153
|
-
* Schedule.upTo({ times: 5 })
|
|
3154
|
-
* )
|
|
3155
|
-
*
|
|
3156
|
-
* const heartbeatProgram = Effect.gen(function*() {
|
|
3157
|
-
* yield* Effect.repeat(
|
|
3158
|
-
* Effect.gen(function*() {
|
|
3159
|
-
* yield* Console.log("Heartbeat")
|
|
3160
|
-
* return "pulse"
|
|
3161
|
-
* }),
|
|
3162
|
-
* limitedHeartbeat
|
|
3163
|
-
* )
|
|
3164
|
-
*
|
|
3165
|
-
* yield* Console.log("Heartbeat sequence completed")
|
|
3166
|
-
* })
|
|
3167
|
-
*
|
|
3168
|
-
* // Limit retry attempts by both count and elapsed time
|
|
3169
|
-
* const limitedRetry = Schedule.exponential("100 millis").pipe(
|
|
3170
|
-
* Schedule.upTo({
|
|
3171
|
-
* duration: "5 seconds",
|
|
3172
|
-
* times: 3
|
|
3173
|
-
* })
|
|
3174
|
-
* )
|
|
3175
|
-
*
|
|
3176
|
-
* const retryProgram = Effect.gen(function*() {
|
|
3177
|
-
* let attempt = 0
|
|
3178
|
-
*
|
|
3179
|
-
* const result = yield* Effect.retry(
|
|
3180
|
-
* Effect.gen(function*() {
|
|
3181
|
-
* attempt++
|
|
3182
|
-
* yield* Console.log(`Attempt ${attempt}`)
|
|
3183
|
-
*
|
|
3184
|
-
* if (attempt < 5) { // Will fail more than 3 times
|
|
3185
|
-
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
3186
|
-
* }
|
|
3187
|
-
*
|
|
3188
|
-
* return `Success on attempt ${attempt}`
|
|
3189
|
-
* }),
|
|
3190
|
-
* limitedRetry
|
|
3191
|
-
* )
|
|
1774
|
+
* ```ts import.meta.vitest
|
|
1775
|
+
* import { Effect, Schedule } from "effect"
|
|
1776
|
+
* import { TestClock } from "effect/testing"
|
|
3192
1777
|
*
|
|
3193
|
-
*
|
|
3194
|
-
*
|
|
3195
|
-
*
|
|
3196
|
-
*
|
|
3197
|
-
* )
|
|
1778
|
+
* const executions: Array<number> = []
|
|
1779
|
+
* const schedule = Schedule.forever.pipe(Schedule.upTo({ times: 2 }))
|
|
1780
|
+
* const program = Effect.sync(() => executions.push(executions.length + 1)).pipe(
|
|
1781
|
+
* Effect.repeat(schedule),
|
|
1782
|
+
* Effect.as(executions)
|
|
3198
1783
|
* )
|
|
3199
1784
|
*
|
|
3200
|
-
*
|
|
3201
|
-
* const unchanged = Schedule.fixed("500 millis").pipe(
|
|
3202
|
-
* Schedule.upTo({})
|
|
3203
|
-
* )
|
|
1785
|
+
* await Effect.runPromise(Effect.provide(program, TestClock.layer())) // => [1, 2, 3]
|
|
3204
1786
|
* ```
|
|
3205
1787
|
*
|
|
3206
1788
|
* @category filtering
|
|
@@ -3301,21 +1883,15 @@ export {
|
|
|
3301
1883
|
*
|
|
3302
1884
|
* **Example** (Repeating on aligned windows)
|
|
3303
1885
|
*
|
|
3304
|
-
* ```ts
|
|
3305
|
-
* import {
|
|
3306
|
-
*
|
|
3307
|
-
* // Execute tasks at regular intervals aligned to window boundaries
|
|
3308
|
-
* const windowSchedule = Schedule.windowed("5 seconds")
|
|
1886
|
+
* ```ts import.meta.vitest
|
|
1887
|
+
* import { Duration, Effect, Schedule } from "effect"
|
|
3309
1888
|
*
|
|
3310
1889
|
* const program = Effect.gen(function*() {
|
|
3311
|
-
* yield*
|
|
3312
|
-
*
|
|
3313
|
-
* yield* Console.log("Window task executed")
|
|
3314
|
-
* return "window-task"
|
|
3315
|
-
* }),
|
|
3316
|
-
* windowSchedule.pipe(Schedule.upTo({ times: 4 }))
|
|
3317
|
-
* )
|
|
1890
|
+
* const step = yield* Schedule.toStep(Schedule.windowed("5 seconds"))
|
|
1891
|
+
* return yield* step(0, undefined)
|
|
3318
1892
|
* })
|
|
1893
|
+
*
|
|
1894
|
+
* await Effect.runPromise(program) // => [0, Duration.seconds(5)]
|
|
3319
1895
|
* ```
|
|
3320
1896
|
*
|
|
3321
1897
|
* @category constructors
|
|
@@ -3341,21 +1917,18 @@ export const windowed = (interval: Duration.Input): Schedule<number> => {
|
|
|
3341
1917
|
*
|
|
3342
1918
|
* **Example** (Repeating forever)
|
|
3343
1919
|
*
|
|
3344
|
-
* ```ts
|
|
3345
|
-
* import {
|
|
1920
|
+
* ```ts import.meta.vitest
|
|
1921
|
+
* import { Effect, Schedule } from "effect"
|
|
1922
|
+
* import { TestClock } from "effect/testing"
|
|
3346
1923
|
*
|
|
3347
|
-
*
|
|
3348
|
-
* const
|
|
1924
|
+
* const executions: Array<number> = []
|
|
1925
|
+
* const schedule = Schedule.forever.pipe(Schedule.upTo({ times: 2 }))
|
|
1926
|
+
* const program = Effect.sync(() => executions.push(executions.length + 1)).pipe(
|
|
1927
|
+
* Effect.repeat(schedule),
|
|
1928
|
+
* Effect.as(executions)
|
|
1929
|
+
* )
|
|
3349
1930
|
*
|
|
3350
|
-
*
|
|
3351
|
-
* yield* Effect.repeat(
|
|
3352
|
-
* Effect.gen(function*() {
|
|
3353
|
-
* yield* Console.log("Running forever...")
|
|
3354
|
-
* return "continuous-task"
|
|
3355
|
-
* }),
|
|
3356
|
-
* infiniteSchedule.pipe(Schedule.upTo({ times: 5 })) // Limit for demo
|
|
3357
|
-
* )
|
|
3358
|
-
* })
|
|
1931
|
+
* await Effect.runPromise(Effect.provide(program, TestClock.layer())) // => [1, 2, 3]
|
|
3359
1932
|
* ```
|
|
3360
1933
|
*
|
|
3361
1934
|
* @category constructors
|
|
@@ -3405,12 +1978,13 @@ export {
|
|
|
3405
1978
|
*
|
|
3406
1979
|
* **Example** (Setting a schedule input type)
|
|
3407
1980
|
*
|
|
3408
|
-
* ```ts
|
|
1981
|
+
* ```ts import.meta.vitest
|
|
3409
1982
|
* import { Schedule } from "effect"
|
|
3410
1983
|
*
|
|
3411
1984
|
* const schedule = Schedule.recurs(3).pipe(
|
|
3412
1985
|
* Schedule.setInputType<string>()
|
|
3413
1986
|
* )
|
|
1987
|
+
* Schedule.isSchedule(schedule) // => true
|
|
3414
1988
|
* ```
|
|
3415
1989
|
*
|
|
3416
1990
|
* @category utility types
|