@systemfsoftware/effect-daemon-spec 3.0.13 → 4.0.0
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/CHANGELOG.md +15 -0
- package/dist/effect-daemon-spec-untrimmed.d.ts +4 -4
- package/dist/effect-daemon-spec.d.ts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +39 -15
- package/package.json +11 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @systemfsoftware/effect-daemon-spec
|
|
2
2
|
|
|
3
|
+
## 4.0.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- A supervisor whose restart decision cannot read its own restart command now logs the error and cools down, the same as when its restart budget runs out. It used to die and take its children down with it.
|
|
8
|
+
|
|
9
|
+
## 3.0.14
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Unconstrained type holes are defaulted type parameters (`<A = unknown>`) instead of a type argument `unknown`. Calls that omit those arguments are unchanged.
|
|
14
|
+
|
|
15
|
+
- Updated dependencies:
|
|
16
|
+
- @systemfsoftware/effect-cell-types@9.0.0
|
|
17
|
+
|
|
3
18
|
## 3.0.13
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -255,8 +255,8 @@ export declare const stream: <A, E, R, L extends LockConfig>(opts: CommonOpts<L>
|
|
|
255
255
|
readonly stream: Stream.Stream<A, E, R>;
|
|
256
256
|
}) => Worker_2<E, R, L>;
|
|
257
257
|
|
|
258
|
-
export declare interface StreamLoop<E, R> extends StreamLoopTag {
|
|
259
|
-
readonly stream: Stream.Stream<
|
|
258
|
+
export declare interface StreamLoop<E, R, A = unknown> extends StreamLoopTag {
|
|
259
|
+
readonly stream: Stream.Stream<A, E, R>;
|
|
260
260
|
}
|
|
261
261
|
|
|
262
262
|
export declare const StreamLoopTag: {
|
|
@@ -356,9 +356,9 @@ declare const TickPolicyConfig_base: Schema.Class<TickPolicyConfig, Schema.Struc
|
|
|
356
356
|
readonly startLogLevel: Schema.optional<Schema.Literals<readonly ["debug", "info"]>>;
|
|
357
357
|
}>, {}>;
|
|
358
358
|
|
|
359
|
-
export declare interface TickPolicyHooks {
|
|
359
|
+
export declare interface TickPolicyHooks<RetrySchedule = unknown> {
|
|
360
360
|
readonly spanAttributes?: Effect.Effect<Record<string, string | number | boolean>>;
|
|
361
|
-
readonly innerRetry?: Schedule.Schedule<
|
|
361
|
+
readonly innerRetry?: Schedule.Schedule<RetrySchedule>;
|
|
362
362
|
readonly trackDuration?: Metric.Histogram<Duration.Duration>;
|
|
363
363
|
}
|
|
364
364
|
|
|
@@ -255,8 +255,8 @@ export declare const stream: <A, E, R, L extends LockConfig>(opts: CommonOpts<L>
|
|
|
255
255
|
readonly stream: Stream.Stream<A, E, R>;
|
|
256
256
|
}) => Worker_2<E, R, L>;
|
|
257
257
|
|
|
258
|
-
export declare interface StreamLoop<E, R> extends StreamLoopTag {
|
|
259
|
-
readonly stream: Stream.Stream<
|
|
258
|
+
export declare interface StreamLoop<E, R, A = unknown> extends StreamLoopTag {
|
|
259
|
+
readonly stream: Stream.Stream<A, E, R>;
|
|
260
260
|
}
|
|
261
261
|
|
|
262
262
|
export declare const StreamLoopTag: {
|
|
@@ -356,9 +356,9 @@ declare const TickPolicyConfig_base: Schema.Class<TickPolicyConfig, Schema.Struc
|
|
|
356
356
|
readonly startLogLevel: Schema.optional<Schema.Literals<readonly ["debug", "info"]>>;
|
|
357
357
|
}>, {}>;
|
|
358
358
|
|
|
359
|
-
export declare interface TickPolicyHooks {
|
|
359
|
+
export declare interface TickPolicyHooks<RetrySchedule = unknown> {
|
|
360
360
|
readonly spanAttributes?: Effect.Effect<Record<string, string | number | boolean>>;
|
|
361
|
-
readonly innerRetry?: Schedule.Schedule<
|
|
361
|
+
readonly innerRetry?: Schedule.Schedule<RetrySchedule>;
|
|
362
362
|
readonly trackDuration?: Metric.Histogram<Duration.Duration>;
|
|
363
363
|
}
|
|
364
364
|
|
package/dist/index.d.ts
CHANGED
|
@@ -178,9 +178,9 @@ export type PollOpts<A, E, R, L extends LockConfig> = CommonOpts<L> & {
|
|
|
178
178
|
readonly prereq: Effect.Effect<Option.Option<A>, E, R>;
|
|
179
179
|
readonly work: (data: A) => Effect.Effect<void, E, R>;
|
|
180
180
|
});
|
|
181
|
-
export interface TickPolicyHooks {
|
|
181
|
+
export interface TickPolicyHooks<RetrySchedule = unknown> {
|
|
182
182
|
readonly spanAttributes?: Effect.Effect<Record<string, string | number | boolean>>;
|
|
183
|
-
readonly innerRetry?: Schedule.Schedule<
|
|
183
|
+
readonly innerRetry?: Schedule.Schedule<RetrySchedule>;
|
|
184
184
|
readonly trackDuration?: Metric.Histogram<Duration.Duration>;
|
|
185
185
|
}
|
|
186
186
|
export interface ReporterPolicyHooks {
|
|
@@ -191,8 +191,8 @@ export interface PollLoop<E, R> extends PollLoopTag {
|
|
|
191
191
|
readonly gate: Effect.Effect<Option.Option<Effect.Effect<void, E, R>>, E, R>;
|
|
192
192
|
readonly interval: Duration.Input;
|
|
193
193
|
}
|
|
194
|
-
export interface StreamLoop<E, R> extends StreamLoopTag {
|
|
195
|
-
readonly stream: Stream.Stream<
|
|
194
|
+
export interface StreamLoop<E, R, A = unknown> extends StreamLoopTag {
|
|
195
|
+
readonly stream: Stream.Stream<A, E, R>;
|
|
196
196
|
}
|
|
197
197
|
export interface SubscriptionLoop<E, R> extends SubscriptionLoopTag {
|
|
198
198
|
readonly acquire: Effect.Effect<void, E, R>;
|
package/dist/index.mjs
CHANGED
|
@@ -521,8 +521,8 @@ const DecideInputBase = Schema.Struct({
|
|
|
521
521
|
}).check(Schema.makeFilter(failedIndexAddressesAChild, { message: BOUND_MESSAGE }));
|
|
522
522
|
/**
|
|
523
523
|
* The restart command. A `Schema.Class` rather than a `Schema.Struct` because `Workflow.make`
|
|
524
|
-
*
|
|
525
|
-
*
|
|
524
|
+
* constrains its `command` on the class itself — a struct carries no `identifier` and no
|
|
525
|
+
* `extend`, and the constraint refuses it. Every field schema and the cross-field check are
|
|
526
526
|
* the ones the struct carried.
|
|
527
527
|
*
|
|
528
528
|
* Class-level `toCodecArbitrary` is what `Arbitrary.schema(DecideInput)` compiles. The
|
|
@@ -534,7 +534,9 @@ const DecideInputBase = Schema.Struct({
|
|
|
534
534
|
var DecideInput = class DecideInput extends Schema.Class("DecideInput")(DecideInputBase, { toCodecArbitrary: () => Schema.link()(DecideInputGenerated, {
|
|
535
535
|
decode: SchemaGetter.transform((generated) => new DecideInput(commandFromGenerated(generated))),
|
|
536
536
|
encode: SchemaGetter.transform(generatedFromCommand)
|
|
537
|
-
}) }) {
|
|
537
|
+
}) }) {
|
|
538
|
+
static [Workflow.InstrumentationBrand] = { strategy: "daemon.restart.strategy" };
|
|
539
|
+
};
|
|
538
540
|
//#endregion
|
|
539
541
|
//#region src/internal/choose-restart-strategy.workflow.ts
|
|
540
542
|
/**
|
|
@@ -558,11 +560,23 @@ var RestartDecisionRestart = class extends S.TaggedClass()("Restart", { indices:
|
|
|
558
560
|
var RestartDecisionExhausted = class extends S.TaggedError()("Exhausted", {}) {
|
|
559
561
|
[RestartDecisionTypeId] = RestartDecisionTypeId;
|
|
560
562
|
};
|
|
563
|
+
/**
|
|
564
|
+
* The decision channel: the two outcomes a cooldown-or-restart choice is made between, as
|
|
565
|
+
* one schema the workflow declares. The error channel carries `RestartDecisionExhausted`, so
|
|
566
|
+
* the compiler holds the three-way dispatch over the encoded tags of both channels.
|
|
567
|
+
*/
|
|
561
568
|
/** @internal */
|
|
562
|
-
const
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
569
|
+
const RestartDecision = S.Union([RestartDecisionContinue, RestartDecisionRestart]);
|
|
570
|
+
/** @internal */
|
|
571
|
+
const chooseRestartStrategy = Workflow.make({
|
|
572
|
+
command: DecideInput,
|
|
573
|
+
decision: RestartDecision,
|
|
574
|
+
error: RestartDecisionExhausted,
|
|
575
|
+
decide: (command) => Match$1.value(command).pipe(Match$1.when({ exitSuccess: true }, () => Result$1.succeed(RestartDecisionContinue.make())), Match$1.when({
|
|
576
|
+
exitSuccess: false,
|
|
577
|
+
intensityExceeded: true
|
|
578
|
+
}, () => Result$1.fail(RestartDecisionExhausted.make())), Match$1.orElse(() => Result$1.succeed(RestartDecisionRestart.make({ indices: restartIndicesFor(command.strategy, command.failedIndex, command.totalChildren) }))))
|
|
579
|
+
});
|
|
566
580
|
//#endregion
|
|
567
581
|
//#region src/internal/IntensityWindow.ts
|
|
568
582
|
/** @internal */
|
|
@@ -716,25 +730,35 @@ const handleRestart = (ctx, cause, onSignal) => Effect.gen(function* () {
|
|
|
716
730
|
* The read is a bump-and-report: recording a restart is how the current rate is obtained, so
|
|
717
731
|
* the mutation is a product gathered across the read's interior rather than a write standing
|
|
718
732
|
* before a decision. That is what keeps this one layer instead of two, and it is why
|
|
719
|
-
* `intensity.record` sits where it does.
|
|
733
|
+
* `intensity.record` sits where it does. The read is also where the command's encoded form is
|
|
734
|
+
* gathered, so the library decodes it through the workflow's command schema before `decide`
|
|
735
|
+
* runs and encodes the decision or the refusal the workflow returns.
|
|
720
736
|
*
|
|
721
|
-
*
|
|
722
|
-
*
|
|
737
|
+
* The write dispatches one handler per encoded tag, and each handler answers with the epoch
|
|
738
|
+
* step that follows: a decision to continue stops the epoch, a decision to restart reports and
|
|
739
|
+
* reboots, and the `Exhausted` refusal cools down. A command the supervisor built that fails its
|
|
740
|
+
* own schema is a regression in this module, so it is logged and treated as exhausted: the
|
|
741
|
+
* supervisor cools down instead of dying and taking every child with it.
|
|
723
742
|
*
|
|
724
743
|
* A description is built per failure because the write needs that failure's context, and the
|
|
725
744
|
* phase signatures hand the command to the read alone. Restarts are rare, so the allocation is
|
|
726
745
|
* paid only when a supervised child has actually died.
|
|
727
746
|
*/
|
|
728
|
-
const restartDescription = (spec) => Sandwich.
|
|
747
|
+
const restartDescription = (spec) => Sandwich.named("supervisor.restart-description")((intensity) => Effect.map(Effect.andThen(intensity.record, intensity.isExceeded), (intensityExceeded) => ({
|
|
729
748
|
strategy: spec.strategy,
|
|
730
749
|
totalChildren: spec.totalChildren,
|
|
731
750
|
failedIndex: spec.failedIndex,
|
|
732
751
|
exitSuccess: false,
|
|
733
752
|
intensityExceeded
|
|
734
|
-
}))).decide(chooseRestartStrategy).
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
753
|
+
}))).decide(chooseRestartStrategy).write({
|
|
754
|
+
Continue: () => Effect.succeed(StopEpoch.make()),
|
|
755
|
+
Restart: (decision) => handleRestart(spec.ctx, spec.cause, spec.onRestart(decision)),
|
|
756
|
+
Exhausted: () => handleExhausted(spec.ctx, spec.cause),
|
|
757
|
+
CommandRejected: (rejected) => Effect.andThen(Effect.logError("supervisor restart command failed its own schema; cooling down", {
|
|
758
|
+
daemon: spec.ctx.name,
|
|
759
|
+
issue: String(rejected.issue)
|
|
760
|
+
}), handleExhausted(spec.ctx, spec.cause))
|
|
761
|
+
});
|
|
738
762
|
const reopenHealthyAfterCooldown = (ctx) => Effect.andThen(ctx.health.healthy.open, Metric.update(Metric.withAttributes(healthStateGauge, {
|
|
739
763
|
daemon: ctx.name,
|
|
740
764
|
latch: "healthy"
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@systemfsoftware/effect-daemon-spec",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.0",
|
|
5
5
|
"author": "Ryan Lee <drdgvhbh@gmail.com>",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -37,17 +37,17 @@
|
|
|
37
37
|
"dist"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@systemfsoftware/effect-cell-types": "^
|
|
40
|
+
"@systemfsoftware/effect-cell-types": "^10.0.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@effect/vitest": "4.0.0-rc.116",
|
|
44
44
|
"@microsoft/api-extractor": "^7.59.1",
|
|
45
45
|
"@systemfsoftware/arethetypeswrong-cli": "^4.2.0",
|
|
46
|
-
"@systemfsoftware/stryker-ignorer-effect-schema-declarations": "^0.1.
|
|
47
|
-
"@systemfsoftware/stryker-ignorer-in-source-vitest-block": "^0.1.
|
|
48
|
-
"@systemfsoftware/stryker-js": "^10.
|
|
49
|
-
"@systemfsoftware/stryker-js-typescript-checker": "^7.0.
|
|
50
|
-
"@systemfsoftware/stryker-js-vitest-runner": "^7.
|
|
46
|
+
"@systemfsoftware/stryker-ignorer-effect-schema-declarations": "^0.1.1",
|
|
47
|
+
"@systemfsoftware/stryker-ignorer-in-source-vitest-block": "^0.1.1",
|
|
48
|
+
"@systemfsoftware/stryker-js": "^10.1.1",
|
|
49
|
+
"@systemfsoftware/stryker-js-typescript-checker": "^7.0.5",
|
|
50
|
+
"@systemfsoftware/stryker-js-vitest-runner": "^7.1.1",
|
|
51
51
|
"@systemfsoftware/stryker-test-contribution": "^3.0.3",
|
|
52
52
|
"@types/node": "^26",
|
|
53
53
|
"@vitest/coverage-v8": "^5",
|
|
@@ -58,15 +58,14 @@
|
|
|
58
58
|
"tsdown": "^0.23.0",
|
|
59
59
|
"typescript": "^7",
|
|
60
60
|
"vitest": "^5",
|
|
61
|
-
"@systemfsoftware/
|
|
61
|
+
"@systemfsoftware/effect-gherkin-spec": "^4.2.3",
|
|
62
62
|
"@systemfsoftware/effect-schema-vite": "^2.2.1",
|
|
63
|
-
"@systemfsoftware/effect-gherkin-spec": "^4.2.1",
|
|
64
63
|
"@systemfsoftware/effect-schema-law": "^2.2.1",
|
|
65
|
-
"@systemfsoftware/oxlint-config": "^
|
|
64
|
+
"@systemfsoftware/oxlint-config-recommended": "^1.1.1",
|
|
66
65
|
"@systemfsoftware/stryker-config": "^0.1.0",
|
|
66
|
+
"@systemfsoftware/vitest-config": "^0.1.0",
|
|
67
67
|
"@systemfsoftware/tsdown-config": "^0.1.0",
|
|
68
|
-
"@systemfsoftware/tsconfig": "^1.3.6"
|
|
69
|
-
"@systemfsoftware/vitest-config": "^0.1.0"
|
|
68
|
+
"@systemfsoftware/tsconfig": "^1.3.6"
|
|
70
69
|
},
|
|
71
70
|
"peerDependencies": {
|
|
72
71
|
"effect": "4.0.0-rc.116"
|