@systemfsoftware/effect-daemon-spec 4.0.0 → 4.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @systemfsoftware/effect-daemon-spec
2
2
 
3
+ ## 4.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Update peer and runtime dependency on `effect` and companion packages to `4.0.0-rc.117`.
8
+
9
+ ## 4.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - `cappedBackoff`, `worker`, `leader`, `task`, `withLeaderLock` and the other exported functions that took their subject first can now also be called data-last inside `pipe`. Existing calls keep working.
14
+
3
15
  ## 4.0.0
4
16
 
5
17
  ### Patch Changes
@@ -22,7 +22,10 @@ declare const BoundedIntensity_base: Schema.Class<BoundedIntensity, Schema.Tagge
22
22
  readonly window: Schema.Duration;
23
23
  }>, {}>;
24
24
 
25
- export declare const cappedBackoff: (base: Duration.Input, cap: Duration.Input) => Schedule.Schedule<Duration.Duration>;
25
+ export declare const cappedBackoff: {
26
+ (cap: Duration.Input): (base: Duration.Input) => Schedule.Schedule<Duration.Duration>;
27
+ (base: Duration.Input, cap: Duration.Input): Schedule.Schedule<Duration.Duration>;
28
+ };
26
29
 
27
30
  export declare type Child<E, R> = Worker_2<E, R> | Supervisor<E, R>;
28
31
 
@@ -371,7 +374,10 @@ declare const UnboundedIntensity_base: Schema.Class<UnboundedIntensity, Schema.T
371
374
  /**
372
375
  * Runs `self` while holding the named leader lock.
373
376
  */
374
- export declare function withLeaderLock<A, E, R>(self: Effect.Effect<A, E, R>, options: LeaderLockOptions, lock: LeaderLock['Service']): Effect.Effect<A | void, E | LeaderLockAcquireError, R>;
377
+ export declare const withLeaderLock: {
378
+ <A, E, R>(options: LeaderLockOptions, lock: LeaderLock['Service']): (self: Effect.Effect<A, E, R>) => Effect.Effect<A | void, E | LeaderLockAcquireError, R>;
379
+ <A, E, R>(self: Effect.Effect<A, E, R>, options: LeaderLockOptions, lock: LeaderLock['Service']): Effect.Effect<A | void, E | LeaderLockAcquireError, R>;
380
+ };
375
381
 
376
382
  /**
377
383
  * Boots a worker. The leader-lock capability is acquired here, at the composition
@@ -22,7 +22,10 @@ declare const BoundedIntensity_base: Schema.Class<BoundedIntensity, Schema.Tagge
22
22
  readonly window: Schema.Duration;
23
23
  }>, {}>;
24
24
 
25
- export declare const cappedBackoff: (base: Duration.Input, cap: Duration.Input) => Schedule.Schedule<Duration.Duration>;
25
+ export declare const cappedBackoff: {
26
+ (cap: Duration.Input): (base: Duration.Input) => Schedule.Schedule<Duration.Duration>;
27
+ (base: Duration.Input, cap: Duration.Input): Schedule.Schedule<Duration.Duration>;
28
+ };
26
29
 
27
30
  export declare type Child<E, R> = Worker_2<E, R> | Supervisor<E, R>;
28
31
 
@@ -371,7 +374,10 @@ declare const UnboundedIntensity_base: Schema.Class<UnboundedIntensity, Schema.T
371
374
  /**
372
375
  * Runs `self` while holding the named leader lock.
373
376
  */
374
- export declare function withLeaderLock<A, E, R>(self: Effect.Effect<A, E, R>, options: LeaderLockOptions, lock: LeaderLock['Service']): Effect.Effect<A | void, E | LeaderLockAcquireError, R>;
377
+ export declare const withLeaderLock: {
378
+ <A, E, R>(options: LeaderLockOptions, lock: LeaderLock['Service']): (self: Effect.Effect<A, E, R>) => Effect.Effect<A | void, E | LeaderLockAcquireError, R>;
379
+ <A, E, R>(self: Effect.Effect<A, E, R>, options: LeaderLockOptions, lock: LeaderLock['Service']): Effect.Effect<A | void, E | LeaderLockAcquireError, R>;
380
+ };
375
381
 
