@fungi.computer/watchdog 0.0.1 → 0.1.1
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/README.md +94 -41
- package/dist/d1.js +1 -0
- package/dist/effect.d.ts +120 -8
- package/dist/effect.js +34 -11
- package/dist/index.d.ts +7 -5
- package/dist/index.js +2 -2
- package/dist/internal/async-runtime.d.ts +3 -1
- package/dist/internal/async-runtime.js +12 -3
- package/dist/internal/async-sql.d.ts +2 -1
- package/dist/internal/async-sql.js +18 -9
- package/dist/internal/async-store.d.ts +40 -7
- package/dist/internal/async-store.js +177 -24
- package/dist/internal/promise-watchdog-host.js +11 -2
- package/dist/internal/recovery.d.ts +9 -0
- package/dist/internal/recovery.js +20 -0
- package/dist/internal/retry.d.ts +19 -0
- package/dist/internal/retry.js +32 -0
- package/dist/internal/runtime.js +184 -82
- package/dist/internal/sqlite-store.d.ts +50 -9
- package/dist/internal/sqlite-store.js +200 -59
- package/dist/internal/watchdog-error.d.ts +2 -2
- package/dist/postgres.js +1 -0
- package/docs/api/d1.md +4 -3
- package/docs/api/effect.md +267 -29
- package/docs/api/index.md +48 -11
- package/docs/api/postgres.md +3 -3
- package/package.json +4 -3
package/docs/api/effect.md
CHANGED
|
@@ -10,6 +10,54 @@
|
|
|
10
10
|
|
|
11
11
|
## Type Aliases
|
|
12
12
|
|
|
13
|
+
### WatchdogWakeState
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
type WatchdogWakeState = Readonly<{
|
|
17
|
+
pending: boolean;
|
|
18
|
+
nextWakeAt: number | null;
|
|
19
|
+
}>;
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Immediate reconciliation and the earliest future durable deadline.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
### WatchdogRetryPolicy
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
type WatchdogRetryPolicy = Readonly<{
|
|
30
|
+
baseMs: number;
|
|
31
|
+
maxMs: number;
|
|
32
|
+
limit:
|
|
33
|
+
| Readonly<{
|
|
34
|
+
maxAttempts: number;
|
|
35
|
+
}>
|
|
36
|
+
| Readonly<{
|
|
37
|
+
deadlineAt: number;
|
|
38
|
+
}>;
|
|
39
|
+
}>;
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Bounded receiver policy selected by the executor's existing delivery owner.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
### WatchdogAttempt
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
type WatchdogAttempt = Readonly<{
|
|
50
|
+
count: number;
|
|
51
|
+
status: "admitted" | "exhausted";
|
|
52
|
+
final: boolean;
|
|
53
|
+
}>;
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Reservation committed before receiver I/O; exhausted work may only finish its
|
|
57
|
+
receipt.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
13
61
|
### WatchdogQueuedJob
|
|
14
62
|
|
|
15
63
|
```ts
|
|
@@ -20,6 +68,18 @@ Generic durable work waiting for execution.
|
|
|
20
68
|
|
|
21
69
|
---
|
|
22
70
|
|
|
71
|
+
### WatchdogCompletingJob
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
type WatchdogCompletingJob = Schema.Schema.Type<
|
|
75
|
+
typeof WatchdogCompletingJobSchema
|
|
76
|
+
>;
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Durable decision awaiting its owner projection, never executor replay.
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
23
83
|
### WatchdogSettledJob
|
|
24
84
|
|
|
25
85
|
```ts
|
|
@@ -95,6 +155,10 @@ type WatchdogCancellationDecision =
|
|
|
95
155
|
status: "recorded" | "replayed";
|
|
96
156
|
intent: WatchdogCancellationIntent;
|
|
97
157
|
}>
|
|
158
|
+
| Readonly<{
|
|
159
|
+
status: "decided";
|
|
160
|
+
outcome: WatchdogSettledJob["outcome"];
|
|
161
|
+
}>
|
|
98
162
|
| Readonly<{
|
|
99
163
|
status: "conflict" | "missing";
|
|
100
164
|
}>;
|
|
@@ -108,9 +172,17 @@ Result of recording an owner cancellation in its surrounding transaction.
|
|
|
108
172
|
|
|
109
173
|
```ts
|
|
110
174
|
type WatchdogTransactionalProjection = Readonly<{
|
|
175
|
+
wakeState: (now) => WatchdogWakeState;
|
|
176
|
+
readJob: (jobId) =>
|
|
177
|
+
| Readonly<{
|
|
178
|
+
state: WatchdogStoredJob["state"];
|
|
179
|
+
notBefore: number;
|
|
180
|
+
}>
|
|
181
|
+
| undefined;
|
|
111
182
|
readQueueHead: (queue) => WatchdogQueueHead;
|
|
112
183
|
readLatestSettledJob: (queue) => WatchdogSettledJob | undefined;
|
|
113
184
|
enqueueAcceptedJob: (job) => void;
|
|
185
|
+
expediteQueuedJob: (jobId, now) => boolean;
|
|
114
186
|
recordCancellationIntent: (intent) => WatchdogCancellationDecision;
|
|
115
187
|
}>;
|
|
116
188
|
```
|
|
@@ -136,7 +208,8 @@ Result of reading one generic job and its cancellation state.
|
|
|
136
208
|
type WatchdogQueueHead = Schema.Schema.Type<typeof WatchdogQueueHeadSchema>;
|
|
137
209
|
```
|
|
138
210
|
|
|
139
|
-
|
|
211
|
+
Queue occupancy: completing work remains running here until its projection
|
|
212
|
+
commits. Read the job for its exact lifecycle state.
|
|
140
213
|
|
|
141
214
|
---
|
|
142
215
|
|
|
@@ -205,7 +278,15 @@ Result of recording a cancellation through the asynchronous runtime.
|
|
|
205
278
|
|
|
206
279
|
```ts
|
|
207
280
|
type EffectWatchdogExecutor = Readonly<{
|
|
208
|
-
|
|
281
|
+
replaySafe?: (job) => boolean;
|
|
282
|
+
retryPolicy?: (
|
|
283
|
+
job,
|
|
284
|
+
) => Effect.Effect<WatchdogRetryPolicy | undefined, WatchdogError>;
|
|
285
|
+
execute: (
|
|
286
|
+
job,
|
|
287
|
+
attempt,
|
|
288
|
+
) => Effect.Effect<WatchdogExecutionDecision, WatchdogError>;
|
|
289
|
+
isDrained?: (job) => Effect.Effect<boolean, WatchdogError>;
|
|
209
290
|
}>;
|
|
210
291
|
```
|
|
211
292
|
|
|
@@ -298,9 +379,16 @@ Watchdog neither treats it as alive nor fabricates a disappearance.
|
|
|
298
379
|
|
|
299
380
|
```ts
|
|
300
381
|
type WatchdogTickResult =
|
|
382
|
+
| Readonly<{
|
|
383
|
+
status: "requeued";
|
|
384
|
+
jobId: string;
|
|
385
|
+
}>
|
|
301
386
|
| Readonly<{
|
|
302
387
|
status: "busy";
|
|
303
388
|
}>
|
|
389
|
+
| Readonly<{
|
|
390
|
+
status: "stopped";
|
|
391
|
+
}>
|
|
304
392
|
| Readonly<{
|
|
305
393
|
status: "no_ready";
|
|
306
394
|
}>
|
|
@@ -346,17 +434,19 @@ One bounded refusal batch; call again only while more is true.
|
|
|
346
434
|
|
|
347
435
|
```ts
|
|
348
436
|
type WatchdogRuntimeEffect = Readonly<{
|
|
349
|
-
|
|
437
|
+
wakeState: (now) => Effect.Effect<WatchdogWakeState, WatchdogError>;
|
|
350
438
|
ingest: (job) => Effect.Effect<WatchdogIngestResult, WatchdogError>;
|
|
351
439
|
read: (jobId) => Effect.Effect<WatchdogReadResult, WatchdogError>;
|
|
352
440
|
readQueueHead: (queue) => Effect.Effect<WatchdogQueueHead, WatchdogError>;
|
|
353
441
|
readSettled: (
|
|
354
442
|
limit,
|
|
355
443
|
afterSequence?,
|
|
444
|
+
lane?,
|
|
356
445
|
) => Effect.Effect<readonly WatchdogSettledRecord[], WatchdogError>;
|
|
357
446
|
tick: () => Effect.Effect<WatchdogTickResult, WatchdogError>;
|
|
358
447
|
cancel: (input) => Effect.Effect<WatchdogCancellationResult, WatchdogError>;
|
|
359
448
|
failLane: (input) => Effect.Effect<WatchdogLaneFailureResult, WatchdogError>;
|
|
449
|
+
close: Effect.Effect<void, WatchdogError>;
|
|
360
450
|
purge: (queue) => Effect.Effect<void, WatchdogError>;
|
|
361
451
|
transactional: WatchdogTransactionalProjection;
|
|
362
452
|
}>;
|
|
@@ -388,9 +478,11 @@ const WatchdogQueuedJobSchema: Struct<{
|
|
|
388
478
|
lane: String;
|
|
389
479
|
priority: Int;
|
|
390
480
|
payload: Unknown;
|
|
481
|
+
notBefore: optionalKey<Int>;
|
|
391
482
|
recovery: optional<
|
|
392
483
|
Struct<{
|
|
393
484
|
maxRecoveries: Int;
|
|
485
|
+
windowMs: optionalKey<Int>;
|
|
394
486
|
}>
|
|
395
487
|
>;
|
|
396
488
|
state: Literal<"queued">;
|
|
@@ -401,6 +493,40 @@ The public queued-job grammar. Payload is deliberately uninterpreted.
|
|
|
401
493
|
|
|
402
494
|
---
|
|
403
495
|
|
|
496
|
+
### WatchdogCompletingJobSchema
|
|
497
|
+
|
|
498
|
+
```ts
|
|
499
|
+
const WatchdogCompletingJobSchema: Struct<{
|
|
500
|
+
jobId: String;
|
|
501
|
+
queue: String;
|
|
502
|
+
lane: String;
|
|
503
|
+
priority: Int;
|
|
504
|
+
payload: Unknown;
|
|
505
|
+
notBefore: optionalKey<Int>;
|
|
506
|
+
recovery: optional<
|
|
507
|
+
Struct<{
|
|
508
|
+
maxRecoveries: Int;
|
|
509
|
+
windowMs: optionalKey<Int>;
|
|
510
|
+
}>
|
|
511
|
+
>;
|
|
512
|
+
outcome: Literals<
|
|
513
|
+
readonly [
|
|
514
|
+
"completed",
|
|
515
|
+
"failed",
|
|
516
|
+
"cancelled",
|
|
517
|
+
"outcome_unknown",
|
|
518
|
+
"interrupted",
|
|
519
|
+
]
|
|
520
|
+
>;
|
|
521
|
+
failureReason: optionalKey<String>;
|
|
522
|
+
state: Literal<"completing">;
|
|
523
|
+
}>;
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
Execution has decided; its atomic owner projection has not committed yet.
|
|
527
|
+
|
|
528
|
+
---
|
|
529
|
+
|
|
404
530
|
### WatchdogSettledJobSchema
|
|
405
531
|
|
|
406
532
|
```ts
|
|
@@ -410,12 +536,13 @@ const WatchdogSettledJobSchema: Struct<{
|
|
|
410
536
|
lane: String;
|
|
411
537
|
priority: Int;
|
|
412
538
|
payload: Unknown;
|
|
539
|
+
notBefore: optionalKey<Int>;
|
|
413
540
|
recovery: optional<
|
|
414
541
|
Struct<{
|
|
415
542
|
maxRecoveries: Int;
|
|
543
|
+
windowMs: optionalKey<Int>;
|
|
416
544
|
}>
|
|
417
545
|
>;
|
|
418
|
-
state: Literal<"settled">;
|
|
419
546
|
outcome: Literals<
|
|
420
547
|
readonly [
|
|
421
548
|
"completed",
|
|
@@ -426,6 +553,7 @@ const WatchdogSettledJobSchema: Struct<{
|
|
|
426
553
|
]
|
|
427
554
|
>;
|
|
428
555
|
failureReason: optionalKey<String>;
|
|
556
|
+
state: Literal<"settled">;
|
|
429
557
|
}>;
|
|
430
558
|
```
|
|
431
559
|
|
|
@@ -442,9 +570,11 @@ const WatchdogRunningJobSchema: Struct<{
|
|
|
442
570
|
lane: String;
|
|
443
571
|
priority: Int;
|
|
444
572
|
payload: Unknown;
|
|
573
|
+
notBefore: optionalKey<Int>;
|
|
445
574
|
recovery: optional<
|
|
446
575
|
Struct<{
|
|
447
576
|
maxRecoveries: Int;
|
|
577
|
+
windowMs: optionalKey<Int>;
|
|
448
578
|
}>
|
|
449
579
|
>;
|
|
450
580
|
state: Literal<"running">;
|
|
@@ -466,9 +596,11 @@ const WatchdogStoredJobSchema: Union<
|
|
|
466
596
|
lane: String;
|
|
467
597
|
priority: Int;
|
|
468
598
|
payload: Unknown;
|
|
599
|
+
notBefore: optionalKey<Int>;
|
|
469
600
|
recovery: optional<
|
|
470
601
|
Struct<{
|
|
471
602
|
maxRecoveries: Int;
|
|
603
|
+
windowMs: optionalKey<Int>;
|
|
472
604
|
}>
|
|
473
605
|
>;
|
|
474
606
|
state: Literal<"queued">;
|
|
@@ -479,9 +611,11 @@ const WatchdogStoredJobSchema: Union<
|
|
|
479
611
|
lane: String;
|
|
480
612
|
priority: Int;
|
|
481
613
|
payload: Unknown;
|
|
614
|
+
notBefore: optionalKey<Int>;
|
|
482
615
|
recovery: optional<
|
|
483
616
|
Struct<{
|
|
484
617
|
maxRecoveries: Int;
|
|
618
|
+
windowMs: optionalKey<Int>;
|
|
485
619
|
}>
|
|
486
620
|
>;
|
|
487
621
|
state: Literal<"running">;
|
|
@@ -492,12 +626,13 @@ const WatchdogStoredJobSchema: Union<
|
|
|
492
626
|
lane: String;
|
|
493
627
|
priority: Int;
|
|
494
628
|
payload: Unknown;
|
|
629
|
+
notBefore: optionalKey<Int>;
|
|
495
630
|
recovery: optional<
|
|
496
631
|
Struct<{
|
|
497
632
|
maxRecoveries: Int;
|
|
633
|
+
windowMs: optionalKey<Int>;
|
|
498
634
|
}>
|
|
499
635
|
>;
|
|
500
|
-
state: Literal<"settled">;
|
|
501
636
|
outcome: Literals<
|
|
502
637
|
readonly [
|
|
503
638
|
"completed",
|
|
@@ -508,6 +643,32 @@ const WatchdogStoredJobSchema: Union<
|
|
|
508
643
|
]
|
|
509
644
|
>;
|
|
510
645
|
failureReason: optionalKey<String>;
|
|
646
|
+
state: Literal<"completing">;
|
|
647
|
+
}>,
|
|
648
|
+
Struct<{
|
|
649
|
+
jobId: String;
|
|
650
|
+
queue: String;
|
|
651
|
+
lane: String;
|
|
652
|
+
priority: Int;
|
|
653
|
+
payload: Unknown;
|
|
654
|
+
notBefore: optionalKey<Int>;
|
|
655
|
+
recovery: optional<
|
|
656
|
+
Struct<{
|
|
657
|
+
maxRecoveries: Int;
|
|
658
|
+
windowMs: optionalKey<Int>;
|
|
659
|
+
}>
|
|
660
|
+
>;
|
|
661
|
+
outcome: Literals<
|
|
662
|
+
readonly [
|
|
663
|
+
"completed",
|
|
664
|
+
"failed",
|
|
665
|
+
"cancelled",
|
|
666
|
+
"outcome_unknown",
|
|
667
|
+
"interrupted",
|
|
668
|
+
]
|
|
669
|
+
>;
|
|
670
|
+
failureReason: optionalKey<String>;
|
|
671
|
+
state: Literal<"settled">;
|
|
511
672
|
}>,
|
|
512
673
|
]
|
|
513
674
|
>;
|
|
@@ -522,6 +683,9 @@ The complete public job lifecycle grammar.
|
|
|
522
683
|
```ts
|
|
523
684
|
const WatchdogExecutionDecisionSchema: Union<
|
|
524
685
|
readonly [
|
|
686
|
+
Struct<{
|
|
687
|
+
kind: Literal<"retry">;
|
|
688
|
+
}>,
|
|
525
689
|
Struct<{
|
|
526
690
|
kind: Literal<"completed">;
|
|
527
691
|
}>,
|
|
@@ -568,8 +732,10 @@ const WatchdogReadResultSchema: Union<readonly [Struct<{
|
|
|
568
732
|
lane: String;
|
|
569
733
|
priority: Int;
|
|
570
734
|
payload: Unknown;
|
|
735
|
+
notBefore: optionalKey<Int>;
|
|
571
736
|
recovery: optional<Struct<{
|
|
572
737
|
maxRecoveries: ...;
|
|
738
|
+
windowMs: ...;
|
|
573
739
|
}>>;
|
|
574
740
|
state: Literal<"queued">;
|
|
575
741
|
}>, Struct<{
|
|
@@ -578,8 +744,10 @@ const WatchdogReadResultSchema: Union<readonly [Struct<{
|
|
|
578
744
|
lane: String;
|
|
579
745
|
priority: Int;
|
|
580
746
|
payload: Unknown;
|
|
747
|
+
notBefore: optionalKey<Int>;
|
|
581
748
|
recovery: optional<Struct<{
|
|
582
749
|
maxRecoveries: ...;
|
|
750
|
+
windowMs: ...;
|
|
583
751
|
}>>;
|
|
584
752
|
state: Literal<"running">;
|
|
585
753
|
}>, Struct<{
|
|
@@ -588,12 +756,28 @@ const WatchdogReadResultSchema: Union<readonly [Struct<{
|
|
|
588
756
|
lane: String;
|
|
589
757
|
priority: Int;
|
|
590
758
|
payload: Unknown;
|
|
759
|
+
notBefore: optionalKey<Int>;
|
|
591
760
|
recovery: optional<Struct<{
|
|
592
761
|
maxRecoveries: ...;
|
|
762
|
+
windowMs: ...;
|
|
593
763
|
}>>;
|
|
594
|
-
state: Literal<"settled">;
|
|
595
764
|
outcome: Literals<readonly ["completed", "failed", "cancelled", "outcome_unknown", "interrupted"]>;
|
|
596
765
|
failureReason: optionalKey<String>;
|
|
766
|
+
state: Literal<"completing">;
|
|
767
|
+
}>, Struct<{
|
|
768
|
+
jobId: String;
|
|
769
|
+
queue: String;
|
|
770
|
+
lane: String;
|
|
771
|
+
priority: Int;
|
|
772
|
+
payload: Unknown;
|
|
773
|
+
notBefore: optionalKey<Int>;
|
|
774
|
+
recovery: optional<Struct<{
|
|
775
|
+
maxRecoveries: ...;
|
|
776
|
+
windowMs: ...;
|
|
777
|
+
}>>;
|
|
778
|
+
outcome: Literals<readonly ["completed", "failed", "cancelled", "outcome_unknown", "interrupted"]>;
|
|
779
|
+
failureReason: optionalKey<String>;
|
|
780
|
+
state: Literal<"settled">;
|
|
597
781
|
}>]>;
|
|
598
782
|
cancellation: Union<readonly [Struct<{
|
|
599
783
|
status: Literal<"absent">;
|
|
@@ -659,6 +843,18 @@ Results returned by idempotent public ingest.
|
|
|
659
843
|
```ts
|
|
660
844
|
const WatchdogCancellationResultSchema: Union<
|
|
661
845
|
readonly [
|
|
846
|
+
Struct<{
|
|
847
|
+
status: Literal<"decided">;
|
|
848
|
+
outcome: Literals<
|
|
849
|
+
readonly [
|
|
850
|
+
"completed",
|
|
851
|
+
"failed",
|
|
852
|
+
"cancelled",
|
|
853
|
+
"outcome_unknown",
|
|
854
|
+
"interrupted",
|
|
855
|
+
]
|
|
856
|
+
>;
|
|
857
|
+
}>,
|
|
662
858
|
Struct<{
|
|
663
859
|
status: Literals<readonly ["recorded", "replayed"]>;
|
|
664
860
|
}>,
|
|
@@ -725,7 +921,10 @@ Construct two private single-flight slots over the same owner and job table.
|
|
|
725
921
|
|
|
726
922
|
```ts
|
|
727
923
|
function makeRuntime(options): Effect<Readonly<{
|
|
728
|
-
|
|
924
|
+
wakeState: (now) => Effect<Readonly<{
|
|
925
|
+
pending: boolean;
|
|
926
|
+
nextWakeAt: number | null;
|
|
927
|
+
}>, WatchdogError>;
|
|
729
928
|
ingest: (job) => Effect<
|
|
730
929
|
| {
|
|
731
930
|
status: "queued";
|
|
@@ -742,8 +941,23 @@ function makeRuntime(options): Effect<Readonly<{
|
|
|
742
941
|
lane: string;
|
|
743
942
|
priority: number;
|
|
744
943
|
payload: unknown;
|
|
944
|
+
notBefore?: number;
|
|
945
|
+
recovery?: {
|
|
946
|
+
maxRecoveries: ...;
|
|
947
|
+
windowMs?: ...;
|
|
948
|
+
};
|
|
949
|
+
state: "running";
|
|
950
|
+
}
|
|
951
|
+
| {
|
|
952
|
+
jobId: string;
|
|
953
|
+
queue: string;
|
|
954
|
+
lane: string;
|
|
955
|
+
priority: number;
|
|
956
|
+
payload: unknown;
|
|
957
|
+
notBefore?: number;
|
|
745
958
|
recovery?: {
|
|
746
959
|
maxRecoveries: ...;
|
|
960
|
+
windowMs?: ...;
|
|
747
961
|
};
|
|
748
962
|
state: "queued";
|
|
749
963
|
}
|
|
@@ -753,10 +967,14 @@ function makeRuntime(options): Effect<Readonly<{
|
|
|
753
967
|
lane: string;
|
|
754
968
|
priority: number;
|
|
755
969
|
payload: unknown;
|
|
970
|
+
notBefore?: number;
|
|
756
971
|
recovery?: {
|
|
757
972
|
maxRecoveries: ...;
|
|
973
|
+
windowMs?: ...;
|
|
758
974
|
};
|
|
759
|
-
|
|
975
|
+
outcome: "failed" | "completed" | "interrupted" | "cancelled" | "outcome_unknown";
|
|
976
|
+
failureReason?: string;
|
|
977
|
+
state: "completing";
|
|
760
978
|
}
|
|
761
979
|
| {
|
|
762
980
|
jobId: string;
|
|
@@ -764,12 +982,14 @@ function makeRuntime(options): Effect<Readonly<{
|
|
|
764
982
|
lane: string;
|
|
765
983
|
priority: number;
|
|
766
984
|
payload: unknown;
|
|
985
|
+
notBefore?: number;
|
|
767
986
|
recovery?: {
|
|
768
987
|
maxRecoveries: ...;
|
|
988
|
+
windowMs?: ...;
|
|
769
989
|
};
|
|
770
|
-
state: "settled";
|
|
771
990
|
outcome: "failed" | "completed" | "interrupted" | "cancelled" | "outcome_unknown";
|
|
772
991
|
failureReason?: string;
|
|
992
|
+
state: "settled";
|
|
773
993
|
};
|
|
774
994
|
cancellation: | {
|
|
775
995
|
status: "absent";
|
|
@@ -795,7 +1015,7 @@ function makeRuntime(options): Effect<Readonly<{
|
|
|
795
1015
|
jobId: string;
|
|
796
1016
|
cancellationRequested: boolean;
|
|
797
1017
|
}, WatchdogError>;
|
|
798
|
-
readSettled: (limit, afterSequence?) => Effect<readonly Readonly<{
|
|
1018
|
+
readSettled: (limit, afterSequence?, lane?) => Effect<readonly Readonly<{
|
|
799
1019
|
sequence: number;
|
|
800
1020
|
job: {
|
|
801
1021
|
jobId: string;
|
|
@@ -803,18 +1023,24 @@ function makeRuntime(options): Effect<Readonly<{
|
|
|
803
1023
|
lane: string;
|
|
804
1024
|
priority: number;
|
|
805
1025
|
payload: unknown;
|
|
1026
|
+
notBefore?: number;
|
|
806
1027
|
recovery?: {
|
|
807
1028
|
maxRecoveries: ...;
|
|
1029
|
+
windowMs?: ...;
|
|
808
1030
|
};
|
|
809
|
-
state: "settled";
|
|
810
1031
|
outcome: "failed" | "completed" | "interrupted" | "cancelled" | "outcome_unknown";
|
|
811
1032
|
failureReason?: string;
|
|
1033
|
+
state: "settled";
|
|
812
1034
|
};
|
|
813
1035
|
}>[], WatchdogError>;
|
|
814
1036
|
tick: () => Effect<WatchdogTickResult, WatchdogError>;
|
|
815
1037
|
cancel: (input) => Effect<
|
|
816
1038
|
| {
|
|
817
|
-
status: "
|
|
1039
|
+
status: "decided";
|
|
1040
|
+
outcome: "failed" | "completed" | "interrupted" | "cancelled" | "outcome_unknown";
|
|
1041
|
+
}
|
|
1042
|
+
| {
|
|
1043
|
+
status: "recorded" | "replayed";
|
|
818
1044
|
}
|
|
819
1045
|
| {
|
|
820
1046
|
status: "missing" | "conflict";
|
|
@@ -823,6 +1049,7 @@ function makeRuntime(options): Effect<Readonly<{
|
|
|
823
1049
|
settled: number;
|
|
824
1050
|
more: boolean;
|
|
825
1051
|
}>, WatchdogError>;
|
|
1052
|
+
close: Effect<void, WatchdogError>;
|
|
826
1053
|
purge: (queue) => Effect<void, WatchdogError>;
|
|
827
1054
|
transactional: WatchdogTransactionalProjection;
|
|
828
1055
|
}>, WatchdogError>;
|
|
@@ -838,19 +1065,26 @@ Construct a serial owner-local runtime.
|
|
|
838
1065
|
|
|
839
1066
|
##### Returns
|
|
840
1067
|
|
|
841
|
-
`Effect`\<`Readonly`\<\{ `
|
|
1068
|
+
`Effect`\<`Readonly`\<\{ `wakeState`: (`now`) => `Effect`\<`Readonly`\<\{
|
|
1069
|
+
`pending`: `boolean`; `nextWakeAt`: `number` \| `null`; \}\>,
|
|
842
1070
|
[`WatchdogError`](index.md#watchdogerror)\>; `ingest`: (`job`) => `Effect`\< \|
|
|
843
1071
|
\{ `status`: `"queued"`; \} \| \{ `status`: `"duplicate"`; \},
|
|
844
1072
|
[`WatchdogError`](index.md#watchdogerror)\>; `read`: (`jobId`) => `Effect`\< \|
|
|
845
1073
|
\{ `status`: `"found"`; `job`: \| \{ `jobId`: `string`; `queue`: `string`;
|
|
846
|
-
`lane`: `string`; `priority`: `number`; `payload`: `unknown`; `
|
|
847
|
-
`
|
|
848
|
-
`
|
|
849
|
-
`
|
|
1074
|
+
`lane`: `string`; `priority`: `number`; `payload`: `unknown`; `notBefore?`:
|
|
1075
|
+
`number`; `recovery?`: \{ `maxRecoveries`: ...; `windowMs?`: ...; \}; `state`:
|
|
1076
|
+
`"running"`; \} \| \{ `jobId`: `string`; `queue`: `string`; `lane`: `string`;
|
|
1077
|
+
`priority`: `number`; `payload`: `unknown`; `notBefore?`: `number`; `recovery?`:
|
|
1078
|
+
\{ `maxRecoveries`: ...; `windowMs?`: ...; \}; `state`: `"queued"`; \} \| \{
|
|
850
1079
|
`jobId`: `string`; `queue`: `string`; `lane`: `string`; `priority`: `number`;
|
|
851
|
-
`payload`: `unknown`; `recovery?`: \{ `maxRecoveries`:
|
|
852
|
-
`
|
|
853
|
-
`"cancelled"` \| `"outcome_unknown"`; `failureReason?`:
|
|
1080
|
+
`payload`: `unknown`; `notBefore?`: `number`; `recovery?`: \{ `maxRecoveries`:
|
|
1081
|
+
...; `windowMs?`: ...; \}; `outcome`: `"failed"` \| `"completed"` \|
|
|
1082
|
+
`"interrupted"` \| `"cancelled"` \| `"outcome_unknown"`; `failureReason?`:
|
|
1083
|
+
`string`; `state`: `"completing"`; \} \| \{ `jobId`: `string`; `queue`:
|
|
1084
|
+
`string`; `lane`: `string`; `priority`: `number`; `payload`: `unknown`;
|
|
1085
|
+
`notBefore?`: `number`; `recovery?`: \{ `maxRecoveries`: ...; `windowMs?`: ...;
|
|
1086
|
+
\}; `outcome`: `"failed"` \| `"completed"` \| `"interrupted"` \| `"cancelled"`
|
|
1087
|
+
\| `"outcome_unknown"`; `failureReason?`: `string`; `state`: `"settled"`; \};
|
|
854
1088
|
`cancellation`: \| \{ `status`: `"absent"`; \} \| \{ `status`: `"present"`;
|
|
855
1089
|
`cancellation`: \{ `jobId`: `string`; `cancellationId`: `string`;
|
|
856
1090
|
`onlyIfQueued?`: ... \| ... \| ...; \}; \}; \} \| \{ `status`: `"missing"`; \},
|
|
@@ -858,18 +1092,22 @@ Construct a serial owner-local runtime.
|
|
|
858
1092
|
`Effect`\< \| \{ `state`: `"idle"`; \} \| \{ `state`: `"running"` \| `"queued"`;
|
|
859
1093
|
`jobId`: `string`; `cancellationRequested`: `boolean`; \},
|
|
860
1094
|
[`WatchdogError`](index.md#watchdogerror)\>; `readSettled`: (`limit`,
|
|
861
|
-
`afterSequence?`) => `Effect`\<readonly `Readonly`\<\{ `sequence`:
|
|
862
|
-
`job`: \{ `jobId`: `string`; `queue`: `string`; `lane`: `string`;
|
|
863
|
-
`number`; `payload`: `unknown`; `
|
|
864
|
-
`
|
|
865
|
-
\| `"
|
|
1095
|
+
`afterSequence?`, `lane?`) => `Effect`\<readonly `Readonly`\<\{ `sequence`:
|
|
1096
|
+
`number`; `job`: \{ `jobId`: `string`; `queue`: `string`; `lane`: `string`;
|
|
1097
|
+
`priority`: `number`; `payload`: `unknown`; `notBefore?`: `number`; `recovery?`:
|
|
1098
|
+
\{ `maxRecoveries`: ...; `windowMs?`: ...; \}; `outcome`: `"failed"` \|
|
|
1099
|
+
`"completed"` \| `"interrupted"` \| `"cancelled"` \| `"outcome_unknown"`;
|
|
1100
|
+
`failureReason?`: `string`; `state`: `"settled"`; \}; \}\>[],
|
|
866
1101
|
[`WatchdogError`](index.md#watchdogerror)\>; `tick`: () =>
|
|
867
1102
|
`Effect`\<[`WatchdogTickResult`](#watchdogtickresult),
|
|
868
1103
|
[`WatchdogError`](index.md#watchdogerror)\>; `cancel`: (`input`) => `Effect`\<
|
|
869
|
-
\| \{ `status`: `"
|
|
870
|
-
`"
|
|
871
|
-
|
|
872
|
-
\}
|
|
1104
|
+
\| \{ `status`: `"decided"`; `outcome`: `"failed"` \| `"completed"` \|
|
|
1105
|
+
`"interrupted"` \| `"cancelled"` \| `"outcome_unknown"`; \} \| \{ `status`:
|
|
1106
|
+
`"recorded"` \| `"replayed"`; \} \| \{ `status`: `"missing"` \| `"conflict"`;
|
|
1107
|
+
\}, [`WatchdogError`](index.md#watchdogerror)\>; `failLane`: (`input`) =>
|
|
1108
|
+
`Effect`\<`Readonly`\<\{ `settled`: `number`; `more`: `boolean`; \}\>,
|
|
1109
|
+
[`WatchdogError`](index.md#watchdogerror)\>; `close`: `Effect`\<`void`,
|
|
1110
|
+
[`WatchdogError`](index.md#watchdogerror)\>; `purge`: (`queue`) =>
|
|
873
1111
|
`Effect`\<`void`, [`WatchdogError`](index.md#watchdogerror)\>; `transactional`:
|
|
874
1112
|
[`WatchdogTransactionalProjection`](#watchdogtransactionalprojection); \}\>,
|
|
875
1113
|
[`WatchdogError`](index.md#watchdogerror)\>
|