effect 4.0.0-beta.26 → 4.0.0-beta.28
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/Cause.d.ts +1 -1
- package/dist/ConfigProvider.d.ts +1 -1
- package/dist/Cron.d.ts +1 -1
- package/dist/Data.d.ts +3 -3
- package/dist/Data.d.ts.map +1 -1
- package/dist/Data.js +2 -2
- package/dist/Data.js.map +1 -1
- package/dist/Effect.d.ts +331 -206
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +113 -72
- package/dist/Effect.js.map +1 -1
- package/dist/Encoding.d.ts +1 -1
- package/dist/ErrorReporter.d.ts +2 -4
- package/dist/ErrorReporter.d.ts.map +1 -1
- package/dist/ErrorReporter.js +1 -3
- package/dist/ErrorReporter.js.map +1 -1
- package/dist/Exit.d.ts +24 -12
- package/dist/Exit.d.ts.map +1 -1
- package/dist/Exit.js +8 -4
- package/dist/Exit.js.map +1 -1
- package/dist/Fiber.d.ts +1 -0
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.js.map +1 -1
- package/dist/Graph.d.ts +1 -1
- package/dist/Layer.d.ts +112 -117
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +43 -44
- package/dist/Layer.js.map +1 -1
- package/dist/LayerMap.d.ts +4 -4
- package/dist/LayerMap.js +3 -3
- package/dist/ManagedRuntime.d.ts +1 -1
- package/dist/ManagedRuntime.js +1 -1
- package/dist/Metric.d.ts +2 -4
- package/dist/Metric.d.ts.map +1 -1
- package/dist/Metric.js +2 -4
- package/dist/Metric.js.map +1 -1
- package/dist/PlatformError.d.ts +2 -2
- package/dist/References.d.ts +6 -1
- package/dist/References.d.ts.map +1 -1
- package/dist/References.js +6 -1
- package/dist/References.js.map +1 -1
- package/dist/RequestResolver.d.ts +19 -19
- package/dist/RequestResolver.js +10 -10
- package/dist/RequestResolver.js.map +1 -1
- package/dist/Schedule.d.ts +144 -82
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +58 -32
- package/dist/Schedule.js.map +1 -1
- package/dist/Scheduler.d.ts +9 -0
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +11 -0
- package/dist/Scheduler.js.map +1 -1
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +3 -1
- package/dist/Schema.js.map +1 -1
- package/dist/Stdio.d.ts +6 -2
- package/dist/Stdio.d.ts.map +1 -1
- package/dist/Stdio.js +2 -2
- package/dist/Stdio.js.map +1 -1
- package/dist/Stream.d.ts +8 -4
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +8 -4
- package/dist/Stream.js.map +1 -1
- package/dist/Types.d.ts +1 -22
- package/dist/Types.d.ts.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/internal/effect.js +3 -1
- package/dist/internal/effect.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts +12 -28
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +4 -18
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/McpSchema.d.ts +20 -1
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.js +8 -0
- package/dist/unstable/ai/McpSchema.js.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts +65 -12
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js +159 -45
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/Toolkit.d.ts +1 -1
- package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
- package/dist/unstable/ai/Toolkit.js +4 -11
- package/dist/unstable/ai/Toolkit.js.map +1 -1
- package/dist/unstable/ai/internal/codec-transformer.js +0 -5
- package/dist/unstable/ai/internal/codec-transformer.js.map +1 -1
- package/dist/unstable/cli/CliError.d.ts +4 -4
- package/dist/unstable/cli/CliError.js +4 -4
- package/dist/unstable/cli/Primitive.d.ts +1 -1
- package/dist/unstable/cli/Primitive.js +1 -1
- package/dist/unstable/cli/Prompt.js +31 -0
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cluster/Message.d.ts +5 -5
- package/dist/unstable/cluster/Reply.d.ts +3 -3
- package/dist/unstable/encoding/Msgpack.d.ts +1 -1
- package/dist/unstable/encoding/Ndjson.d.ts +1 -1
- package/dist/unstable/encoding/Sse.d.ts +1 -1
- package/dist/unstable/eventlog/EventJournal.d.ts +1 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts +1 -1
- package/dist/unstable/http/Cookies.d.ts +45 -1
- package/dist/unstable/http/Cookies.d.ts.map +1 -1
- package/dist/unstable/http/Cookies.js +22 -0
- package/dist/unstable/http/Cookies.js.map +1 -1
- package/dist/unstable/http/Headers.d.ts +16 -0
- package/dist/unstable/http/Headers.d.ts.map +1 -1
- package/dist/unstable/http/Headers.js +11 -0
- package/dist/unstable/http/Headers.js.map +1 -1
- package/dist/unstable/http/HttpBody.d.ts +1 -1
- package/dist/unstable/http/HttpClientError.d.ts +7 -7
- package/dist/unstable/http/HttpClientRequest.d.ts +5 -0
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +21 -17
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpEffect.d.ts +7 -0
- package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
- package/dist/unstable/http/HttpEffect.js +6 -0
- package/dist/unstable/http/HttpEffect.js.map +1 -1
- package/dist/unstable/http/HttpServerError.d.ts +6 -6
- package/dist/unstable/http/HttpServerRequest.d.ts +11 -0
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRequest.js +291 -1
- package/dist/unstable/http/HttpServerRequest.js.map +1 -1
- package/dist/unstable/http/HttpServerResponse.d.ts +47 -1
- package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerResponse.js +227 -0
- package/dist/unstable/http/HttpServerResponse.js.map +1 -1
- package/dist/unstable/http/HttpStaticServer.d.ts +69 -0
- package/dist/unstable/http/HttpStaticServer.d.ts.map +1 -0
- package/dist/unstable/http/HttpStaticServer.js +353 -0
- package/dist/unstable/http/HttpStaticServer.js.map +1 -0
- package/dist/unstable/http/Multipart.d.ts +1 -1
- package/dist/unstable/http/UrlParams.d.ts +1 -1
- package/dist/unstable/http/index.d.ts +4 -0
- package/dist/unstable/http/index.d.ts.map +1 -1
- package/dist/unstable/http/index.js +4 -0
- package/dist/unstable/http/index.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +5 -0
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.d.ts +1 -0
- package/dist/unstable/httpapi/HttpApiGroup.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.d.ts +1 -1
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +4 -10
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts +4 -6
- package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.js +39 -9
- package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts +8 -8
- package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.js +46 -20
- package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts +1 -1
- package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.js.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.d.ts +5 -5
- package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +2 -2
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/rpc/Utils.js +1 -1
- package/dist/unstable/rpc/Utils.js.map +1 -1
- package/dist/unstable/schema/Model.d.ts +21 -0
- package/dist/unstable/schema/Model.d.ts.map +1 -1
- package/dist/unstable/schema/Model.js +15 -0
- package/dist/unstable/schema/Model.js.map +1 -1
- package/dist/unstable/socket/SocketServer.d.ts +3 -3
- package/dist/unstable/sql/Migrator.d.ts +1 -1
- package/dist/unstable/sql/SqlResolver.js +2 -2
- package/dist/unstable/sql/SqlResolver.js.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +1 -1
- package/package.json +1 -1
- package/src/Cause.ts +1 -1
- package/src/Data.ts +3 -4
- package/src/Effect.ts +331 -206
- package/src/ErrorReporter.ts +2 -4
- package/src/Exit.ts +24 -12
- package/src/Fiber.ts +1 -0
- package/src/Layer.ts +112 -117
- package/src/LayerMap.ts +4 -4
- package/src/ManagedRuntime.ts +1 -1
- package/src/Metric.ts +2 -4
- package/src/References.ts +6 -1
- package/src/RequestResolver.ts +20 -20
- package/src/Schedule.ts +144 -82
- package/src/Scheduler.ts +12 -0
- package/src/Schema.ts +3 -1
- package/src/Stdio.ts +8 -4
- package/src/Stream.ts +8 -4
- package/src/Types.ts +1 -23
- package/src/index.ts +5 -3
- package/src/internal/effect.ts +3 -0
- package/src/unstable/ai/LanguageModel.ts +16 -37
- package/src/unstable/ai/McpSchema.ts +14 -0
- package/src/unstable/ai/McpServer.ts +224 -53
- package/src/unstable/ai/Toolkit.ts +5 -14
- package/src/unstable/ai/internal/codec-transformer.ts +0 -7
- package/src/unstable/cli/CliError.ts +4 -4
- package/src/unstable/cli/Primitive.ts +1 -1
- package/src/unstable/cli/Prompt.ts +27 -0
- package/src/unstable/http/Cookies.ts +84 -0
- package/src/unstable/http/Headers.ts +34 -0
- package/src/unstable/http/HttpClientRequest.ts +21 -17
- package/src/unstable/http/HttpEffect.ts +8 -0
- package/src/unstable/http/HttpServerRequest.ts +388 -1
- package/src/unstable/http/HttpServerResponse.ts +328 -1
- package/src/unstable/http/HttpStaticServer.ts +456 -0
- package/src/unstable/http/index.ts +5 -0
- package/src/unstable/httpapi/HttpApiBuilder.ts +3 -0
- package/src/unstable/httpapi/HttpApiGroup.ts +1 -0
- package/src/unstable/reactivity/Atom.ts +20 -26
- package/src/unstable/reactivity/AtomHttpApi.ts +45 -11
- package/src/unstable/reactivity/AtomRpc.ts +48 -17
- package/src/unstable/rpc/Rpc.ts +1 -3
- package/src/unstable/rpc/RpcMiddleware.ts +12 -6
- package/src/unstable/rpc/RpcServer.ts +2 -2
- package/src/unstable/rpc/Utils.ts +1 -1
- package/src/unstable/schema/Model.ts +31 -0
- package/src/unstable/sql/SqlResolver.ts +2 -2
package/dist/Schedule.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ declare const TypeId = "~effect/Schedule";
|
|
|
31
31
|
* const program = Effect.gen(function*() {
|
|
32
32
|
* // Using retry schedule
|
|
33
33
|
* const result1 = yield* Effect.retry(
|
|
34
|
-
* Effect.fail("temporary error"),
|
|
34
|
+
* Effect.suspend(() => Math.random() > 0.5 ? Effect.fail("temporary error") : Effect.succeed("Success")),
|
|
35
35
|
* retrySchedule
|
|
36
36
|
* )
|
|
37
37
|
*
|
|
@@ -143,7 +143,7 @@ export declare const CurrentMetadata: ServiceMap.Reference<Metadata<unknown, unk
|
|
|
143
143
|
* Effect.gen(function*() {
|
|
144
144
|
* attempt++
|
|
145
145
|
* if (attempt < 3) {
|
|
146
|
-
* yield* Effect.fail(`Attempt ${attempt} failed`)
|
|
146
|
+
* return yield* Effect.fail(`Attempt ${attempt} failed`)
|
|
147
147
|
* }
|
|
148
148
|
* return `Success on attempt ${attempt}`
|
|
149
149
|
* }),
|
|
@@ -367,7 +367,9 @@ export declare const toStepWithSleep: <Output, Input, Error, Env>(schedule: Sche
|
|
|
367
367
|
*
|
|
368
368
|
* @example
|
|
369
369
|
* ```ts
|
|
370
|
-
* import { Console, Duration, Effect, Schedule } from "effect"
|
|
370
|
+
* import { Console, Data, Duration, Effect, Schedule } from "effect"
|
|
371
|
+
*
|
|
372
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
371
373
|
*
|
|
372
374
|
* // Add random jitter to schedule delays
|
|
373
375
|
* const jitteredSchedule = Schedule.addDelay(
|
|
@@ -463,7 +465,7 @@ export declare const toStepWithSleep: <Output, Input, Error, Env>(schedule: Sche
|
|
|
463
465
|
* Effect.gen(function*() {
|
|
464
466
|
* attempt++
|
|
465
467
|
* if (attempt < 5) {
|
|
466
|
-
* yield* Effect.fail(new
|
|
468
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
467
469
|
* }
|
|
468
470
|
* return `Success on attempt ${attempt}`
|
|
469
471
|
* }),
|
|
@@ -484,7 +486,9 @@ export declare const addDelay: {
|
|
|
484
486
|
*
|
|
485
487
|
* @example
|
|
486
488
|
* ```ts
|
|
487
|
-
* import { Console, Duration, Effect, Schedule } from "effect"
|
|
489
|
+
* import { Console, Data, Duration, Effect, Schedule } from "effect"
|
|
490
|
+
*
|
|
491
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
488
492
|
*
|
|
489
493
|
* // Add random jitter to schedule delays
|
|
490
494
|
* const jitteredSchedule = Schedule.addDelay(
|
|
@@ -580,7 +584,7 @@ export declare const addDelay: {
|
|
|
580
584
|
* Effect.gen(function*() {
|
|
581
585
|
* attempt++
|
|
582
586
|
* if (attempt < 5) {
|
|
583
|
-
* yield* Effect.fail(new
|
|
587
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
584
588
|
* }
|
|
585
589
|
* return `Success on attempt ${attempt}`
|
|
586
590
|
* }),
|
|
@@ -601,7 +605,9 @@ export declare const addDelay: {
|
|
|
601
605
|
*
|
|
602
606
|
* @example
|
|
603
607
|
* ```ts
|
|
604
|
-
* import { Console, Duration, Effect, Schedule } from "effect"
|
|
608
|
+
* import { Console, Data, Duration, Effect, Schedule } from "effect"
|
|
609
|
+
*
|
|
610
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
605
611
|
*
|
|
606
612
|
* // Add random jitter to schedule delays
|
|
607
613
|
* const jitteredSchedule = Schedule.addDelay(
|
|
@@ -697,7 +703,7 @@ export declare const addDelay: {
|
|
|
697
703
|
* Effect.gen(function*() {
|
|
698
704
|
* attempt++
|
|
699
705
|
* if (attempt < 5) {
|
|
700
|
-
* yield* Effect.fail(new
|
|
706
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
701
707
|
* }
|
|
702
708
|
* return `Success on attempt ${attempt}`
|
|
703
709
|
* }),
|
|
@@ -720,7 +726,9 @@ export declare const addDelay: {
|
|
|
720
726
|
*
|
|
721
727
|
* @example
|
|
722
728
|
* ```ts
|
|
723
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
729
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
730
|
+
*
|
|
731
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
724
732
|
*
|
|
725
733
|
* // First retry 3 times quickly, then switch to slower retries
|
|
726
734
|
* const quickRetries = Schedule.exponential("100 millis").pipe(
|
|
@@ -739,7 +747,7 @@ export declare const addDelay: {
|
|
|
739
747
|
* attempt++
|
|
740
748
|
* yield* Console.log(`Attempt ${attempt}`)
|
|
741
749
|
* if (attempt < 6) {
|
|
742
|
-
* yield* Effect.fail(new
|
|
750
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Failure ${attempt}` }))
|
|
743
751
|
* }
|
|
744
752
|
* return `Success on attempt ${attempt}`
|
|
745
753
|
* }),
|
|
@@ -759,7 +767,9 @@ export declare const andThen: {
|
|
|
759
767
|
*
|
|
760
768
|
* @example
|
|
761
769
|
* ```ts
|
|
762
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
770
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
771
|
+
*
|
|
772
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
763
773
|
*
|
|
764
774
|
* // First retry 3 times quickly, then switch to slower retries
|
|
765
775
|
* const quickRetries = Schedule.exponential("100 millis").pipe(
|
|
@@ -778,7 +788,7 @@ export declare const andThen: {
|
|
|
778
788
|
* attempt++
|
|
779
789
|
* yield* Console.log(`Attempt ${attempt}`)
|
|
780
790
|
* if (attempt < 6) {
|
|
781
|
-
* yield* Effect.fail(new
|
|
791
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Failure ${attempt}` }))
|
|
782
792
|
* }
|
|
783
793
|
* return `Success on attempt ${attempt}`
|
|
784
794
|
* }),
|
|
@@ -798,7 +808,9 @@ export declare const andThen: {
|
|
|
798
808
|
*
|
|
799
809
|
* @example
|
|
800
810
|
* ```ts
|
|
801
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
811
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
812
|
+
*
|
|
813
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
802
814
|
*
|
|
803
815
|
* // First retry 3 times quickly, then switch to slower retries
|
|
804
816
|
* const quickRetries = Schedule.exponential("100 millis").pipe(
|
|
@@ -817,7 +829,7 @@ export declare const andThen: {
|
|
|
817
829
|
* attempt++
|
|
818
830
|
* yield* Console.log(`Attempt ${attempt}`)
|
|
819
831
|
* if (attempt < 6) {
|
|
820
|
-
* yield* Effect.fail(new
|
|
832
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Failure ${attempt}` }))
|
|
821
833
|
* }
|
|
822
834
|
* return `Success on attempt ${attempt}`
|
|
823
835
|
* }),
|
|
@@ -962,7 +974,9 @@ export declare const andThenResult: {
|
|
|
962
974
|
*
|
|
963
975
|
* @example
|
|
964
976
|
* ```ts
|
|
965
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
977
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
978
|
+
*
|
|
979
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
966
980
|
*
|
|
967
981
|
* // Both schedules must want to continue for the combined schedule to continue
|
|
968
982
|
* const timeLimit = Schedule.spaced("1 second").pipe(Schedule.take(5)) // max 5 times
|
|
@@ -1004,7 +1018,7 @@ export declare const andThenResult: {
|
|
|
1004
1018
|
* yield* Console.log(`Retry attempt ${attempt}`)
|
|
1005
1019
|
*
|
|
1006
1020
|
* if (attempt < 3) {
|
|
1007
|
-
* yield* Effect.fail(new
|
|
1021
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
1008
1022
|
* }
|
|
1009
1023
|
*
|
|
1010
1024
|
* return `Success on attempt ${attempt}`
|
|
@@ -1030,7 +1044,9 @@ export declare const both: {
|
|
|
1030
1044
|
*
|
|
1031
1045
|
* @example
|
|
1032
1046
|
* ```ts
|
|
1033
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
1047
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
1048
|
+
*
|
|
1049
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
1034
1050
|
*
|
|
1035
1051
|
* // Both schedules must want to continue for the combined schedule to continue
|
|
1036
1052
|
* const timeLimit = Schedule.spaced("1 second").pipe(Schedule.take(5)) // max 5 times
|
|
@@ -1072,7 +1088,7 @@ export declare const both: {
|
|
|
1072
1088
|
* yield* Console.log(`Retry attempt ${attempt}`)
|
|
1073
1089
|
*
|
|
1074
1090
|
* if (attempt < 3) {
|
|
1075
|
-
* yield* Effect.fail(new
|
|
1091
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
1076
1092
|
* }
|
|
1077
1093
|
*
|
|
1078
1094
|
* return `Success on attempt ${attempt}`
|
|
@@ -1098,7 +1114,9 @@ export declare const both: {
|
|
|
1098
1114
|
*
|
|
1099
1115
|
* @example
|
|
1100
1116
|
* ```ts
|
|
1101
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
1117
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
1118
|
+
*
|
|
1119
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
1102
1120
|
*
|
|
1103
1121
|
* // Both schedules must want to continue for the combined schedule to continue
|
|
1104
1122
|
* const timeLimit = Schedule.spaced("1 second").pipe(Schedule.take(5)) // max 5 times
|
|
@@ -1140,7 +1158,7 @@ export declare const both: {
|
|
|
1140
1158
|
* yield* Console.log(`Retry attempt ${attempt}`)
|
|
1141
1159
|
*
|
|
1142
1160
|
* if (attempt < 3) {
|
|
1143
|
-
* yield* Effect.fail(new
|
|
1161
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
1144
1162
|
* }
|
|
1145
1163
|
*
|
|
1146
1164
|
* return `Success on attempt ${attempt}`
|
|
@@ -1485,7 +1503,9 @@ export declare const bothWith: {
|
|
|
1485
1503
|
*
|
|
1486
1504
|
* @example
|
|
1487
1505
|
* ```ts
|
|
1488
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
1506
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
1507
|
+
*
|
|
1508
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
1489
1509
|
*
|
|
1490
1510
|
* // Compose a quick retry phase followed by slower retry phase
|
|
1491
1511
|
* const fastRetries = Schedule.exponential("100 millis").pipe(
|
|
@@ -1509,7 +1529,7 @@ export declare const bothWith: {
|
|
|
1509
1529
|
* yield* Console.log(`Attempt ${attempt}`)
|
|
1510
1530
|
*
|
|
1511
1531
|
* if (attempt < 7) { // Needs both phases to succeed
|
|
1512
|
-
* yield* Effect.fail(new
|
|
1532
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
1513
1533
|
* }
|
|
1514
1534
|
*
|
|
1515
1535
|
* return `Success on attempt ${attempt}`
|
|
@@ -1548,7 +1568,9 @@ export declare const compose: {
|
|
|
1548
1568
|
*
|
|
1549
1569
|
* @example
|
|
1550
1570
|
* ```ts
|
|
1551
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
1571
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
1572
|
+
*
|
|
1573
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
1552
1574
|
*
|
|
1553
1575
|
* // Compose a quick retry phase followed by slower retry phase
|
|
1554
1576
|
* const fastRetries = Schedule.exponential("100 millis").pipe(
|
|
@@ -1572,7 +1594,7 @@ export declare const compose: {
|
|
|
1572
1594
|
* yield* Console.log(`Attempt ${attempt}`)
|
|
1573
1595
|
*
|
|
1574
1596
|
* if (attempt < 7) { // Needs both phases to succeed
|
|
1575
|
-
* yield* Effect.fail(new
|
|
1597
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
1576
1598
|
* }
|
|
1577
1599
|
*
|
|
1578
1600
|
* return `Success on attempt ${attempt}`
|
|
@@ -1611,7 +1633,9 @@ export declare const compose: {
|
|
|
1611
1633
|
*
|
|
1612
1634
|
* @example
|
|
1613
1635
|
* ```ts
|
|
1614
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
1636
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
1637
|
+
*
|
|
1638
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
1615
1639
|
*
|
|
1616
1640
|
* // Compose a quick retry phase followed by slower retry phase
|
|
1617
1641
|
* const fastRetries = Schedule.exponential("100 millis").pipe(
|
|
@@ -1635,7 +1659,7 @@ export declare const compose: {
|
|
|
1635
1659
|
* yield* Console.log(`Attempt ${attempt}`)
|
|
1636
1660
|
*
|
|
1637
1661
|
* if (attempt < 7) { // Needs both phases to succeed
|
|
1638
|
-
* yield* Effect.fail(new
|
|
1662
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
1639
1663
|
* }
|
|
1640
1664
|
*
|
|
1641
1665
|
* return `Success on attempt ${attempt}`
|
|
@@ -2048,7 +2072,9 @@ export declare const collectWhile: {
|
|
|
2048
2072
|
*
|
|
2049
2073
|
* @example
|
|
2050
2074
|
* ```ts
|
|
2051
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
2075
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
2076
|
+
*
|
|
2077
|
+
* class ScheduledTaskError extends Data.TaggedError("ScheduledTaskError")<{ readonly message: string }> {}
|
|
2052
2078
|
*
|
|
2053
2079
|
* // Run every minute
|
|
2054
2080
|
* const everyMinute = Schedule.cron("* * * * *")
|
|
@@ -2149,7 +2175,7 @@ export declare const collectWhile: {
|
|
|
2149
2175
|
* yield* Console.log("Complex scheduled task...")
|
|
2150
2176
|
* // Simulate occasional failures
|
|
2151
2177
|
* if (Math.random() < 0.3) {
|
|
2152
|
-
* yield* Effect.fail(new
|
|
2178
|
+
* return yield* Effect.fail(new ScheduledTaskError({ message: "Scheduled task failed" }))
|
|
2153
2179
|
* }
|
|
2154
2180
|
* return "success"
|
|
2155
2181
|
* }),
|
|
@@ -2172,7 +2198,9 @@ export declare const cron: {
|
|
|
2172
2198
|
*
|
|
2173
2199
|
* @example
|
|
2174
2200
|
* ```ts
|
|
2175
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
2201
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
2202
|
+
*
|
|
2203
|
+
* class ScheduledTaskError extends Data.TaggedError("ScheduledTaskError")<{ readonly message: string }> {}
|
|
2176
2204
|
*
|
|
2177
2205
|
* // Run every minute
|
|
2178
2206
|
* const everyMinute = Schedule.cron("* * * * *")
|
|
@@ -2273,7 +2301,7 @@ export declare const cron: {
|
|
|
2273
2301
|
* yield* Console.log("Complex scheduled task...")
|
|
2274
2302
|
* // Simulate occasional failures
|
|
2275
2303
|
* if (Math.random() < 0.3) {
|
|
2276
|
-
* yield* Effect.fail(new
|
|
2304
|
+
* return yield* Effect.fail(new ScheduledTaskError({ message: "Scheduled task failed" }))
|
|
2277
2305
|
* }
|
|
2278
2306
|
* return "success"
|
|
2279
2307
|
* }),
|
|
@@ -2296,7 +2324,9 @@ export declare const cron: {
|
|
|
2296
2324
|
*
|
|
2297
2325
|
* @example
|
|
2298
2326
|
* ```ts
|
|
2299
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
2327
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
2328
|
+
*
|
|
2329
|
+
* class ScheduledTaskError extends Data.TaggedError("ScheduledTaskError")<{ readonly message: string }> {}
|
|
2300
2330
|
*
|
|
2301
2331
|
* // Run every minute
|
|
2302
2332
|
* const everyMinute = Schedule.cron("* * * * *")
|
|
@@ -2397,7 +2427,7 @@ export declare const cron: {
|
|
|
2397
2427
|
* yield* Console.log("Complex scheduled task...")
|
|
2398
2428
|
* // Simulate occasional failures
|
|
2399
2429
|
* if (Math.random() < 0.3) {
|
|
2400
|
-
* yield* Effect.fail(new
|
|
2430
|
+
* return yield* Effect.fail(new ScheduledTaskError({ message: "Scheduled task failed" }))
|
|
2401
2431
|
* }
|
|
2402
2432
|
* return "success"
|
|
2403
2433
|
* }),
|
|
@@ -2515,7 +2545,9 @@ export declare const duration: (durationInput: Duration.Input) => Schedule<Durat
|
|
|
2515
2545
|
*
|
|
2516
2546
|
* @example
|
|
2517
2547
|
* ```ts
|
|
2518
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
2548
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
2549
|
+
*
|
|
2550
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
2519
2551
|
*
|
|
2520
2552
|
* // Run a task for exactly 5 seconds, regardless of how many iterations
|
|
2521
2553
|
* const fiveSecondSchedule = Schedule.during("5 seconds")
|
|
@@ -2577,7 +2609,7 @@ export declare const duration: (durationInput: Duration.Input) => Schedule<Durat
|
|
|
2577
2609
|
* yield* Console.log(`Retry attempt ${attempt}`)
|
|
2578
2610
|
*
|
|
2579
2611
|
* if (Math.random() < 0.8) { // 80% failure rate
|
|
2580
|
-
* yield* Effect.fail(new
|
|
2612
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
2581
2613
|
* }
|
|
2582
2614
|
*
|
|
2583
2615
|
* return `Success on attempt ${attempt}`
|
|
@@ -2602,7 +2634,9 @@ export declare const during: (duration: Duration.Input) => Schedule<Duration.Dur
|
|
|
2602
2634
|
*
|
|
2603
2635
|
* @example
|
|
2604
2636
|
* ```ts
|
|
2605
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
2637
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
2638
|
+
*
|
|
2639
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
2606
2640
|
*
|
|
2607
2641
|
* // Either continues as long as at least one schedule wants to continue
|
|
2608
2642
|
* const timeBasedSchedule = Schedule.spaced("2 seconds").pipe(Schedule.take(3))
|
|
@@ -2646,7 +2680,7 @@ export declare const during: (duration: Duration.Input) => Schedule<Duration.Dur
|
|
|
2646
2680
|
* yield* Console.log(`Retry attempt ${attempt}`)
|
|
2647
2681
|
*
|
|
2648
2682
|
* if (attempt < 6) {
|
|
2649
|
-
* yield* Effect.fail(new
|
|
2683
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
2650
2684
|
* }
|
|
2651
2685
|
*
|
|
2652
2686
|
* return `Success on attempt ${attempt}`
|
|
@@ -2672,7 +2706,9 @@ export declare const either: {
|
|
|
2672
2706
|
*
|
|
2673
2707
|
* @example
|
|
2674
2708
|
* ```ts
|
|
2675
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
2709
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
2710
|
+
*
|
|
2711
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
2676
2712
|
*
|
|
2677
2713
|
* // Either continues as long as at least one schedule wants to continue
|
|
2678
2714
|
* const timeBasedSchedule = Schedule.spaced("2 seconds").pipe(Schedule.take(3))
|
|
@@ -2716,7 +2752,7 @@ export declare const either: {
|
|
|
2716
2752
|
* yield* Console.log(`Retry attempt ${attempt}`)
|
|
2717
2753
|
*
|
|
2718
2754
|
* if (attempt < 6) {
|
|
2719
|
-
* yield* Effect.fail(new
|
|
2755
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
2720
2756
|
* }
|
|
2721
2757
|
*
|
|
2722
2758
|
* return `Success on attempt ${attempt}`
|
|
@@ -2742,7 +2778,9 @@ export declare const either: {
|
|
|
2742
2778
|
*
|
|
2743
2779
|
* @example
|
|
2744
2780
|
* ```ts
|
|
2745
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
2781
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
2782
|
+
*
|
|
2783
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
2746
2784
|
*
|
|
2747
2785
|
* // Either continues as long as at least one schedule wants to continue
|
|
2748
2786
|
* const timeBasedSchedule = Schedule.spaced("2 seconds").pipe(Schedule.take(3))
|
|
@@ -2786,7 +2824,7 @@ export declare const either: {
|
|
|
2786
2824
|
* yield* Console.log(`Retry attempt ${attempt}`)
|
|
2787
2825
|
*
|
|
2788
2826
|
* if (attempt < 6) {
|
|
2789
|
-
* yield* Effect.fail(new
|
|
2827
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
2790
2828
|
* }
|
|
2791
2829
|
*
|
|
2792
2830
|
* return `Success on attempt ${attempt}`
|
|
@@ -3176,7 +3214,9 @@ export declare const elapsed: Schedule<Duration.Duration>;
|
|
|
3176
3214
|
*
|
|
3177
3215
|
* @example
|
|
3178
3216
|
* ```ts
|
|
3179
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
3217
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
3218
|
+
*
|
|
3219
|
+
* class RetryFailure extends Data.TaggedError("RetryFailure")<{ readonly message: string }> {}
|
|
3180
3220
|
*
|
|
3181
3221
|
* // Basic exponential backoff with default factor of 2
|
|
3182
3222
|
* const basicExponential = Schedule.exponential("100 millis")
|
|
@@ -3199,7 +3239,7 @@ export declare const elapsed: Schedule<Duration.Duration>;
|
|
|
3199
3239
|
* attempt++
|
|
3200
3240
|
* if (attempt < 4) {
|
|
3201
3241
|
* yield* Console.log(`Attempt ${attempt} failed, retrying...`)
|
|
3202
|
-
* yield* Effect.fail(new
|
|
3242
|
+
* return yield* Effect.fail(new RetryFailure({ message: `Failure ${attempt}` }))
|
|
3203
3243
|
* }
|
|
3204
3244
|
* return `Success on attempt ${attempt}`
|
|
3205
3245
|
* }),
|
|
@@ -3223,7 +3263,9 @@ export declare const exponential: (base: Duration.Input, factor?: number) => Sch
|
|
|
3223
3263
|
*
|
|
3224
3264
|
* @example
|
|
3225
3265
|
* ```ts
|
|
3226
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
3266
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
3267
|
+
*
|
|
3268
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
3227
3269
|
*
|
|
3228
3270
|
* // Basic fibonacci schedule starting with 100ms
|
|
3229
3271
|
* const fibSchedule = Schedule.fibonacci("100 millis")
|
|
@@ -3239,7 +3281,7 @@ export declare const exponential: (base: Duration.Input, factor?: number) => Sch
|
|
|
3239
3281
|
* yield* Console.log(`Attempt ${attempt}`)
|
|
3240
3282
|
*
|
|
3241
3283
|
* if (attempt < 5) {
|
|
3242
|
-
* yield* Effect.fail(new
|
|
3284
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
3243
3285
|
* }
|
|
3244
3286
|
*
|
|
3245
3287
|
* return `Success on attempt ${attempt}`
|
|
@@ -3678,7 +3720,9 @@ export declare const passthrough: <Output, Input, Error, Env>(self: Schedule<Out
|
|
|
3678
3720
|
*
|
|
3679
3721
|
* @example
|
|
3680
3722
|
* ```ts
|
|
3681
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
3723
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
3724
|
+
*
|
|
3725
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
3682
3726
|
*
|
|
3683
3727
|
* // Basic recurs - retry at most 3 times
|
|
3684
3728
|
* const maxThreeAttempts = Schedule.recurs(3)
|
|
@@ -3693,7 +3737,7 @@ export declare const passthrough: <Output, Input, Error, Env>(self: Schedule<Out
|
|
|
3693
3737
|
* yield* Console.log(`Attempt ${attempt}`)
|
|
3694
3738
|
*
|
|
3695
3739
|
* if (attempt < 4) {
|
|
3696
|
-
* yield* Effect.fail(new
|
|
3740
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
3697
3741
|
* }
|
|
3698
3742
|
*
|
|
3699
3743
|
* return `Success on attempt ${attempt}`
|
|
@@ -4121,12 +4165,14 @@ export declare const spaced: (duration: Duration.Input) => Schedule<number>;
|
|
|
4121
4165
|
*
|
|
4122
4166
|
* @example
|
|
4123
4167
|
* ```ts
|
|
4124
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
4168
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
4169
|
+
*
|
|
4170
|
+
* class RetryError extends Data.TaggedError("RetryError")<{ readonly message: string }> {}
|
|
4125
4171
|
*
|
|
4126
4172
|
* // Log retry errors for debugging
|
|
4127
4173
|
* const errorLoggingSchedule = Schedule.exponential("100 millis").pipe(
|
|
4128
4174
|
* Schedule.take(3),
|
|
4129
|
-
* Schedule.tapInput((error:
|
|
4175
|
+
* Schedule.tapInput((error: RetryError) =>
|
|
4130
4176
|
* Console.log(`Retry triggered by error: ${String(error)}`)
|
|
4131
4177
|
* )
|
|
4132
4178
|
* )
|
|
@@ -4138,7 +4184,7 @@ export declare const spaced: (duration: Duration.Input) => Schedule<number>;
|
|
|
4138
4184
|
* Effect.gen(function*() {
|
|
4139
4185
|
* attempt++
|
|
4140
4186
|
* if (attempt < 4) {
|
|
4141
|
-
* yield* Effect.fail(new
|
|
4187
|
+
* return yield* Effect.fail(new RetryError({ message: `Network timeout on attempt ${attempt}` }))
|
|
4142
4188
|
* }
|
|
4143
4189
|
* return `Success on attempt ${attempt}`
|
|
4144
4190
|
* }),
|
|
@@ -4187,7 +4233,7 @@ export declare const spaced: (duration: Duration.Input) => Schedule<number>;
|
|
|
4187
4233
|
* // Conditional alerting based on input
|
|
4188
4234
|
* const alertingSchedule = Schedule.exponential("200 millis").pipe(
|
|
4189
4235
|
* Schedule.take(6),
|
|
4190
|
-
* Schedule.tapInput((error:
|
|
4236
|
+
* Schedule.tapInput((error: RetryError) =>
|
|
4191
4237
|
* Effect.gen(function*() {
|
|
4192
4238
|
* if (String(error).includes("critical")) {
|
|
4193
4239
|
* yield* Console.log(`🚨 CRITICAL ERROR: ${String(error)}`)
|
|
@@ -4209,7 +4255,7 @@ export declare const spaced: (duration: Duration.Input) => Schedule<number>;
|
|
|
4209
4255
|
* const errorType = isCritical
|
|
4210
4256
|
* ? "critical database failure"
|
|
4211
4257
|
* : "temporary network issue"
|
|
4212
|
-
* yield* Effect.fail(new
|
|
4258
|
+
* return yield* Effect.fail(new RetryError({ message: errorType }))
|
|
4213
4259
|
* }),
|
|
4214
4260
|
* alertingSchedule
|
|
4215
4261
|
* ).pipe(
|
|
@@ -4222,10 +4268,10 @@ export declare const spaced: (duration: Duration.Input) => Schedule<number>;
|
|
|
4222
4268
|
* // Chain multiple input taps for different purposes
|
|
4223
4269
|
* const comprehensiveSchedule = Schedule.fibonacci("100 millis").pipe(
|
|
4224
4270
|
* Schedule.take(5),
|
|
4225
|
-
* Schedule.tapInput((error:
|
|
4226
|
-
* Console.log(`Error occurred: ${error.
|
|
4271
|
+
* Schedule.tapInput((error: RetryError) =>
|
|
4272
|
+
* Console.log(`Error occurred: ${error._tag}`)
|
|
4227
4273
|
* ),
|
|
4228
|
-
* Schedule.tapInput((error:
|
|
4274
|
+
* Schedule.tapInput((error: RetryError) =>
|
|
4229
4275
|
* String(error).length > 20
|
|
4230
4276
|
* ? Console.log("📝 Long error message detected")
|
|
4231
4277
|
* : Effect.void
|
|
@@ -4244,12 +4290,14 @@ export declare const tapInput: {
|
|
|
4244
4290
|
*
|
|
4245
4291
|
* @example
|
|
4246
4292
|
* ```ts
|
|
4247
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
4293
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
4294
|
+
*
|
|
4295
|
+
* class RetryError extends Data.TaggedError("RetryError")<{ readonly message: string }> {}
|
|
4248
4296
|
*
|
|
4249
4297
|
* // Log retry errors for debugging
|
|
4250
4298
|
* const errorLoggingSchedule = Schedule.exponential("100 millis").pipe(
|
|
4251
4299
|
* Schedule.take(3),
|
|
4252
|
-
* Schedule.tapInput((error:
|
|
4300
|
+
* Schedule.tapInput((error: RetryError) =>
|
|
4253
4301
|
* Console.log(`Retry triggered by error: ${String(error)}`)
|
|
4254
4302
|
* )
|
|
4255
4303
|
* )
|
|
@@ -4261,7 +4309,7 @@ export declare const tapInput: {
|
|
|
4261
4309
|
* Effect.gen(function*() {
|
|
4262
4310
|
* attempt++
|
|
4263
4311
|
* if (attempt < 4) {
|
|
4264
|
-
* yield* Effect.fail(new
|
|
4312
|
+
* return yield* Effect.fail(new RetryError({ message: `Network timeout on attempt ${attempt}` }))
|
|
4265
4313
|
* }
|
|
4266
4314
|
* return `Success on attempt ${attempt}`
|
|
4267
4315
|
* }),
|
|
@@ -4310,7 +4358,7 @@ export declare const tapInput: {
|
|
|
4310
4358
|
* // Conditional alerting based on input
|
|
4311
4359
|
* const alertingSchedule = Schedule.exponential("200 millis").pipe(
|
|
4312
4360
|
* Schedule.take(6),
|
|
4313
|
-
* Schedule.tapInput((error:
|
|
4361
|
+
* Schedule.tapInput((error: RetryError) =>
|
|
4314
4362
|
* Effect.gen(function*() {
|
|
4315
4363
|
* if (String(error).includes("critical")) {
|
|
4316
4364
|
* yield* Console.log(`🚨 CRITICAL ERROR: ${String(error)}`)
|
|
@@ -4332,7 +4380,7 @@ export declare const tapInput: {
|
|
|
4332
4380
|
* const errorType = isCritical
|
|
4333
4381
|
* ? "critical database failure"
|
|
4334
4382
|
* : "temporary network issue"
|
|
4335
|
-
* yield* Effect.fail(new
|
|
4383
|
+
* return yield* Effect.fail(new RetryError({ message: errorType }))
|
|
4336
4384
|
* }),
|
|
4337
4385
|
* alertingSchedule
|
|
4338
4386
|
* ).pipe(
|
|
@@ -4345,10 +4393,10 @@ export declare const tapInput: {
|
|
|
4345
4393
|
* // Chain multiple input taps for different purposes
|
|
4346
4394
|
* const comprehensiveSchedule = Schedule.fibonacci("100 millis").pipe(
|
|
4347
4395
|
* Schedule.take(5),
|
|
4348
|
-
* Schedule.tapInput((error:
|
|
4349
|
-
* Console.log(`Error occurred: ${error.
|
|
4396
|
+
* Schedule.tapInput((error: RetryError) =>
|
|
4397
|
+
* Console.log(`Error occurred: ${error._tag}`)
|
|
4350
4398
|
* ),
|
|
4351
|
-
* Schedule.tapInput((error:
|
|
4399
|
+
* Schedule.tapInput((error: RetryError) =>
|
|
4352
4400
|
* String(error).length > 20
|
|
4353
4401
|
* ? Console.log("📝 Long error message detected")
|
|
4354
4402
|
* : Effect.void
|
|
@@ -4367,12 +4415,14 @@ export declare const tapInput: {
|
|
|
4367
4415
|
*
|
|
4368
4416
|
* @example
|
|
4369
4417
|
* ```ts
|
|
4370
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
4418
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
4419
|
+
*
|
|
4420
|
+
* class RetryError extends Data.TaggedError("RetryError")<{ readonly message: string }> {}
|
|
4371
4421
|
*
|
|
4372
4422
|
* // Log retry errors for debugging
|
|
4373
4423
|
* const errorLoggingSchedule = Schedule.exponential("100 millis").pipe(
|
|
4374
4424
|
* Schedule.take(3),
|
|
4375
|
-
* Schedule.tapInput((error:
|
|
4425
|
+
* Schedule.tapInput((error: RetryError) =>
|
|
4376
4426
|
* Console.log(`Retry triggered by error: ${String(error)}`)
|
|
4377
4427
|
* )
|
|
4378
4428
|
* )
|
|
@@ -4384,7 +4434,7 @@ export declare const tapInput: {
|
|
|
4384
4434
|
* Effect.gen(function*() {
|
|
4385
4435
|
* attempt++
|
|
4386
4436
|
* if (attempt < 4) {
|
|
4387
|
-
* yield* Effect.fail(new
|
|
4437
|
+
* return yield* Effect.fail(new RetryError({ message: `Network timeout on attempt ${attempt}` }))
|
|
4388
4438
|
* }
|
|
4389
4439
|
* return `Success on attempt ${attempt}`
|
|
4390
4440
|
* }),
|
|
@@ -4433,7 +4483,7 @@ export declare const tapInput: {
|
|
|
4433
4483
|
* // Conditional alerting based on input
|
|
4434
4484
|
* const alertingSchedule = Schedule.exponential("200 millis").pipe(
|
|
4435
4485
|
* Schedule.take(6),
|
|
4436
|
-
* Schedule.tapInput((error:
|
|
4486
|
+
* Schedule.tapInput((error: RetryError) =>
|
|
4437
4487
|
* Effect.gen(function*() {
|
|
4438
4488
|
* if (String(error).includes("critical")) {
|
|
4439
4489
|
* yield* Console.log(`🚨 CRITICAL ERROR: ${String(error)}`)
|
|
@@ -4455,7 +4505,7 @@ export declare const tapInput: {
|
|
|
4455
4505
|
* const errorType = isCritical
|
|
4456
4506
|
* ? "critical database failure"
|
|
4457
4507
|
* : "temporary network issue"
|
|
4458
|
-
* yield* Effect.fail(new
|
|
4508
|
+
* return yield* Effect.fail(new RetryError({ message: errorType }))
|
|
4459
4509
|
* }),
|
|
4460
4510
|
* alertingSchedule
|
|
4461
4511
|
* ).pipe(
|
|
@@ -4468,10 +4518,10 @@ export declare const tapInput: {
|
|
|
4468
4518
|
* // Chain multiple input taps for different purposes
|
|
4469
4519
|
* const comprehensiveSchedule = Schedule.fibonacci("100 millis").pipe(
|
|
4470
4520
|
* Schedule.take(5),
|
|
4471
|
-
* Schedule.tapInput((error:
|
|
4472
|
-
* Console.log(`Error occurred: ${error.
|
|
4521
|
+
* Schedule.tapInput((error: RetryError) =>
|
|
4522
|
+
* Console.log(`Error occurred: ${error._tag}`)
|
|
4473
4523
|
* ),
|
|
4474
|
-
* Schedule.tapInput((error:
|
|
4524
|
+
* Schedule.tapInput((error: RetryError) =>
|
|
4475
4525
|
* String(error).length > 20
|
|
4476
4526
|
* ? Console.log("📝 Long error message detected")
|
|
4477
4527
|
* : Effect.void
|
|
@@ -4491,7 +4541,9 @@ export declare const tapInput: {
|
|
|
4491
4541
|
*
|
|
4492
4542
|
* @example
|
|
4493
4543
|
* ```ts
|
|
4494
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
4544
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
4545
|
+
*
|
|
4546
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
4495
4547
|
*
|
|
4496
4548
|
* // Log schedule outputs for debugging/monitoring
|
|
4497
4549
|
* const monitoredSchedule = Schedule.exponential("100 millis").pipe(
|
|
@@ -4506,7 +4558,7 @@ export declare const tapInput: {
|
|
|
4506
4558
|
* Effect.gen(function*() {
|
|
4507
4559
|
* attempt++
|
|
4508
4560
|
* if (attempt < 4) {
|
|
4509
|
-
* yield* Effect.fail(new
|
|
4561
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
4510
4562
|
* }
|
|
4511
4563
|
* return `Success on attempt ${attempt}`
|
|
4512
4564
|
* }),
|
|
@@ -4575,7 +4627,9 @@ export declare const tapOutput: {
|
|
|
4575
4627
|
*
|
|
4576
4628
|
* @example
|
|
4577
4629
|
* ```ts
|
|
4578
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
4630
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
4631
|
+
*
|
|
4632
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
4579
4633
|
*
|
|
4580
4634
|
* // Log schedule outputs for debugging/monitoring
|
|
4581
4635
|
* const monitoredSchedule = Schedule.exponential("100 millis").pipe(
|
|
@@ -4590,7 +4644,7 @@ export declare const tapOutput: {
|
|
|
4590
4644
|
* Effect.gen(function*() {
|
|
4591
4645
|
* attempt++
|
|
4592
4646
|
* if (attempt < 4) {
|
|
4593
|
-
* yield* Effect.fail(new
|
|
4647
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
4594
4648
|
* }
|
|
4595
4649
|
* return `Success on attempt ${attempt}`
|
|
4596
4650
|
* }),
|
|
@@ -4659,7 +4713,9 @@ export declare const tapOutput: {
|
|
|
4659
4713
|
*
|
|
4660
4714
|
* @example
|
|
4661
4715
|
* ```ts
|
|
4662
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
4716
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
4717
|
+
*
|
|
4718
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
4663
4719
|
*
|
|
4664
4720
|
* // Log schedule outputs for debugging/monitoring
|
|
4665
4721
|
* const monitoredSchedule = Schedule.exponential("100 millis").pipe(
|
|
@@ -4674,7 +4730,7 @@ export declare const tapOutput: {
|
|
|
4674
4730
|
* Effect.gen(function*() {
|
|
4675
4731
|
* attempt++
|
|
4676
4732
|
* if (attempt < 4) {
|
|
4677
|
-
* yield* Effect.fail(new
|
|
4733
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
4678
4734
|
* }
|
|
4679
4735
|
* return `Success on attempt ${attempt}`
|
|
4680
4736
|
* }),
|
|
@@ -4744,7 +4800,9 @@ export declare const tapOutput: {
|
|
|
4744
4800
|
*
|
|
4745
4801
|
* @example
|
|
4746
4802
|
* ```ts
|
|
4747
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
4803
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
4804
|
+
*
|
|
4805
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
4748
4806
|
*
|
|
4749
4807
|
* // Limit an infinite schedule to run only 5 times
|
|
4750
4808
|
* const limitedHeartbeat = Schedule.spaced("1 second").pipe(
|
|
@@ -4777,7 +4835,7 @@ export declare const tapOutput: {
|
|
|
4777
4835
|
* yield* Console.log(`Attempt ${attempt}`)
|
|
4778
4836
|
*
|
|
4779
4837
|
* if (attempt < 5) { // Will fail more than 3 times
|
|
4780
|
-
* yield* Effect.fail(new
|
|
4838
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
4781
4839
|
* }
|
|
4782
4840
|
*
|
|
4783
4841
|
* return `Success on attempt ${attempt}`
|
|
@@ -4823,7 +4881,9 @@ export declare const take: {
|
|
|
4823
4881
|
*
|
|
4824
4882
|
* @example
|
|
4825
4883
|
* ```ts
|
|
4826
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
4884
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
4885
|
+
*
|
|
4886
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
4827
4887
|
*
|
|
4828
4888
|
* // Limit an infinite schedule to run only 5 times
|
|
4829
4889
|
* const limitedHeartbeat = Schedule.spaced("1 second").pipe(
|
|
@@ -4856,7 +4916,7 @@ export declare const take: {
|
|
|
4856
4916
|
* yield* Console.log(`Attempt ${attempt}`)
|
|
4857
4917
|
*
|
|
4858
4918
|
* if (attempt < 5) { // Will fail more than 3 times
|
|
4859
|
-
* yield* Effect.fail(new
|
|
4919
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
4860
4920
|
* }
|
|
4861
4921
|
*
|
|
4862
4922
|
* return `Success on attempt ${attempt}`
|
|
@@ -4902,7 +4962,9 @@ export declare const take: {
|
|
|
4902
4962
|
*
|
|
4903
4963
|
* @example
|
|
4904
4964
|
* ```ts
|
|
4905
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
4965
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
4966
|
+
*
|
|
4967
|
+
* class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
|
|
4906
4968
|
*
|
|
4907
4969
|
* // Limit an infinite schedule to run only 5 times
|
|
4908
4970
|
* const limitedHeartbeat = Schedule.spaced("1 second").pipe(
|
|
@@ -4935,7 +4997,7 @@ export declare const take: {
|
|
|
4935
4997
|
* yield* Console.log(`Attempt ${attempt}`)
|
|
4936
4998
|
*
|
|
4937
4999
|
* if (attempt < 5) { // Will fail more than 3 times
|
|
4938
|
-
* yield* Effect.fail(new
|
|
5000
|
+
* return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
|
|
4939
5001
|
* }
|
|
4940
5002
|
*
|
|
4941
5003
|
* return `Success on attempt ${attempt}`
|