376
382
  /**
377
383
  * Boots a worker. The leader-lock capability is acquired here, at the composition
package/dist/index.d.ts CHANGED
@@ -63,7 +63,10 @@ export declare class LockPrimitive extends LockPrimitive_base {}
63
63
  export declare const LeaderLockFromPrimitive: Layer.Layer<LeaderLock, never, LockPrimitive>;
64
64
  //#endregion
65
65
  //#region src/Backoff.d.ts
66
- export declare const cappedBackoff: (base: Duration.Input, cap: Duration.Input) => Schedule.Schedule<Duration.Duration>;
66
+ export declare const cappedBackoff: {
67
+ (cap: Duration.Input): (base: Duration.Input) => Schedule.Schedule<Duration.Duration>;
68
+ (base: Duration.Input, cap: Duration.Input): Schedule.Schedule<Duration.Duration>;
69
+ };
67
70
  //#endregion
68
71
  //#region src/Brands.d.ts
69
72
  export declare const WorkerTypeId: unique symbol;
@@ -276,7 +279,10 @@ interface LeaderLockOptions {
276
279
  /**
277
280
  * Runs `self` while holding the named leader lock.
278
281
  */
279
- export declare function withLeaderLock<A, E, R>(self: Effect.Effect<A, E, R>, options: LeaderLockOptions, lock: LeaderLock['Service']): Effect.Effect<A | void, E | LeaderLockAcquireError, R>;
282
+ export declare const withLeaderLock: {
283
+ <A, E, R>(options: LeaderLockOptions, lock: LeaderLock['Service']): (self: Effect.Effect<A, E, R>) => Effect.Effect<A | void, E | LeaderLockAcquireError, R>;
284
+ <A, E, R>(self: Effect.Effect<A, E, R>, options: LeaderLockOptions, lock: LeaderLock['Service']): Effect.Effect<A | void, E | LeaderLockAcquireError, R>;
285
+ };
280
286
  //#endregion
281
287
  //#region src/SupervisionCustom.d.ts
282
288
  declare const custom: <P>(policy: P) => Effect.Effect<P>;
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { Array, Cause, Clock, Context, Duration, Effect, Equal, Exit, Fiber, HashMap, Latch, Layer, Match, Metric, Option, Predicate, Ref, Result, Schedule, Schema, SchemaGetter, Scope, Stream } from "effect";
1
+ import { Array, Cause, Clock, Context, Duration, Effect, Equal, Exit, Fiber, Function, HashMap, Latch, Layer, Match, Metric, Option, Predicate, Ref, Result, Schedule, Schema, SchemaGetter, Scope, Stream } from "effect";
2
2
  import { Sandwich, Workflow } from "@systemfsoftware/effect-cell-types";
3
3
  import * as Arr from "effect/Array";
4
4
  import * as Match$1 from "effect/Match";
@@ -6,10 +6,10 @@ import "effect/Option";
6
6
  import * as Result$1 from "effect/Result";
7
7
  import * as S from "effect/Schema";
8
8
  //#region src/Backoff.ts
9
- const cappedBackoff = (base, cap) => {
9
+ const cappedBackoff = Function.dual(2, (base, cap) => {
10
10
  const ceiling = Duration.fromInputUnsafe(cap);
11
11
  return Schedule.exponential(base).pipe(Schedule.jittered, Schedule.modifyDelay(({ duration }) => Effect.succeed(Duration.min(duration, ceiling))));
12
- };
12
+ });
13
13
  //#endregion
14
14
  //#region src/Brands.ts
15
15
  const WorkerTypeId = Symbol.for("@systemfsoftware/effect-daemon/Worker");
