@systemfsoftware/effect-daemon-spec 1.0.0 → 3.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 +119 -0
- package/dist/effect-daemon-spec-untrimmed.d.ts +406 -0
- package/dist/effect-daemon-spec.d.ts +33 -8
- package/dist/index.d.ts +104 -80
- package/dist/index.mjs +234 -177
- package/package.json +15 -14
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
import { Cause, Context, Duration, Effect, Latch, Layer, Metric, Option, Schedule, Schema, Scope, Stream } from "effect";
|
|
2
|
-
//#region src/Backoff.d.ts
|
|
3
|
-
declare const cappedBackoff: (base: Duration.Input, cap: Duration.Input) => Schedule.Schedule<Duration.Duration>;
|
|
4
|
-
//#endregion
|
|
5
|
-
//#region src/Brands.d.ts
|
|
6
|
-
declare const WorkerTypeId: unique symbol;
|
|
7
|
-
type WorkerTypeId = typeof WorkerTypeId;
|
|
8
|
-
declare const SupervisorTypeId: unique symbol;
|
|
9
|
-
type SupervisorTypeId = typeof SupervisorTypeId;
|
|
10
|
-
declare const DynamicSpecTypeId: unique symbol;
|
|
11
|
-
type DynamicSpecTypeId = typeof DynamicSpecTypeId;
|
|
12
|
-
//#endregion
|
|
13
2
|
//#region src/DaemonHealth.schema.d.ts
|
|
14
3
|
declare const DynamicLimitExceeded_base: Schema.Class<DynamicLimitExceeded, Schema.TaggedStruct<"DynamicLimitExceeded", {
|
|
15
4
|
readonly limit: Schema.Int;
|
|
@@ -39,6 +28,51 @@ type ChildRef = {
|
|
|
39
28
|
readonly removed: Effect.Effect<void>;
|
|
40
29
|
};
|
|
41
30
|
//#endregion
|
|
31
|
+
//#region src/LeaderLock.schema.d.ts
|
|
32
|
+
declare const LeaderLockNotAcquired_base: Schema.Class<LeaderLockNotAcquired, Schema.TaggedStruct<"LeaderLockNotAcquired", {
|
|
33
|
+
readonly key: Schema.String;
|
|
34
|
+
}>, import("effect/Cause").YieldableError>;
|
|
35
|
+
declare class LeaderLockNotAcquired extends LeaderLockNotAcquired_base {}
|
|
36
|
+
declare const LeaderLockInfraError_base: Schema.Class<LeaderLockInfraError, Schema.TaggedStruct<"LeaderLockInfraError", {
|
|
37
|
+
readonly key: Schema.String;
|
|
38
|
+
readonly cause: Schema.Unknown;
|
|
39
|
+
}>, import("effect/Cause").YieldableError>;
|
|
40
|
+
declare class LeaderLockInfraError extends LeaderLockInfraError_base {}
|
|
41
|
+
type LeaderLockAcquireError = LeaderLockNotAcquired | LeaderLockInfraError;
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/LockPrimitive.schema.d.ts
|
|
44
|
+
declare const LockPrimitiveError_base: Schema.Class<LockPrimitiveError, Schema.TaggedStruct<"LockPrimitiveError", {
|
|
45
|
+
readonly key: Schema.String;
|
|
46
|
+
readonly cause: Schema.Unknown;
|
|
47
|
+
}>, import("effect/Cause").YieldableError>;
|
|
48
|
+
declare class LockPrimitiveError extends LockPrimitiveError_base {}
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/LeaderLockAdapter.d.ts
|
|
51
|
+
interface LeaderLockService {
|
|
52
|
+
readonly withLock: <A, E, R>(key: string, self: Effect.Effect<A, E, R>) => Effect.Effect<Option.Option<A>, E | LeaderLockInfraError, R>;
|
|
53
|
+
}
|
|
54
|
+
declare const LeaderLock_base: Context.ServiceClass<LeaderLock, "@systemfsoftware/effect-daemon-spec/LeaderLockAdapter/LeaderLock", LeaderLockService>;
|
|
55
|
+
declare class LeaderLock extends LeaderLock_base {
|
|
56
|
+
static readonly Noop: Layer.Layer<LeaderLock>;
|
|
57
|
+
}
|
|
58
|
+
interface LockPrimitiveService {
|
|
59
|
+
readonly tryAcquire: (key: string) => Effect.Effect<boolean, LockPrimitiveError, Scope.Scope>;
|
|
60
|
+
}
|
|
61
|
+
declare const LockPrimitive_base: Context.ServiceClass<LockPrimitive, "@systemfsoftware/effect-daemon-spec/LeaderLockAdapter/LockPrimitive", LockPrimitiveService>;
|
|
62
|
+
declare class LockPrimitive extends LockPrimitive_base {}
|
|
63
|
+
declare const LeaderLockFromPrimitive: Layer.Layer<LeaderLock, never, LockPrimitive>;
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/Backoff.d.ts
|
|
66
|
+
declare const cappedBackoff: (base: Duration.Input, cap: Duration.Input) => Schedule.Schedule<Duration.Duration>;
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/Brands.d.ts
|
|
69
|
+
declare const WorkerTypeId: unique symbol;
|
|
70
|
+
type WorkerTypeId = typeof WorkerTypeId;
|
|
71
|
+
declare const SupervisorTypeId: unique symbol;
|
|
72
|
+
type SupervisorTypeId = typeof SupervisorTypeId;
|
|
73
|
+
declare const DynamicSpecTypeId: unique symbol;
|
|
74
|
+
type DynamicSpecTypeId = typeof DynamicSpecTypeId;
|
|
75
|
+
//#endregion
|
|
42
76
|
//#region src/DaemonMetrics.d.ts
|
|
43
77
|
declare const supervisorRestartsCounter: Metric.Counter<number>;
|
|
44
78
|
declare const supervisorExhaustionsCounter: Metric.Counter<number>;
|
|
@@ -97,6 +131,26 @@ declare const DaemonReporter_base: Context.ServiceClass<DaemonReporter, "@system
|
|
|
97
131
|
declare class DaemonReporter extends DaemonReporter_base {}
|
|
98
132
|
declare const Noop: Layer.Layer<DaemonReporter>;
|
|
99
133
|
//#endregion
|
|
134
|
+
//#region src/LoopTags.d.ts
|
|
135
|
+
/**
|
|
136
|
+
* Discriminants on the public Worker loop variants.
|
|
137
|
+
*
|
|
138
|
+
* These tags are part of the published type identity of `poll`, `stream`,
|
|
139
|
+
* and `subscription`. They are not unpublished wiring.
|
|
140
|
+
*/
|
|
141
|
+
declare const PollLoopTag: {
|
|
142
|
+
readonly _tag: 'Poll';
|
|
143
|
+
};
|
|
144
|
+
type PollLoopTag = typeof PollLoopTag;
|
|
145
|
+
declare const StreamLoopTag: {
|
|
146
|
+
readonly _tag: 'Stream';
|
|
147
|
+
};
|
|
148
|
+
type StreamLoopTag = typeof StreamLoopTag;
|
|
149
|
+
declare const SubscriptionLoopTag: {
|
|
150
|
+
readonly _tag: 'Subscription';
|
|
151
|
+
};
|
|
152
|
+
type SubscriptionLoopTag = typeof SubscriptionLoopTag;
|
|
153
|
+
//#endregion
|
|
100
154
|
//#region src/DaemonSpec.schema.d.ts
|
|
101
155
|
type LockConfig = {
|
|
102
156
|
mode: 'none';
|
|
@@ -133,19 +187,16 @@ interface ReporterPolicyHooks {
|
|
|
133
187
|
readonly onRestart?: (cause: Cause.Cause<never>) => Effect.Effect<void>;
|
|
134
188
|
readonly onExhausted?: (cause: Cause.Cause<never>) => Effect.Effect<void>;
|
|
135
189
|
}
|
|
136
|
-
|
|
137
|
-
readonly _tag: 'Poll';
|
|
190
|
+
interface PollLoop<E, R> extends PollLoopTag {
|
|
138
191
|
readonly gate: Effect.Effect<Option.Option<Effect.Effect<void, E, R>>, E, R>;
|
|
139
192
|
readonly interval: Duration.Input;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
readonly _tag: 'Stream';
|
|
193
|
+
}
|
|
194
|
+
interface StreamLoop<E, R> extends StreamLoopTag {
|
|
143
195
|
readonly stream: Stream.Stream<unknown, E, R>;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
readonly _tag: 'Subscription';
|
|
196
|
+
}
|
|
197
|
+
interface SubscriptionLoop<E, R> extends SubscriptionLoopTag {
|
|
147
198
|
readonly acquire: Effect.Effect<void, E, R>;
|
|
148
|
-
}
|
|
199
|
+
}
|
|
149
200
|
type LoopShape<E, R> = PollLoop<E, R> | StreamLoop<E, R> | SubscriptionLoop<E, R>;
|
|
150
201
|
interface Worker<E, R, L extends LockConfig = LockConfig> {
|
|
151
202
|
readonly [WorkerTypeId]: WorkerTypeId;
|
|
@@ -190,61 +241,53 @@ interface SupervisorOpts<E, R, L extends LockConfig> {
|
|
|
190
241
|
readonly reporter?: ReporterPolicyHooks;
|
|
191
242
|
}
|
|
192
243
|
//#endregion
|
|
193
|
-
//#region src/
|
|
194
|
-
declare const
|
|
195
|
-
readonly key: Schema.String;
|
|
196
|
-
}>, import("effect/Cause").YieldableError>;
|
|
197
|
-
declare class LeaderLockNotAcquired extends LeaderLockNotAcquired_base {}
|
|
198
|
-
declare const LeaderLockInfraError_base: Schema.Class<LeaderLockInfraError, Schema.TaggedStruct<"LeaderLockInfraError", {
|
|
199
|
-
readonly key: Schema.String;
|
|
200
|
-
readonly cause: Schema.Unknown;
|
|
201
|
-
}>, import("effect/Cause").YieldableError>;
|
|
202
|
-
declare class LeaderLockInfraError extends LeaderLockInfraError_base {}
|
|
203
|
-
type LeaderLockAcquireError = LeaderLockNotAcquired | LeaderLockInfraError;
|
|
204
|
-
//#endregion
|
|
205
|
-
//#region src/LockPrimitive.schema.d.ts
|
|
206
|
-
declare const LockPrimitiveError_base: Schema.Class<LockPrimitiveError, Schema.TaggedStruct<"LockPrimitiveError", {
|
|
207
|
-
readonly key: Schema.String;
|
|
208
|
-
readonly cause: Schema.Unknown;
|
|
209
|
-
}>, import("effect/Cause").YieldableError>;
|
|
210
|
-
declare class LockPrimitiveError extends LockPrimitiveError_base {}
|
|
244
|
+
//#region src/RunDynamic.d.ts
|
|
245
|
+
declare const dynamic$1: <E, R, Args>(spec: DynamicSpec<E, R, Args>) => Effect.Effect<DynamicHandle<Args, R | LeaderLock | DaemonReporter | Scope.Scope>, never, R | LeaderLock | DaemonReporter | Scope.Scope>;
|
|
211
246
|
//#endregion
|
|
212
|
-
//#region src/
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
interface LockPrimitiveService {
|
|
221
|
-
readonly tryAcquire: (key: string) => Effect.Effect<boolean, LockPrimitiveError, Scope.Scope>;
|
|
222
|
-
}
|
|
223
|
-
declare const LockPrimitive_base: Context.ServiceClass<LockPrimitive, "@systemfsoftware/effect-daemon-spec/LeaderLockAdapter/LockPrimitive", LockPrimitiveService>;
|
|
224
|
-
declare class LockPrimitive extends LockPrimitive_base {}
|
|
225
|
-
declare const LeaderLockFromPrimitive: Layer.Layer<LeaderLock, never, LockPrimitive>;
|
|
247
|
+
//#region src/RunSupervisor.d.ts
|
|
248
|
+
/**
|
|
249
|
+
* The supervisor: acquires the `DaemonReporter` and — unless the lock mode is none —
|
|
250
|
+
* the `LeaderLock` capabilities at the composition root, then hands them down to the
|
|
251
|
+
* supervisor body via the lock binding. The body itself only ever sees the service
|
|
252
|
+
* values.
|
|
253
|
+
*/
|
|
254
|
+
declare const supervisor: <E, R>(s: Supervisor<E, R, LockConfig>) => Effect.Effect<SupervisorHealth, never, R | DaemonReporter | LeaderLock | Scope.Scope>;
|
|
226
255
|
//#endregion
|
|
227
|
-
//#region src/
|
|
228
|
-
|
|
256
|
+
//#region src/RunWorker.d.ts
|
|
257
|
+
/**
|
|
258
|
+
* Boots a worker. The leader-lock capability is acquired here, at the composition
|
|
259
|
+
* root, and handed down as part of the lock binding: the executor behind this
|
|
260
|
+
* entry point never sees the tag. A worker whose lock is `{ mode: 'none' }`
|
|
261
|
+
* takes no lock at all.
|
|
262
|
+
*/
|
|
263
|
+
declare const worker: {
|
|
264
|
+
<E, R>(w: Worker<E, R, {
|
|
265
|
+
mode: 'none';
|
|
266
|
+
}>): Effect.Effect<DaemonHealth, never, R | Scope.Scope>;
|
|
267
|
+
<E, R>(w: Worker<E, R, LockConfig>): Effect.Effect<DaemonHealth, never, R | LeaderLock | Scope.Scope>;
|
|
268
|
+
};
|
|
229
269
|
//#endregion
|
|
230
|
-
//#region src/
|
|
270
|
+
//#region src/WithLeaderLock.d.ts
|
|
231
271
|
interface LeaderLockOptions {
|
|
232
272
|
readonly key: string;
|
|
233
273
|
readonly mode: 'required' | 'optional';
|
|
234
274
|
readonly acquireRetryBackoff?: Schedule.Schedule<Duration.Duration>;
|
|
235
275
|
}
|
|
276
|
+
/**
|
|
277
|
+
* Runs `self` while holding the named leader lock.
|
|
278
|
+
*/
|
|
236
279
|
declare function withLeaderLock<A, E, R>(self: Effect.Effect<A, E, R>, options: LeaderLockOptions, lock: LeaderLock['Service']): Effect.Effect<A | void, E | LeaderLockAcquireError, R>;
|
|
237
280
|
//#endregion
|
|
238
281
|
//#region src/SupervisionCustom.d.ts
|
|
239
282
|
declare const custom: <P>(policy: P) => Effect.Effect<P>;
|
|
240
283
|
//#endregion
|
|
241
|
-
//#region src/
|
|
284
|
+
//#region src/SupervisionLeader.d.ts
|
|
242
285
|
declare const LeaderConfig: Context.Reference<SupervisionConfig>;
|
|
243
286
|
//#endregion
|
|
244
|
-
//#region src/
|
|
287
|
+
//#region src/SupervisionTask.d.ts
|
|
245
288
|
declare const TaskConfig: Context.Reference<SupervisionConfig>;
|
|
246
289
|
//#endregion
|
|
247
|
-
//#region src/
|
|
290
|
+
//#region src/SupervisionWorker.d.ts
|
|
248
291
|
declare const WorkerConfig: Context.Reference<SupervisionConfig>;
|
|
249
292
|
//#endregion
|
|
250
293
|
//#region src/mod.d.ts
|
|
@@ -260,31 +303,12 @@ declare const Daemon: {
|
|
|
260
303
|
readonly stream: typeof stream;
|
|
261
304
|
readonly subscription: typeof subscription;
|
|
262
305
|
};
|
|
263
|
-
/**
|
|
264
|
-
* Boots a worker. The leader-lock capability is acquired here, at the composition
|
|
265
|
-
* root, and handed down as part of the lock binding: the executor behind this
|
|
266
|
-
* entry point never sees the tag. A worker whose lock is `{ mode: 'none' }`
|
|
267
|
-
* takes no lock at all.
|
|
268
|
-
*/
|
|
269
|
-
declare const worker: {
|
|
270
|
-
<E, R>(w: Worker<E, R, {
|
|
271
|
-
mode: 'none';
|
|
272
|
-
}>): Effect.Effect<DaemonHealth, never, R | Scope.Scope>;
|
|
273
|
-
<E, R>(w: Worker<E, R, LockConfig>): Effect.Effect<DaemonHealth, never, R | LeaderLock | Scope.Scope>;
|
|
274
|
-
};
|
|
275
|
-
/**
|
|
276
|
-
* The supervisor: acquires the `DaemonReporter` and — unless the lock mode is none —
|
|
277
|
-
* the `LeaderLock` capabilities at the composition root, then hands them down to the
|
|
278
|
-
* supervisor body via the lock binding. The body itself only ever sees the service
|
|
279
|
-
* values.
|
|
280
|
-
*/
|
|
281
|
-
declare const supervisor: <E, R>(s: Supervisor<E, R, LockConfig>) => Effect.Effect<SupervisorHealth, never, R | DaemonReporter | LeaderLock | Scope.Scope>;
|
|
282
306
|
declare const run: {
|
|
283
307
|
readonly worker: {
|
|
284
308
|
<E, R>(w: Worker<E, R, {
|
|
285
309
|
mode: 'none';
|
|
286
|
-
}>): Effect.Effect<DaemonHealth, never, R | Scope.Scope>;
|
|
287
|
-
<E, R>(w: Worker<E, R, LockConfig>): Effect.Effect<DaemonHealth, never, R | LeaderLock | Scope.Scope>;
|
|
310
|
+
}>): Effect.Effect<DaemonHealth, never, R | import("effect/Scope").Scope>;
|
|
311
|
+
<E, R>(w: Worker<E, R, LockConfig>): Effect.Effect<DaemonHealth, never, R | LeaderLock | import("effect/Scope").Scope>;
|
|
288
312
|
};
|
|
289
313
|
readonly supervisor: typeof supervisor;
|
|
290
314
|
readonly dynamic: typeof dynamic$1;
|
|
@@ -307,4 +331,4 @@ declare const oneForAll: <E, R, L extends LockConfig = LockConfig>(opts: Supervi
|
|
|
307
331
|
declare const oneForOne: <E, R, L extends LockConfig = LockConfig>(opts: SupervisorOpts<E, R, L>) => Supervisor<E, R, L>;
|
|
308
332
|
declare const restForOne: <E, R, L extends LockConfig = LockConfig>(opts: SupervisorOpts<E, R, L>) => Supervisor<E, R, L>;
|
|
309
333
|
//#endregion
|
|
310
|
-
export { BoundedIntensity, Child, ChildPolicyConfig, ChildRef, CommonOpts, Daemon, DaemonHealth, DaemonReporter, DaemonReporterService, DynamicHandle, DynamicLimitExceeded, DynamicSpec, DynamicSpecTypeId, Intensity, IntensityConfig, LeaderConfig, LeaderLock, LeaderLockAcquireError, LeaderLockFromPrimitive, LeaderLockInfraError, LeaderLockNotAcquired, type LeaderLockOptions, LeaderLockService, LockConfig, LockPolicyConfig, LockPrimitive, LockPrimitiveError, LockPrimitiveService, LoopShape, MaxChildren, Noop, PollLoop, PollOpts, ReporterPolicyHooks, StreamLoop, SubscriptionLoop, Supervision, SupervisionConfig, SupervisionPolicy, Supervisor, SupervisorHealth, SupervisorOpts, SupervisorTypeId, TaskConfig, TickPolicyConfig, TickPolicyHooks, UnboundedIntensity, Worker, WorkerConfig, WorkerTypeId, cappedBackoff, dynamic, healthStateGauge, leader, oneForAll, oneForOne, poll, restForOne, run, stream, subscription, supervision, supervisor, supervisorChildrenGauge, supervisorExhaustionsCounter, supervisorRestartsCounter, task, withLeaderLock, worker };
|
|
334
|
+
export { BoundedIntensity, Child, ChildPolicyConfig, ChildRef, CommonOpts, Daemon, DaemonHealth, DaemonReporter, DaemonReporterService, DynamicHandle, DynamicLimitExceeded, DynamicSpec, DynamicSpecTypeId, Intensity, IntensityConfig, LeaderConfig, LeaderLock, LeaderLockAcquireError, LeaderLockFromPrimitive, LeaderLockInfraError, LeaderLockNotAcquired, type LeaderLockOptions, LeaderLockService, LockConfig, LockPolicyConfig, LockPrimitive, LockPrimitiveError, LockPrimitiveService, LoopShape, MaxChildren, Noop, PollLoop, PollLoopTag, PollOpts, ReporterPolicyHooks, StreamLoop, StreamLoopTag, SubscriptionLoop, SubscriptionLoopTag, Supervision, SupervisionConfig, SupervisionPolicy, Supervisor, SupervisorHealth, SupervisorOpts, SupervisorTypeId, TaskConfig, TickPolicyConfig, TickPolicyHooks, UnboundedIntensity, Worker, WorkerConfig, WorkerTypeId, cappedBackoff, dynamic, healthStateGauge, leader, oneForAll, oneForOne, poll, restForOne, run, stream, subscription, supervision, supervisor, supervisorChildrenGauge, supervisorExhaustionsCounter, supervisorRestartsCounter, task, withLeaderLock, worker };
|