@systemfsoftware/effect-daemon-spec 0.1.0 → 0.2.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/dist/index.d.ts +6 -7
- package/dist/index.mjs +25 -15
- package/package.json +9 -10
- package/dist/effect-daemon-spec.d.ts +0 -410
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Cause, Context, Duration, Effect, Layer, Metric, Option, Schedule, Schema, Scope, Stream } from "effect";
|
|
2
|
-
|
|
3
2
|
//#region src/backoff.d.ts
|
|
4
3
|
declare const cappedBackoff: (base: Duration.DurationInput, cap: Duration.DurationInput) => Schedule.Schedule<Duration.Duration>;
|
|
5
4
|
//#endregion
|
|
@@ -80,12 +79,12 @@ declare const ChildPolicyConfig_base: Schema.Class<ChildPolicyConfig, {
|
|
|
80
79
|
window: typeof Schema.DurationFromSelf;
|
|
81
80
|
}>>;
|
|
82
81
|
}>, never, {
|
|
82
|
+
readonly restart?: "permanent" | "transient" | "temporary" | undefined;
|
|
83
|
+
} & {
|
|
83
84
|
readonly intensity?: {
|
|
84
85
|
readonly restarts: number;
|
|
85
86
|
readonly window: import("effect/Duration").Duration;
|
|
86
87
|
} | undefined;
|
|
87
|
-
} & {
|
|
88
|
-
readonly restart?: "permanent" | "temporary" | "transient" | undefined;
|
|
89
88
|
}, {}, {}>;
|
|
90
89
|
declare class ChildPolicyConfig extends ChildPolicyConfig_base {}
|
|
91
90
|
declare const LockPolicyConfig_base: Schema.Class<LockPolicyConfig, {
|
|
@@ -95,9 +94,9 @@ declare const LockPolicyConfig_base: Schema.Class<LockPolicyConfig, {
|
|
|
95
94
|
mode: Schema.optional<Schema.Literal<["none", "required", "optional"]>>;
|
|
96
95
|
key: Schema.optional<typeof Schema.String>;
|
|
97
96
|
}>, never, {
|
|
98
|
-
readonly
|
|
97
|
+
readonly mode?: "none" | "required" | "optional" | undefined;
|
|
99
98
|
} & {
|
|
100
|
-
readonly
|
|
99
|
+
readonly key?: string | undefined;
|
|
101
100
|
}, {}, {}>;
|
|
102
101
|
declare class LockPolicyConfig extends LockPolicyConfig_base {}
|
|
103
102
|
declare const TickPolicyConfig_base: Schema.Class<TickPolicyConfig, {
|
|
@@ -109,11 +108,11 @@ declare const TickPolicyConfig_base: Schema.Class<TickPolicyConfig, {
|
|
|
109
108
|
tickTimeout: typeof Schema.DurationFromSelf;
|
|
110
109
|
startLogLevel: Schema.optional<Schema.Literal<["debug", "info"]>>;
|
|
111
110
|
}>, never, {
|
|
111
|
+
readonly tickTimeout: import("effect/Duration").Duration;
|
|
112
|
+
} & {
|
|
112
113
|
readonly spanName?: string | undefined;
|
|
113
114
|
} & {
|
|
114
115
|
readonly startLogLevel?: "debug" | "info" | undefined;
|
|
115
|
-
} & {
|
|
116
|
-
readonly tickTimeout: import("effect/Duration").Duration;
|
|
117
116
|
}, {}, {}>;
|
|
118
117
|
declare class TickPolicyConfig extends TickPolicyConfig_base {}
|
|
119
118
|
//#endregion
|
package/dist/index.mjs
CHANGED
|
@@ -73,15 +73,19 @@ const make$1 = (common, loop) => ({
|
|
|
73
73
|
lock: common.lock
|
|
74
74
|
});
|
|
75
75
|
const poll = (opts) => {
|
|
76
|
-
if (typeof opts.prereq === "undefined")
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
if (typeof opts.prereq === "undefined") {
|
|
77
|
+
const gate = Effect.succeed(Option.some(Effect.asVoid(opts.work)));
|
|
78
|
+
return make$1(opts, {
|
|
79
|
+
_tag: "Poll",
|
|
80
|
+
gate,
|
|
81
|
+
interval: opts.interval
|
|
82
|
+
});
|
|
83
|
+
}
|
|
81
84
|
const { prereq, work } = opts;
|
|
85
|
+
const gate = Effect.map(prereq, Option.map((data) => work(data)));
|
|
82
86
|
return make$1(opts, {
|
|
83
87
|
_tag: "Poll",
|
|
84
|
-
gate
|
|
88
|
+
gate,
|
|
85
89
|
interval: opts.interval
|
|
86
90
|
});
|
|
87
91
|
};
|
|
@@ -165,10 +169,12 @@ const boundedTracker = (restarts, window) => Effect.gen(function* () {
|
|
|
165
169
|
yield* Ref.update(timestamps, (ts) => recordTimestamp(ts, now, windowMillis));
|
|
166
170
|
}),
|
|
167
171
|
isExceeded: Effect.gen(function* () {
|
|
168
|
-
|
|
172
|
+
const now = yield* Clock.currentTimeMillis;
|
|
173
|
+
return exceedsRestarts((yield* prune(now)).length, restarts);
|
|
169
174
|
}),
|
|
170
175
|
count: Effect.gen(function* () {
|
|
171
|
-
|
|
176
|
+
const now = yield* Clock.currentTimeMillis;
|
|
177
|
+
return (yield* prune(now)).length;
|
|
172
178
|
})
|
|
173
179
|
};
|
|
174
180
|
});
|
|
@@ -284,7 +290,7 @@ const superviseChild = (ctx, child, idx) => Effect.gen(function* () {
|
|
|
284
290
|
});
|
|
285
291
|
const loop = () => Effect.gen(function* () {
|
|
286
292
|
const supIntensity = yield* make(ctx.policy.intensity);
|
|
287
|
-
const
|
|
293
|
+
const attempt = Effect.gen(function* () {
|
|
288
294
|
yield* ctx.health.paused.await;
|
|
289
295
|
const fiber = yield* Effect.forkScoped(child.run);
|
|
290
296
|
const exit = yield* Fiber.await(fiber);
|
|
@@ -308,7 +314,8 @@ const superviseChild = (ctx, child, idx) => Effect.gen(function* () {
|
|
|
308
314
|
return yield* Match.value(decision).pipe(Match.tag("Continue", () => Effect.succeed(new StopEpoch())), Match.tag("Exhausted", () => handleExhausted(ctx, exit.cause)), Match.tag("Restart", () => handleRestart(ctx, exit.cause, Effect.void)), Match.exhaustive);
|
|
309
315
|
}
|
|
310
316
|
return new StopEpoch();
|
|
311
|
-
})
|
|
317
|
+
});
|
|
318
|
+
const epochResult = yield* runSupervisionEpochWithBackoff(attempt, ctx);
|
|
312
319
|
return yield* Match.value(epochResult).pipe(Match.tag("ContinueSupervision", () => loop()), Match.tag("StopSupervision", () => Effect.void), Match.exhaustive);
|
|
313
320
|
});
|
|
314
321
|
return yield* loop();
|
|
@@ -327,7 +334,7 @@ const runGroup = (strategy, ctx) => Effect.gen(function* () {
|
|
|
327
334
|
onSome: (cfg) => Effect.map(make(new BoundedIntensity(cfg)), Option.some)
|
|
328
335
|
}));
|
|
329
336
|
const cursor = yield* Ref.make(0);
|
|
330
|
-
const
|
|
337
|
+
const attempt = Effect.gen(function* () {
|
|
331
338
|
yield* ctx.health.paused.await;
|
|
332
339
|
const startIdx = yield* Ref.get(cursor);
|
|
333
340
|
const slice = ctx.booted.slice(startIdx);
|
|
@@ -359,7 +366,8 @@ const runGroup = (strategy, ctx) => Effect.gen(function* () {
|
|
|
359
366
|
return yield* Match.value(decision).pipe(Match.tag("Continue", () => Effect.succeed(new StopEpoch())), Match.tag("Exhausted", () => handleExhausted(ctx, firstExit.cause)), Match.tag("Restart", (restartDecision) => handleRestart(ctx, firstExit.cause, Ref.set(cursor, restartDecision.indices[0]))), Match.exhaustive);
|
|
360
367
|
}
|
|
361
368
|
return new StopEpoch();
|
|
362
|
-
})
|
|
369
|
+
});
|
|
370
|
+
const epochResult = yield* runSupervisionEpochWithBackoff(attempt, ctx);
|
|
363
371
|
return yield* Match.value(epochResult).pipe(Match.tag("ContinueSupervision", () => loop()), Match.tag("StopSupervision", () => Effect.void), Match.exhaustive);
|
|
364
372
|
});
|
|
365
373
|
return yield* loop();
|
|
@@ -463,15 +471,17 @@ const buildStreamLoop = (worker, loop, health) => {
|
|
|
463
471
|
yield* Effect.raceFirst(ready, Fiber.join(fiber));
|
|
464
472
|
yield* Fiber.join(fiber);
|
|
465
473
|
});
|
|
466
|
-
|
|
474
|
+
const retried = applyInnerRetry(worker.tickHooks)(body);
|
|
475
|
+
return wrapSpan(worker, retried.pipe(Effect.asVoid));
|
|
467
476
|
};
|
|
468
477
|
const buildSubscriptionLoop = (worker, loop, health) => {
|
|
469
|
-
|
|
478
|
+
const body = Effect.gen(function* () {
|
|
470
479
|
yield* health.paused.await;
|
|
471
480
|
yield* applyTimeout(worker.tick)(loop.acquire);
|
|
472
481
|
yield* Effect.zipRight(health.ready.open, Metric.set(Metric.tagged(Metric.tagged(healthStateGauge, "daemon", health.name), "latch", "ready"), 1));
|
|
473
482
|
return yield* Effect.never;
|
|
474
|
-
})
|
|
483
|
+
});
|
|
484
|
+
return wrapSpan(worker, body.pipe(Effect.asVoid));
|
|
475
485
|
};
|
|
476
486
|
const buildWorkerLoop = (worker, health) => Match.value(worker.loop).pipe(Match.tag("Poll", (loop) => buildPollLoop(worker, loop, health)), Match.tag("Stream", (loop) => buildStreamLoop(worker, loop, health)), Match.tag("Subscription", (loop) => buildSubscriptionLoop(worker, loop, health)), Match.exhaustive);
|
|
477
487
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@systemfsoftware/effect-daemon-spec",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"author": "Ryan Lee <drdgvhbh@gmail.com>",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -37,23 +37,22 @@
|
|
|
37
37
|
"dist"
|
|
38
38
|
],
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@effect/vitest": "0.
|
|
40
|
+
"@effect/vitest": "0.30.0",
|
|
41
41
|
"@microsoft/api-extractor": "^7.58.7",
|
|
42
|
-
"@stryker-mutator/core": "^9.6.1",
|
|
43
|
-
"@stryker-mutator/typescript-checker": "^9.6.1",
|
|
44
42
|
"@stryker-mutator/vitest-runner": "^9.6.1",
|
|
45
43
|
"@types/node": "^24",
|
|
46
44
|
"@vitest/coverage-v8": "^4",
|
|
47
|
-
"effect": "^3.
|
|
45
|
+
"effect": "^3.22.0",
|
|
48
46
|
"fast-check": "^3",
|
|
49
47
|
"rimraf": "^6.1.3",
|
|
50
|
-
"tsdown": "^0.22.
|
|
51
|
-
"typescript": "^6.0.3",
|
|
48
|
+
"tsdown": "^0.22.9",
|
|
52
49
|
"vite-tsconfig-paths": "^6.1.1",
|
|
53
50
|
"vitest": "^4",
|
|
54
|
-
"@systemfsoftware/effect-gherkin-spec": "^0.1.0",
|
|
55
|
-
"@systemfsoftware/oxlint-config": "^0.1.0",
|
|
56
51
|
"@systemfsoftware/effect-schema-law": "^0.1.0",
|
|
52
|
+
"@systemfsoftware/stryker-js-core": "^0.1.0",
|
|
53
|
+
"@systemfsoftware/oxlint-config": "^0.1.0",
|
|
54
|
+
"@systemfsoftware/stryker-js-typescript-checker": "^0.1.0",
|
|
55
|
+
"@systemfsoftware/effect-gherkin-spec": "^0.1.0",
|
|
57
56
|
"@systemfsoftware/stryker-plugins": "^0.1.0",
|
|
58
57
|
"@systemfsoftware/tsconfig": "^1.0.0",
|
|
59
58
|
"@systemfsoftware/vitest-config": "^0.1.0"
|
|
@@ -64,7 +63,7 @@
|
|
|
64
63
|
"scripts": {
|
|
65
64
|
"clean": "rimraf dist",
|
|
66
65
|
"build": "tsdown",
|
|
67
|
-
"typecheck": "
|
|
66
|
+
"typecheck": "tsc --noEmit --incremental",
|
|
68
67
|
"test": "vitest run",
|
|
69
68
|
"test:run": "vitest run",
|
|
70
69
|
"mutation": "stryker run --incremental",
|
|
@@ -1,410 +0,0 @@
|
|
|
1
|
-
import { Cause } from 'effect';
|
|
2
|
-
import { Context } from 'effect';
|
|
3
|
-
import { Duration } from 'effect';
|
|
4
|
-
import { Duration as Duration_2 } from 'effect/Duration';
|
|
5
|
-
import { Effect } from 'effect';
|
|
6
|
-
import { Layer } from 'effect';
|
|
7
|
-
import { Metric } from 'effect';
|
|
8
|
-
import { Option as Option_2 } from 'effect';
|
|
9
|
-
import { Schedule } from 'effect';
|
|
10
|
-
import { Schema } from 'effect';
|
|
11
|
-
import { Scope } from 'effect';
|
|
12
|
-
import { Stream } from 'effect';
|
|
13
|
-
|
|
14
|
-
export declare class BoundedIntensity extends BoundedIntensity_base {
|
|
15
|
-
readonly [IntensityTypeId]: symbol;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
declare const BoundedIntensity_base: Schema.TaggedClass<BoundedIntensity, "Bounded", {
|
|
19
|
-
readonly _tag: Schema.tag<"Bounded">;
|
|
20
|
-
} & Readonly<{
|
|
21
|
-
restarts: Schema.filter<typeof Schema.Int>;
|
|
22
|
-
window: typeof Schema.DurationFromSelf;
|
|
23
|
-
}>>;
|
|
24
|
-
|
|
25
|
-
export declare const cappedBackoff: (base: Duration.DurationInput, cap: Duration.DurationInput) => Schedule.Schedule<Duration.Duration>;
|
|
26
|
-
|
|
27
|
-
export declare type Child<E, R> = Worker_2<E, R> | Supervisor<E, R>;
|
|
28
|
-
|
|
29
|
-
export declare class ChildPolicyConfig extends ChildPolicyConfig_base {}
|
|
30
|
-
|
|
31
|
-
declare const ChildPolicyConfig_base: Schema.Class<ChildPolicyConfig, {
|
|
32
|
-
restart: Schema.optional<Schema.Literal<["permanent", "transient", "temporary"]>>;
|
|
33
|
-
intensity: Schema.optional<Schema.Struct<{
|
|
34
|
-
restarts: Schema.filter<typeof Schema.Int>;
|
|
35
|
-
window: typeof Schema.DurationFromSelf;
|
|
36
|
-
}>>;
|
|
37
|
-
}, Schema.Struct.Encoded<{
|
|
38
|
-
restart: Schema.optional<Schema.Literal<["permanent", "transient", "temporary"]>>;
|
|
39
|
-
intensity: Schema.optional<Schema.Struct<{
|
|
40
|
-
restarts: Schema.filter<typeof Schema.Int>;
|
|
41
|
-
window: typeof Schema.DurationFromSelf;
|
|
42
|
-
}>>;
|
|
43
|
-
}>, never, {
|
|
44
|
-
readonly intensity?: {
|
|
45
|
-
readonly restarts: number;
|
|
46
|
-
readonly window: Duration_2;
|
|
47
|
-
} | undefined;
|
|
48
|
-
} & {
|
|
49
|
-
readonly restart?: "permanent" | "temporary" | "transient" | undefined;
|
|
50
|
-
}, {}, {}>;
|
|
51
|
-
|
|
52
|
-
export declare type ChildRef = {
|
|
53
|
-
readonly id: number;
|
|
54
|
-
readonly removed: Effect.Effect<void>;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export declare interface CommonOpts<L extends LockConfig> {
|
|
58
|
-
readonly name: string;
|
|
59
|
-
readonly child?: typeof ChildPolicyConfig.Type;
|
|
60
|
-
readonly tick: typeof TickPolicyConfig.Type;
|
|
61
|
-
readonly tickHooks?: TickPolicyHooks;
|
|
62
|
-
readonly lock: L;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export declare const Daemon: {
|
|
66
|
-
readonly poll: <A, E, R, L extends LockConfig>(opts: PollOpts<A, E, R, L>) => Worker_2<E, R, L>;
|
|
67
|
-
readonly stream: <A, E, R, L extends LockConfig>(opts: CommonOpts<L> & {
|
|
68
|
-
readonly stream: Stream.Stream<A, E, R>;
|
|
69
|
-
}) => Worker_2<E, R, L>;
|
|
70
|
-
readonly subscription: <A, E, R, L extends LockConfig>(opts: CommonOpts<L> & {
|
|
71
|
-
readonly acquire: Effect.Effect<A, E, R>;
|
|
72
|
-
}) => Worker_2<E, R, L>;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export declare interface DaemonHealth {
|
|
76
|
-
readonly name: string;
|
|
77
|
-
readonly ready: Effect.Latch;
|
|
78
|
-
readonly healthy: Effect.Latch;
|
|
79
|
-
readonly paused: Effect.Latch;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export declare class DaemonReporter extends DaemonReporter_base {
|
|
83
|
-
static readonly Noop: Layer.Layer<DaemonReporter>;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
declare const DaemonReporter_base: Context.TagClass<DaemonReporter, "@systemfsoftware/effect-daemon-spec/daemon-reporter/DaemonReporter", DaemonReporterService>;
|
|
87
|
-
|
|
88
|
-
export declare interface DaemonReporterService {
|
|
89
|
-
readonly onRestart: (name: string, cause: Cause.Cause<never>) => Effect.Effect<void>;
|
|
90
|
-
readonly onExhausted: (name: string, cause: Cause.Cause<never>) => Effect.Effect<void>;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export declare const dynamic: <E, R, Args>(opts: {
|
|
94
|
-
readonly name: string;
|
|
95
|
-
readonly child: (args: Args) => Worker_2<E, R>;
|
|
96
|
-
readonly maxChildren?: number;
|
|
97
|
-
}) => DynamicSpec<E, R, Args>;
|
|
98
|
-
|
|
99
|
-
export declare interface DynamicHandle<Args, R = never> {
|
|
100
|
-
readonly health: SupervisorHealth;
|
|
101
|
-
readonly startChild: (args: Args) => Effect.Effect<ChildRef, DynamicLimitExceeded, R>;
|
|
102
|
-
readonly stopChild: (ref: Pick<ChildRef, 'id'>) => Effect.Effect<void>;
|
|
103
|
-
readonly count: Effect.Effect<number>;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export declare class DynamicLimitExceeded extends DynamicLimitExceeded_base {}
|
|
107
|
-
|
|
108
|
-
declare const DynamicLimitExceeded_base: Schema.TaggedErrorClass<DynamicLimitExceeded, "DynamicLimitExceeded", {
|
|
109
|
-
readonly _tag: Schema.tag<"DynamicLimitExceeded">;
|
|
110
|
-
} & {
|
|
111
|
-
limit: Schema.filter<typeof Schema.Int>;
|
|
112
|
-
}>;
|
|
113
|
-
|
|
114
|
-
export declare interface DynamicSpec<E, R, Args> {
|
|
115
|
-
readonly [DynamicSpecTypeId]: DynamicSpecTypeId;
|
|
116
|
-
readonly name: string;
|
|
117
|
-
readonly child: (args: Args) => Worker_2<E, R>;
|
|
118
|
-
readonly maxChildren: number;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export declare const DynamicSpecTypeId: unique symbol;
|
|
122
|
-
|
|
123
|
-
export declare type DynamicSpecTypeId = typeof DynamicSpecTypeId;
|
|
124
|
-
|
|
125
|
-
export declare const healthStateGauge: Metric.Metric.Gauge<number>;
|
|
126
|
-
|
|
127
|
-
export declare const Intensity: Schema.Union<[typeof BoundedIntensity, typeof UnboundedIntensity]>;
|
|
128
|
-
|
|
129
|
-
export declare type Intensity = typeof Intensity.Type;
|
|
130
|
-
|
|
131
|
-
export declare const IntensityConfig: Schema.Struct<{
|
|
132
|
-
restarts: Schema.filter<typeof Schema.Int>;
|
|
133
|
-
window: typeof Schema.DurationFromSelf;
|
|
134
|
-
}>;
|
|
135
|
-
|
|
136
|
-
export declare type IntensityConfig = typeof IntensityConfig.Type;
|
|
137
|
-
|
|
138
|
-
export declare const IntensityTypeId: unique symbol;
|
|
139
|
-
|
|
140
|
-
export declare type IntensityTypeId = typeof IntensityTypeId;
|
|
141
|
-
|
|
142
|
-
export declare const isSupervisor: <E, R>(x: Child<E, R>) => x is Supervisor<E, R>;
|
|
143
|
-
|
|
144
|
-
export declare const isWorker: <E, R>(x: Child<E, R>) => x is Worker_2<E, R>;
|
|
145
|
-
|
|
146
|
-
export declare class LeaderConfig extends LeaderConfig_base {}
|
|
147
|
-
|
|
148
|
-
declare const LeaderConfig_base: Context.ReferenceClass<LeaderConfig, "@systemfsoftware/effect-daemon-spec/LeaderConfig", SupervisionConfig>;
|
|
149
|
-
|
|
150
|
-
export declare class LeaderLock extends LeaderLock_base {
|
|
151
|
-
static readonly Noop: Layer.Layer<LeaderLock>;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
declare const LeaderLock_base: Context.TagClass<LeaderLock, "@systemfsoftware/effect-daemon-spec/leader-lock/LeaderLock", LeaderLockService>;
|
|
155
|
-
|
|
156
|
-
export declare type LeaderLockAcquireError = LeaderLockNotAcquired | LeaderLockInfraError;
|
|
157
|
-
|
|
158
|
-
export declare const LeaderLockFromPrimitive: Layer.Layer<LeaderLock, never, LockPrimitive>;
|
|
159
|
-
|
|
160
|
-
export declare class LeaderLockInfraError extends LeaderLockInfraError_base {}
|
|
161
|
-
|
|
162
|
-
declare const LeaderLockInfraError_base: Schema.TaggedErrorClass<LeaderLockInfraError, "LeaderLockInfraError", {
|
|
163
|
-
readonly _tag: Schema.tag<"LeaderLockInfraError">;
|
|
164
|
-
} & {
|
|
165
|
-
key: typeof Schema.String;
|
|
166
|
-
cause: typeof Schema.Unknown;
|
|
167
|
-
}>;
|
|
168
|
-
|
|
169
|
-
export declare class LeaderLockNotAcquired extends LeaderLockNotAcquired_base {}
|
|
170
|
-
|
|
171
|
-
declare const LeaderLockNotAcquired_base: Schema.TaggedErrorClass<LeaderLockNotAcquired, "LeaderLockNotAcquired", {
|
|
172
|
-
readonly _tag: Schema.tag<"LeaderLockNotAcquired">;
|
|
173
|
-
} & {
|
|
174
|
-
key: typeof Schema.String;
|
|
175
|
-
}>;
|
|
176
|
-
|
|
177
|
-
export declare interface LeaderLockOptions {
|
|
178
|
-
readonly key: string;
|
|
179
|
-
readonly mode: 'required' | 'optional';
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
export declare interface LeaderLockService {
|
|
183
|
-
readonly withLock: <A, E, R>(key: string, self: Effect.Effect<A, E, R>) => Effect.Effect<Option_2.Option<A>, E | LeaderLockInfraError, R>;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
export declare type LockConfig = {
|
|
187
|
-
mode: 'none';
|
|
188
|
-
} | {
|
|
189
|
-
mode: 'optional';
|
|
190
|
-
key: string;
|
|
191
|
-
} | {
|
|
192
|
-
mode: 'required';
|
|
193
|
-
key: string;
|
|
194
|
-
acquireRetryBackoff: Schedule.Schedule<Duration.Duration>;
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
export declare class LockPolicyConfig extends LockPolicyConfig_base {}
|
|
198
|
-
|
|
199
|
-
declare const LockPolicyConfig_base: Schema.Class<LockPolicyConfig, {
|
|
200
|
-
mode: Schema.optional<Schema.Literal<["none", "required", "optional"]>>;
|
|
201
|
-
key: Schema.optional<typeof Schema.String>;
|
|
202
|
-
}, Schema.Struct.Encoded<{
|
|
203
|
-
mode: Schema.optional<Schema.Literal<["none", "required", "optional"]>>;
|
|
204
|
-
key: Schema.optional<typeof Schema.String>;
|
|
205
|
-
}>, never, {
|
|
206
|
-
readonly key?: string | undefined;
|
|
207
|
-
} & {
|
|
208
|
-
readonly mode?: "none" | "optional" | "required" | undefined;
|
|
209
|
-
}, {}, {}>;
|
|
210
|
-
|
|
211
|
-
export declare class LockPrimitive extends LockPrimitive_base {}
|
|
212
|
-
|
|
213
|
-
declare const LockPrimitive_base: Context.TagClass<LockPrimitive, "@systemfsoftware/effect-daemon-spec/lock-primitive/LockPrimitive", LockPrimitiveService>;
|
|
214
|
-
|
|
215
|
-
export declare class LockPrimitiveError extends LockPrimitiveError_base {}
|
|
216
|
-
|
|
217
|
-
declare const LockPrimitiveError_base: Schema.TaggedErrorClass<LockPrimitiveError, "LockPrimitiveError", {
|
|
218
|
-
readonly _tag: Schema.tag<"LockPrimitiveError">;
|
|
219
|
-
} & {
|
|
220
|
-
key: typeof Schema.String;
|
|
221
|
-
cause: typeof Schema.Unknown;
|
|
222
|
-
}>;
|
|
223
|
-
|
|
224
|
-
export declare interface LockPrimitiveService {
|
|
225
|
-
readonly tryAcquire: (key: string) => Effect.Effect<boolean, LockPrimitiveError, Scope.Scope>;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
export declare type LoopShape<E, R> = PollLoop<E, R> | StreamLoop<E, R> | SubscriptionLoop<E, R>;
|
|
229
|
-
|
|
230
|
-
export declare const oneForAll: <E, R, L extends LockConfig = LockConfig>(opts: SupervisorOpts<E, R, L>) => Supervisor<E, R, L>;
|
|
231
|
-
|
|
232
|
-
export declare const oneForOne: <E, R, L extends LockConfig = LockConfig>(opts: SupervisorOpts<E, R, L>) => Supervisor<E, R, L>;
|
|
233
|
-
|
|
234
|
-
export declare const poll: <A, E, R, L extends LockConfig>(opts: PollOpts<A, E, R, L>) => Worker_2<E, R, L>;
|
|
235
|
-
|
|
236
|
-
export declare type PollLoop<E, R> = {
|
|
237
|
-
readonly _tag: 'Poll';
|
|
238
|
-
readonly gate: Effect.Effect<Option_2.Option<Effect.Effect<void, E, R>>, E, R>;
|
|
239
|
-
readonly interval: Duration.DurationInput;
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
export declare type PollOpts<A, E, R, L extends LockConfig> = CommonOpts<L> & {
|
|
243
|
-
readonly interval: Duration.DurationInput;
|
|
244
|
-
} & ({
|
|
245
|
-
readonly prereq?: undefined;
|
|
246
|
-
readonly work: Effect.Effect<A, E, R>;
|
|
247
|
-
} | {
|
|
248
|
-
readonly prereq: Effect.Effect<Option_2.Option<A>, E, R>;
|
|
249
|
-
readonly work: (data: A) => Effect.Effect<void, E, R>;
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
export declare interface ReporterPolicyHooks {
|
|
253
|
-
readonly onRestart?: (cause: Cause.Cause<never>) => Effect.Effect<void>;
|
|
254
|
-
readonly onExhausted?: (cause: Cause.Cause<never>) => Effect.Effect<void>;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
export declare const restForOne: <E, R, L extends LockConfig = LockConfig>(opts: SupervisorOpts<E, R, L>) => Supervisor<E, R, L>;
|
|
258
|
-
|
|
259
|
-
export declare const run: {
|
|
260
|
-
readonly worker: typeof worker;
|
|
261
|
-
readonly supervisor: typeof supervisor;
|
|
262
|
-
readonly dynamic: <E, R, Args>(spec: DynamicSpec<E, R, Args>) => Effect.Effect<DynamicHandle<Args, R | LeaderLock | DaemonReporter | Scope.Scope>, never, R | LeaderLock | DaemonReporter | Scope.Scope>;
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
export declare const stream: <A, E, R, L extends LockConfig>(opts: CommonOpts<L> & {
|
|
266
|
-
readonly stream: Stream.Stream<A, E, R>;
|
|
267
|
-
}) => Worker_2<E, R, L>;
|
|
268
|
-
|
|
269
|
-
export declare type StreamLoop<E, R> = {
|
|
270
|
-
readonly _tag: 'Stream';
|
|
271
|
-
readonly stream: Stream.Stream<unknown, E, R>;
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
export declare const subscription: <A, E, R, L extends LockConfig>(opts: CommonOpts<L> & {
|
|
275
|
-
readonly acquire: Effect.Effect<A, E, R>;
|
|
276
|
-
}) => Worker_2<E, R, L>;
|
|
277
|
-
|
|
278
|
-
export declare type SubscriptionLoop<E, R> = {
|
|
279
|
-
readonly _tag: 'Subscription';
|
|
280
|
-
readonly acquire: Effect.Effect<void, E, R>;
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
export declare const Supervision: {
|
|
284
|
-
readonly leader: (cap: Duration.DurationInput) => Effect.Effect<SupervisionPolicy>;
|
|
285
|
-
readonly worker: (cap: Duration.DurationInput) => Effect.Effect<SupervisionPolicy>;
|
|
286
|
-
readonly task: (budget: Duration.DurationInput) => Effect.Effect<SupervisionPolicy>;
|
|
287
|
-
readonly custom: (policy: SupervisionPolicy) => Effect.Effect<SupervisionPolicy>;
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
export declare interface SupervisionConfig {
|
|
291
|
-
readonly backoffBase: Duration.DurationInput;
|
|
292
|
-
readonly intensity: Intensity;
|
|
293
|
-
readonly cooldown: Duration.DurationInput;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
export declare interface SupervisionPolicy {
|
|
297
|
-
readonly intensity: Intensity;
|
|
298
|
-
readonly backoff: Schedule.Schedule<Duration.Duration>;
|
|
299
|
-
readonly cooldown: Duration.DurationInput;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
export declare interface Supervisor<E, R, L extends LockConfig = LockConfig> {
|
|
303
|
-
readonly [SupervisorTypeId]: SupervisorTypeId;
|
|
304
|
-
readonly name: string;
|
|
305
|
-
readonly strategy: 'one_for_one' | 'one_for_all' | 'rest_for_one';
|
|
306
|
-
readonly children: ReadonlyArray<Worker_2<E, R> | Supervisor<E, R>>;
|
|
307
|
-
readonly supervision: Effect.Effect<SupervisionPolicy>;
|
|
308
|
-
readonly lock: L;
|
|
309
|
-
readonly reporter: ReporterPolicyHooks;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
export declare function supervisor<E, R>(s: Supervisor<E, R, {
|
|
313
|
-
mode: 'none';
|
|
314
|
-
}>): Effect.Effect<SupervisorHealth, never, R | DaemonReporter | Scope.Scope>;
|
|
315
|
-
|
|
316
|
-
export declare function supervisor<E, R>(s: Supervisor<E, R, LockConfig>): Effect.Effect<SupervisorHealth, never, R | LeaderLock | DaemonReporter | Scope.Scope>;
|
|
317
|
-
|
|
318
|
-
export declare const supervisorChildrenGauge: Metric.Metric.Gauge<number>;
|
|
319
|
-
|
|
320
|
-
export declare const supervisorExhaustionsCounter: Metric.Metric.Counter<number>;
|
|
321
|
-
|
|
322
|
-
export declare interface SupervisorHealth {
|
|
323
|
-
readonly name: string;
|
|
324
|
-
readonly ready: Effect.Latch;
|
|
325
|
-
readonly healthy: Effect.Latch;
|
|
326
|
-
readonly paused: Effect.Latch;
|
|
327
|
-
readonly children: ReadonlyArray<DaemonHealth | SupervisorHealth>;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
export declare interface SupervisorOpts<E, R, L extends LockConfig> {
|
|
331
|
-
readonly name: string;
|
|
332
|
-
readonly children: ReadonlyArray<Child<E, R>>;
|
|
333
|
-
readonly supervision: Effect.Effect<SupervisionPolicy>;
|
|
334
|
-
readonly lock: L;
|
|
335
|
-
readonly reporter?: ReporterPolicyHooks;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
export declare const supervisorRestartsCounter: Metric.Metric.Counter<number>;
|
|
339
|
-
|
|
340
|
-
export declare const SupervisorTypeId: unique symbol;
|
|
341
|
-
|
|
342
|
-
export declare type SupervisorTypeId = typeof SupervisorTypeId;
|
|
343
|
-
|
|
344
|
-
export declare class TaskConfig extends TaskConfig_base {}
|
|
345
|
-
|
|
346
|
-
declare const TaskConfig_base: Context.ReferenceClass<TaskConfig, "@systemfsoftware/effect-daemon-spec/TaskConfig", SupervisionConfig>;
|
|
347
|
-
|
|
348
|
-
export declare class TickPolicyConfig extends TickPolicyConfig_base {}
|
|
349
|
-
|
|
350
|
-
declare const TickPolicyConfig_base: Schema.Class<TickPolicyConfig, {
|
|
351
|
-
spanName: Schema.optional<typeof Schema.String>;
|
|
352
|
-
tickTimeout: typeof Schema.DurationFromSelf;
|
|
353
|
-
startLogLevel: Schema.optional<Schema.Literal<["debug", "info"]>>;
|
|
354
|
-
}, Schema.Struct.Encoded<{
|
|
355
|
-
spanName: Schema.optional<typeof Schema.String>;
|
|
356
|
-
tickTimeout: typeof Schema.DurationFromSelf;
|
|
357
|
-
startLogLevel: Schema.optional<Schema.Literal<["debug", "info"]>>;
|
|
358
|
-
}>, never, {
|
|
359
|
-
readonly spanName?: string | undefined;
|
|
360
|
-
} & {
|
|
361
|
-
readonly startLogLevel?: "debug" | "info" | undefined;
|
|
362
|
-
} & {
|
|
363
|
-
readonly tickTimeout: Duration_2;
|
|
364
|
-
}, {}, {}>;
|
|
365
|
-
|
|
366
|
-
export declare interface TickPolicyHooks {
|
|
367
|
-
readonly spanAttributes?: Effect.Effect<Record<string, string | number | boolean>>;
|
|
368
|
-
readonly innerRetry?: Schedule.Schedule<unknown>;
|
|
369
|
-
readonly trackDuration?: Metric.Metric.Histogram<Duration.Duration>;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
export declare class UnboundedIntensity extends UnboundedIntensity_base {
|
|
373
|
-
readonly [IntensityTypeId]: symbol;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
declare const UnboundedIntensity_base: Schema.TaggedClass<UnboundedIntensity, "Unbounded", {
|
|
377
|
-
readonly _tag: Schema.tag<"Unbounded">;
|
|
378
|
-
}>;
|
|
379
|
-
|
|
380
|
-
export declare const withLeaderLock: {
|
|
381
|
-
(options: LeaderLockOptions): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A | void, E | LeaderLockAcquireError, R | LeaderLock>;
|
|
382
|
-
<A, E, R>(self: Effect.Effect<A, E, R>, options: LeaderLockOptions): Effect.Effect<A | void, E | LeaderLockAcquireError, R | LeaderLock>;
|
|
383
|
-
};
|
|
384
|
-
|
|
385
|
-
export declare function worker<E, R>(w: Worker_2<E, R, {
|
|
386
|
-
mode: 'none';
|
|
387
|
-
}>): Effect.Effect<DaemonHealth, never, R | DaemonReporter | Scope.Scope>;
|
|
388
|
-
|
|
389
|
-
export declare function worker<E, R>(w: Worker_2<E, R, LockConfig>): Effect.Effect<DaemonHealth, never, R | LeaderLock | DaemonReporter | Scope.Scope>;
|
|
390
|
-
|
|
391
|
-
declare interface Worker_2<E, R, L extends LockConfig = LockConfig> {
|
|
392
|
-
readonly [WorkerTypeId]: WorkerTypeId;
|
|
393
|
-
readonly name: string;
|
|
394
|
-
readonly loop: LoopShape<E, R>;
|
|
395
|
-
readonly child: typeof ChildPolicyConfig.Type;
|
|
396
|
-
readonly tick: typeof TickPolicyConfig.Type;
|
|
397
|
-
readonly tickHooks: TickPolicyHooks;
|
|
398
|
-
readonly lock: L;
|
|
399
|
-
}
|
|
400
|
-
export { Worker_2 as Worker }
|
|
401
|
-
|
|
402
|
-
export declare class WorkerConfig extends WorkerConfig_base {}
|
|
403
|
-
|
|
404
|
-
declare const WorkerConfig_base: Context.ReferenceClass<WorkerConfig, "@systemfsoftware/effect-daemon-spec/WorkerConfig", SupervisionConfig>;
|
|
405
|
-
|
|
406
|
-
export declare const WorkerTypeId: unique symbol;
|
|
407
|
-
|
|
408
|
-
export declare type WorkerTypeId = typeof WorkerTypeId;
|
|
409
|
-
|
|
410
|
-
export { }
|