@@ -206,7 +206,7 @@ const LeaderLockFromPrimitive = Layer.effect(LeaderLock, Effect.gen(function* ()
206
206
  //#endregion
207
207
  //#region src/internal/AllocateSupervisorHealth.ts
208
208
  /** @internal */
209
- const allocateSupervisorHealth = (name, children) => Effect.gen(function* () {
209
+ const allocateSupervisorHealth = Function.dual(2, (name, children) => Effect.gen(function* () {
210
210
  const ready = yield* Latch.make(false);
211
211
  const healthy = yield* Latch.make(true);
212
212
  const paused = yield* Latch.make(true);
@@ -229,7 +229,7 @@ const allocateSupervisorHealth = (name, children) => Effect.gen(function* () {
229
229
  paused,
230
230
  children
231
231
  };
232
- });
232
+ }));
233
233
  //#endregion
234
234
  //#region src/internal/AllocateWorkerHealth.ts
235
235
  /** @internal */
@@ -332,7 +332,7 @@ const buildSubscriptionLoop = (worker, loop, health, readyGauge) => {
332
332
  return wrapSpan(worker, body.pipe(Effect.asVoid));
333
333
  };
334
334
  /** @internal */
335
- const buildWorkerLoop = (worker, health, readyGauge) => Match.value(worker.loop).pipe(Match.tag("Poll", (loop) => buildPollLoop(worker, loop, health, readyGauge)), Match.tag("Stream", (loop) => buildStreamLoop(worker, loop, health, readyGauge)), Match.tag("Subscription", (loop) => buildSubscriptionLoop(worker, loop, health, readyGauge)), Match.exhaustive);
335
+ const buildWorkerLoop = Function.dual(3, (worker, health, readyGauge) => Match.value(worker.loop).pipe(Match.tag("Poll", (loop) => buildPollLoop(worker, loop, health, readyGauge)), Match.tag("Stream", (loop) => buildStreamLoop(worker, loop, health, readyGauge)), Match.tag("Subscription", (loop) => buildSubscriptionLoop(worker, loop, health, readyGauge)), Match.exhaustive));
336
336
  //#endregion
337
337
  //#region src/RunDynamic.ts
338
338
  const buildDynamic = (spec, health) => Effect.gen(function* () {
@@ -580,14 +580,14 @@ const chooseRestartStrategy = Workflow.make({
580
580
  //#endregion
581
581
  //#region src/internal/IntensityWindow.ts
582
582
  /** @internal */
583
- const isWithinWindow = (now, windowMillis) => (t) => now - t <= windowMillis;
583
+ const isWithinWindow = Function.dual(3, (t, now, windowMillis) => now - t <= windowMillis);
584
584
  const keepWithin = (now, windowMillis) => (ts) => ts.filter(isWithinWindow(now, windowMillis));
585
585
  /** @internal */
586
- const pruneTimestamps = (ts, now, windowMillis) => keepWithin(now, windowMillis)(ts);
586
+ const pruneTimestamps = Function.dual(3, (ts, now, windowMillis) => keepWithin(now, windowMillis)(ts));
587
587
  /** @internal */
588
- const recordTimestamp = (ts, now, windowMillis) => [now, ...pruneTimestamps(ts, now, windowMillis)];
588
+ const recordTimestamp = Function.dual(3, (ts, now, windowMillis) => [now, ...pruneTimestamps(ts, now, windowMillis)]);
589
589
  /** @internal */
590
- const exceedsRestarts = (count, restarts) => count > restarts;
590
+ const exceedsRestarts = Function.dual(2, (count, restarts) => count > restarts);
591
591
  //#endregion
592
592
  //#region src/internal/Intensity.ts
593
593
  /** @internal */
@@ -597,7 +597,7 @@ const neverExceeds = {
597
597
  count: Effect.succeed(0)
598
598
  };
599
599
  /** @internal */
600
- const make = (restarts, window) => Effect.gen(function* () {
600
+ const make = Function.dual(2, (restarts, window) => Effect.gen(function* () {
601
601
  const windowMillis = Duration.toMillis(window);
602
602
  const timestamps = yield* Ref.make([]);
603
603
  const prune = (now) => Ref.modify(timestamps, (ts) => {
@@ -619,7 +619,7 @@ const make = (restarts, window) => Effect.gen(function* () {
619
619
  return (yield* prune(now)).length;
620
620
  })
621
621
  };
622
- });
622
+ }));
623
623
  //#endregion
624
624
  //#region src/internal/RaceForExit.ts
625
625
  /** @internal */
@@ -672,11 +672,11 @@ const withRequiredBackoff = (acquire, backoff) => {
672
672
  /**
673
673
  * Runs `self` while holding the named leader lock.
674
674
  */
675
- function withLeaderLock(self, options, lock) {
675
+ const withLeaderLock = Function.dual(3, (self, options, lock) => {
676
676
  const acquire = acquireWithLock(self, options, lock);
677
677
  if (options.mode !== "required") return acquire;
678
678
  return withRequiredBackoff(acquire, options.acquireRetryBackoff);
679
- }
679
+ });
680
680
  //#endregion
681
681
  //#region src/internal/WithLockByModeExecutor.ts
682
682
  /**
@@ -704,10 +704,10 @@ const withKeyedLock = (self, spec, lock) => {
704
704
  }, lock);
705
705
  };
706
706
  /** @internal */
707
- const withLockByMode = (self, binding) => {
707
+ const withLockByMode = Function.dual(2, (self, binding) => {
708
708
  if (binding.kind === "unlocked") return self;
709
709
  return withKeyedLock(self, binding.spec, binding.lock);
710
- };
710
+ });
711
711
  //#endregion
712
712
  //#region src/internal/SupervisorBodyExecutor.ts
713
713
  const handleExhausted = (ctx, cause) => Effect.gen(function* () {
@@ -950,14 +950,14 @@ const bootChild = (child, reporter) => Effect.gen(function* () {
950
950
  };
951
951
  });
952
952
  /** @internal */
953
- const supervisor$1 = (s, reporter, binding) => Effect.gen(function* () {
953
+ const supervisor$1 = Function.dual(3, (s, reporter, binding) => Effect.gen(function* () {
954
954
  const booted = yield* Effect.forEach(s.children, (child) => bootChild(child, reporter));
955
955
  const health = yield* allocateSupervisorHealth(s.name, booted.map((b) => b.health));
956
956
  const body = buildSupervisorBody(s, health, booted, reporter).pipe(Effect.orDie);
957
957
  const locked = withLockByMode(body, binding);
958
958
  yield* Effect.forkScoped(locked.pipe(Effect.orDie), { startImmediately: true });
959
959
  return health;
960
- });
960
+ }));
961
961
  //#endregion
962
962
  //#region src/LeaderLock.ts
963
963
  const isModeNone = (lock) => lock.mode === "none";
@@ -985,13 +985,13 @@ const supervisor = (s) => Effect.gen(function* () {
985
985
  });
986
986
  //#endregion
987
987
  //#region src/DaemonWorkerExecutor.ts
988
- const worker$2 = (w, binding) => Effect.gen(function* () {
988
+ const worker$2 = Function.dual(2, (w, binding) => Effect.gen(function* () {
989
989
  const health = yield* allocateWorkerHealth(w.name);
990
990
  const loop = buildWorkerLoop(w, health, healthStateGauge).pipe(Effect.orDie);
991
991
  const locked = withLockByMode(loop, binding);
992
992
  yield* Effect.forkScoped(locked.pipe(Effect.orDie));
993
993
  return health;
994
- });
994
+ }));
995
995
  //#endregion
996
996
  //#region src/RunWorker.ts
997
997
  /**
@@ -1023,11 +1023,11 @@ const LeaderConfig = Context.Reference("@systemfsoftware/effect-daemon-spec/Lead
1023
1023
  intensity: UnboundedIntensity.make(),
1024
1024
  cooldown: Duration.zero
1025
1025
  }) });
1026
- const leader$1 = (config, cap) => Effect.succeed({
1026
+ const leader$1 = Function.dual(2, (config, cap) => Effect.succeed({
1027
1027
  intensity: config.intensity,
1028
1028
  backoff: cappedBackoff(config.backoffBase, cap),
1029
1029
  cooldown: config.cooldown
1030
- });
1030
+ }));
1031
1031
  //#endregion
1032
1032
  //#region src/SupervisionTask.ts
1033
1033
  const TaskConfig = Context.Reference("@systemfsoftware/effect-daemon-spec/TaskConfig", { defaultValue: () => ({
@@ -1035,11 +1035,11 @@ const TaskConfig = Context.Reference("@systemfsoftware/effect-daemon-spec/TaskCo
1035
1035
  intensity: UnboundedIntensity.make(),
1036
1036
  cooldown: Duration.zero
1037
1037
  }) });
1038
- const task$1 = (config, budget) => Effect.succeed({
1038
+ const task$1 = Function.dual(2, (config, budget) => Effect.succeed({
1039
1039
  intensity: config.intensity,
1040
1040
  backoff: Schedule.exponential(config.backoffBase).pipe(Schedule.jittered, Schedule.upTo({ duration: budget })),
1041
1041
  cooldown: config.cooldown
1042
- });
1042
+ }));
1043
1043
  //#endregion
1044
1044
  //#region src/SupervisionWorker.ts
1045
1045
  const WorkerConfig = Context.Reference("@systemfsoftware/effect-daemon-spec/WorkerConfig", { defaultValue: () => ({
@@ -1050,11 +1050,11 @@ const WorkerConfig = Context.Reference("@systemfsoftware/effect-daemon-spec/Work
1050
1050
  }),
1051
1051
  cooldown: Duration.seconds(30)
1052
1052
  }) });
1053
- const worker$1 = (config, cap) => Effect.succeed({
1053
+ const worker$1 = Function.dual(2, (config, cap) => Effect.succeed({
1054
1054
  intensity: config.intensity,
1055
1055
  backoff: cappedBackoff(config.backoffBase, cap),
1056
1056
  cooldown: config.cooldown
1057
- });
1057
+ }));
1058
1058
  //#endregion
1059
1059
  //#region src/SupervisorOneForAll.ts
1060
1060
  const oneForAll$1 = (opts) => ({
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.0.0",
4
+ "version": "4.1.1",
5
5
  "author": "Ryan Lee <drdgvhbh@gmail.com>",
6
6
  "repository": {
7
7
  "type": "git",
@@ -37,38 +37,38 @@
37
37
  "dist"
38
38
  ],
39
39
  "dependencies": {
40
- "@systemfsoftware/effect-cell-types": "^10.0.0"
40
+ "@systemfsoftware/effect-cell-types": "^10.1.1"
41
41
  },
42
42
  "devDependencies": {
43
- "@effect/vitest": "4.0.0-rc.116",
43
+ "@effect/vitest": "4.0.0-rc.117",
44
44
  "@microsoft/api-extractor": "^7.59.1",
45
45
  "@systemfsoftware/arethetypeswrong-cli": "^4.2.0",
46
+ "@systemfsoftware/effect-gherkin-spec": "^4.3.1",
47
+ "@systemfsoftware/effect-schema-law": "^2.3.1",
48
+ "@systemfsoftware/effect-schema-vite": "^2.2.3",
49
+ "@systemfsoftware/oxlint-config-recommended": "^2.0.2",
50
+ "@systemfsoftware/stryker-config": "^0.1.0",
46
51
  "@systemfsoftware/stryker-ignorer-effect-schema-declarations": "^0.1.1",
47
52
  "@systemfsoftware/stryker-ignorer-in-source-vitest-block": "^0.1.1",
48
53
  "@systemfsoftware/stryker-js": "^10.1.1",
49
54
  "@systemfsoftware/stryker-js-typescript-checker": "^7.0.5",
50
55
  "@systemfsoftware/stryker-js-vitest-runner": "^7.1.1",
51
56
  "@systemfsoftware/stryker-test-contribution": "^3.0.3",
57
+ "@systemfsoftware/tsconfig": "^2.0.1",
58
+ "@systemfsoftware/tsdown-config": "^0.1.0",
59
+ "@systemfsoftware/vitest-config": "^0.1.0",
52
60
  "@types/node": "^26",
53
61
  "@vitest/coverage-v8": "^5",
54
- "effect": "4.0.0-rc.116",
62
+ "effect": "4.0.0-rc.117",
55
63
  "fast-check": "^4",
56
64
  "oxlint": "~1.82.0",
57
65
  "rimraf": "^6.1.3",
58
66
  "tsdown": "^0.23.0",
59
67
  "typescript": "^7",
60
- "vitest": "^5",
61
- "@systemfsoftware/effect-gherkin-spec": "^4.2.3",
62
- "@systemfsoftware/effect-schema-vite": "^2.2.1",
63
- "@systemfsoftware/effect-schema-law": "^2.2.1",
64
- "@systemfsoftware/oxlint-config-recommended": "^1.1.1",
65
- "@systemfsoftware/stryker-config": "^0.1.0",
66
- "@systemfsoftware/vitest-config": "^0.1.0",
67
- "@systemfsoftware/tsdown-config": "^0.1.0",
68
- "@systemfsoftware/tsconfig": "^1.3.6"
68
+ "vitest": "^5"
69
69
  },
70
70
  "peerDependencies": {
71
- "effect": "4.0.0-rc.116"
71
+ "effect": "4.0.0-rc.117"
72
72
  },
73
73
  "publishConfig": {
74
74
  "provenance": true
@@ -76,7 +76,7 @@
76
76
  "scripts": {
77
77
  "clean": "rimraf dist",
78
78
  "build": "tsdown -l warn && pnpm api:check",
79
- "typecheck": "tsc --noEmit --incremental",
79
+ "typecheck": "tsc -b",
80
80
  "test": "vitest run",
81
81
  "mutation": "stryker run",
82
82
  "mutation:full": "stryker run --force",