@systemfsoftware/effect-daemon-spec 0.5.0 → 0.7.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.
@@ -9,6 +9,7 @@ import { Option as Option_2 } from 'effect';
9
9
  import { Schedule } from 'effect';
10
10
  import { Schema } from 'effect';
11
11
  import { Scope } from 'effect';
12
+ import { Scope as Scope_2 } from 'effect/Scope';
12
13
  import { Stream } from 'effect';
13
14
 
14
15
  export declare class BoundedIntensity extends BoundedIntensity_base {
@@ -79,11 +80,9 @@ export declare interface DaemonHealth {
79
80
  readonly paused: Effect.Latch;
80
81
  }
81
82
 
82
- export declare class DaemonReporter extends DaemonReporter_base {
83
- static readonly Noop: Layer.Layer<DaemonReporter>;
84
- }
83
+ export declare class DaemonReporter extends DaemonReporter_base {}
85
84
 
86
- declare const DaemonReporter_base: Context.TagClass<DaemonReporter, "@systemfsoftware/effect-daemon-spec/daemon-reporter/DaemonReporter", DaemonReporterService>;
85
+ declare const DaemonReporter_base: Context.TagClass<DaemonReporter, "@systemfsoftware/effect-daemon-spec/daemon-reporter.adapter/DaemonReporter", DaemonReporterService>;
87
86
 
88
87
  export declare interface DaemonReporterService {
89
88
  readonly onRestart: (name: string, cause: Cause.Cause<never>) => Effect.Effect<void>;
@@ -135,13 +134,11 @@ export declare const IntensityConfig: Schema.Struct<{
135
134
 
136
135
  export declare type IntensityConfig = typeof IntensityConfig.Type;
137
136
 
138
- export declare const IntensityTypeId: unique symbol;
139
-
140
- export declare type IntensityTypeId = typeof IntensityTypeId;
137
+ declare const IntensityTypeId: unique symbol;
141
138
 
142
- export declare const isSupervisor: <E, R>(x: Child<E, R>) => x is Supervisor<E, R>;
139
+ declare type IntensityTypeId = typeof IntensityTypeId;
143
140
 
144
- export declare const isWorker: <E, R>(x: Child<E, R>) => x is Worker_2<E, R>;
141
+ export declare const leader: (cap: Duration.DurationInput) => Effect.Effect<SupervisionPolicy>;
145
142
 
146
143
  export declare class LeaderConfig extends LeaderConfig_base {}
147
144
 
@@ -151,7 +148,7 @@ export declare class LeaderLock extends LeaderLock_base {
151
148
  static readonly Noop: Layer.Layer<LeaderLock>;
152
149
  }
153
150
 
154
- declare const LeaderLock_base: Context.TagClass<LeaderLock, "@systemfsoftware/effect-daemon-spec/leader-lock/LeaderLock", LeaderLockService>;
151
+ declare const LeaderLock_base: Context.TagClass<LeaderLock, "@systemfsoftware/effect-daemon-spec/leader-lock.adapter/LeaderLock", LeaderLockService>;
155
152
 
156
153
  export declare type LeaderLockAcquireError = LeaderLockNotAcquired | LeaderLockInfraError;
157
154
 
@@ -177,6 +174,7 @@ declare const LeaderLockNotAcquired_base: Schema.TaggedErrorClass<LeaderLockNotA
177
174
  export declare interface LeaderLockOptions {
178
175
  readonly key: string;
179
176
  readonly mode: 'required' | 'optional';
177
+ readonly acquireRetryBackoff?: Schedule.Schedule<Duration.Duration>;
180
178
  }
181
179
 
182
180
  export declare interface LeaderLockService {
@@ -210,7 +208,7 @@ declare const LockPolicyConfig_base: Schema.Class<LockPolicyConfig, {
210
208
 
211
209
  export declare class LockPrimitive extends LockPrimitive_base {}
212
210
 
213
- declare const LockPrimitive_base: Context.TagClass<LockPrimitive, "@systemfsoftware/effect-daemon-spec/lock-primitive/LockPrimitive", LockPrimitiveService>;
211
+ declare const LockPrimitive_base: Context.TagClass<LockPrimitive, "@systemfsoftware/effect-daemon-spec/leader-lock.adapter/LockPrimitive", LockPrimitiveService>;
214
212
 
215
213
  export declare class LockPrimitiveError extends LockPrimitiveError_base {}
216
214
 
@@ -227,6 +225,8 @@ export declare interface LockPrimitiveService {
227
225
 
228
226
  export declare type LoopShape<E, R> = PollLoop<E, R> | StreamLoop<E, R> | SubscriptionLoop<E, R>;
229
227
 
228
+ export declare const Noop: Layer.Layer<DaemonReporter>;
229
+
230
230
  export declare const oneForAll: <E, R, L extends LockConfig = LockConfig>(opts: SupervisorOpts<E, R, L>) => Supervisor<E, R, L>;
231
231
 
232
232
  export declare const oneForOne: <E, R, L extends LockConfig = LockConfig>(opts: SupervisorOpts<E, R, L>) => Supervisor<E, R, L>;
@@ -257,9 +257,14 @@ export declare interface ReporterPolicyHooks {
257
257
  export declare const restForOne: <E, R, L extends LockConfig = LockConfig>(opts: SupervisorOpts<E, R, L>) => Supervisor<E, R, L>;
258
258
 
259
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>;
260
+ readonly worker: {
261
+ <E, R>(w: Worker_2<E, R, {
262
+ mode: "none";
263
+ }>): Effect.Effect<DaemonHealth, never, R | Scope_2>;
264
+ <E, R>(w: Worker_2<E, R, LockConfig>): Effect.Effect<DaemonHealth, never, R | WithLeaderLockExecutorDeps | Scope_2>;
265
+ };
266
+ readonly supervisor: <E, R>(s: Supervisor<E, R, LockConfig>) => Effect.Effect<SupervisorHealth, never, R | SupervisorBodyExecutorDeps | WithLeaderLockExecutorDeps | Scope_2>;
267
+ readonly dynamic: <E, R, Args>(spec: DynamicSpec<E, R, Args>) => Effect.Effect<DynamicHandle<Args, R | WithLeaderLockExecutorDeps | SupervisorBodyExecutorDeps | Scope_2>, never, R | WithLeaderLockExecutorDeps | SupervisorBodyExecutorDeps | Scope_2>;
263
268
  };
264
269
 
265
270
  export declare const stream: <A, E, R, L extends LockConfig>(opts: CommonOpts<L> & {
@@ -284,9 +289,11 @@ export declare const Supervision: {
284
289
  readonly leader: (cap: Duration.DurationInput) => Effect.Effect<SupervisionPolicy>;
285
290
  readonly worker: (cap: Duration.DurationInput) => Effect.Effect<SupervisionPolicy>;
286
291
  readonly task: (budget: Duration.DurationInput) => Effect.Effect<SupervisionPolicy>;
287
- readonly custom: (policy: SupervisionPolicy) => Effect.Effect<SupervisionPolicy>;
292
+ readonly custom: <P>(policy: P) => Effect.Effect<P>;
288
293
  };
289
294
 
295
+ export declare const supervision: (cap: Duration.DurationInput) => Effect.Effect<SupervisionPolicy>;
296
+
290
297
  export declare interface SupervisionConfig {
291
298
  readonly backoffBase: Duration.DurationInput;
292
299
  readonly intensity: Intensity;
@@ -309,11 +316,16 @@ export declare interface Supervisor<E, R, L extends LockConfig = LockConfig> {
309
316
  readonly reporter: ReporterPolicyHooks;
310
317
  }
311
318
 
312
- export declare function supervisor<E, R>(s: Supervisor<E, R, {
313
- mode: 'none';
314
- }>): Effect.Effect<SupervisorHealth, never, R | DaemonReporter | Scope.Scope>;
319
+ export declare const supervisor: <E, R>(s: Supervisor<E, R, LockConfig>) => Effect.Effect<SupervisorHealth, never, R | SupervisorBodyExecutorDeps | WithLeaderLockExecutorDeps | Scope.Scope>;
320
+
321
+ export declare class SupervisorBodyExecutorDeps extends SupervisorBodyExecutorDeps_base {}
322
+
323
+ declare const SupervisorBodyExecutorDeps_base: Context.TagClass<SupervisorBodyExecutorDeps, "SupervisorBodyExecutorDeps", {
324
+ readonly onRestart: DaemonReporter["Type"]["onRestart"];
325
+ readonly onExhausted: DaemonReporter["Type"]["onExhausted"];
326
+ }>;
315
327
 
316
- export declare function supervisor<E, R>(s: Supervisor<E, R, LockConfig>): Effect.Effect<SupervisorHealth, never, R | LeaderLock | DaemonReporter | Scope.Scope>;
328
+ export declare const SupervisorBodyExecutorLive: Layer.Layer<SupervisorBodyExecutorDeps, never, DaemonReporter>;
317
329
 
318
330
  export declare const supervisorChildrenGauge: Metric.Metric.Gauge<number>;
319
331
 
@@ -341,6 +353,8 @@ export declare const SupervisorTypeId: unique symbol;
341
353
 
342
354
  export declare type SupervisorTypeId = typeof SupervisorTypeId;
343
355
 
356
+ export declare const task: (budget: Duration.DurationInput) => Effect.Effect<SupervisionPolicy>;
357
+
344
358
  export declare class TaskConfig extends TaskConfig_base {}
345
359
 
346
360
  declare const TaskConfig_base: Context.ReferenceClass<TaskConfig, "@systemfsoftware/effect-daemon-spec/TaskConfig", SupervisionConfig>;
@@ -377,16 +391,22 @@ declare const UnboundedIntensity_base: Schema.TaggedClass<UnboundedIntensity, "U
377
391
  readonly _tag: Schema.tag<"Unbounded">;
378
392
  }>;
379
393
 
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
- };
394
+ export declare function withLeaderLock<A, E, R>(self: Effect.Effect<A, E, R>, options: LeaderLockOptions): Effect.Effect<A | void, E | LeaderLockAcquireError, R | WithLeaderLockExecutorDeps>;
384
395
 
385
- export declare function worker<E, R>(w: Worker_2<E, R, {
386
- mode: 'none';
387
- }>): Effect.Effect<DaemonHealth, never, R | DaemonReporter | Scope.Scope>;
396
+ export declare class WithLeaderLockExecutorDeps extends WithLeaderLockExecutorDeps_base {}
388
397
 
389
- export declare function worker<E, R>(w: Worker_2<E, R, LockConfig>): Effect.Effect<DaemonHealth, never, R | LeaderLock | DaemonReporter | Scope.Scope>;
398
+ declare const WithLeaderLockExecutorDeps_base: Context.TagClass<WithLeaderLockExecutorDeps, "WithLeaderLockExecutorDeps", {
399
+ readonly withLock: LeaderLock["Type"]["withLock"];
400
+ }>;
401
+
402
+ export declare const WithLeaderLockExecutorLive: Layer.Layer<WithLeaderLockExecutorDeps, never, LeaderLock>;
403
+
404
+ export declare const worker: {
405
+ <E, R>(w: Worker_2<E, R, {
406
+ mode: 'none';
407
+ }>): Effect.Effect<DaemonHealth, never, R | Scope.Scope>;
408
+ <E, R>(w: Worker_2<E, R, LockConfig>): Effect.Effect<DaemonHealth, never, R | WithLeaderLockExecutorDeps | Scope.Scope>;
409
+ };
390
410
 
391
411
  declare interface Worker_2<E, R, L extends LockConfig = LockConfig> {
392
412
  readonly [WorkerTypeId]: WorkerTypeId;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,4 @@
1
1
  import { Cause, Context, Duration, Effect, Layer, Metric, Option, Schedule, Schema, Scope, Stream } from "effect";
2
- //#region src/backoff.d.ts
3
- declare const cappedBackoff: (base: Duration.DurationInput, cap: Duration.DurationInput) => Schedule.Schedule<Duration.Duration>;
4
- //#endregion
5
2
  //#region src/daemon-health.schema.d.ts
6
3
  declare const DynamicLimitExceeded_base: Schema.TaggedErrorClass<DynamicLimitExceeded, "DynamicLimitExceeded", {
7
4
  readonly _tag: Schema.tag<"DynamicLimitExceeded">;
@@ -9,8 +6,6 @@ declare const DynamicLimitExceeded_base: Schema.TaggedErrorClass<DynamicLimitExc
9
6
  limit: Schema.filter<typeof Schema.Int>;
10
7
  }>;
11
8
  declare class DynamicLimitExceeded extends DynamicLimitExceeded_base {}
12
- //#endregion
13
- //#region src/daemon-health.d.ts
14
9
  interface DaemonHealth {
15
10
  readonly name: string;
16
11
  readonly ready: Effect.Latch;
@@ -35,7 +30,18 @@ type ChildRef = {
35
30
  readonly removed: Effect.Effect<void>;
36
31
  };
37
32
  //#endregion
38
- //#region src/daemon-metrics.d.ts
33
+ //#region src/backoff.kernel.d.ts
34
+ declare const cappedBackoff: (base: Duration.DurationInput, cap: Duration.DurationInput) => Schedule.Schedule<Duration.Duration>;
35
+ //#endregion
36
+ //#region src/brands.kernel.d.ts
37
+ declare const WorkerTypeId: unique symbol;
38
+ type WorkerTypeId = typeof WorkerTypeId;
39
+ declare const SupervisorTypeId: unique symbol;
40
+ type SupervisorTypeId = typeof SupervisorTypeId;
41
+ declare const DynamicSpecTypeId: unique symbol;
42
+ type DynamicSpecTypeId = typeof DynamicSpecTypeId;
43
+ //#endregion
44
+ //#region src/daemon-metrics.kernel.d.ts
39
45
  declare const supervisorRestartsCounter: Metric.Metric.Counter<number>;
40
46
  declare const supervisorExhaustionsCounter: Metric.Metric.Counter<number>;
41
47
  declare const supervisorChildrenGauge: Metric.Metric.Gauge<number>;
@@ -116,47 +122,16 @@ declare const TickPolicyConfig_base: Schema.Class<TickPolicyConfig, {
116
122
  }, {}, {}>;
117
123
  declare class TickPolicyConfig extends TickPolicyConfig_base {}
118
124
  //#endregion
119
- //#region src/daemon-reporter.d.ts
125
+ //#region src/daemon-reporter.adapter.d.ts
120
126
  interface DaemonReporterService {
121
127
  readonly onRestart: (name: string, cause: Cause.Cause<never>) => Effect.Effect<void>;
122
128
  readonly onExhausted: (name: string, cause: Cause.Cause<never>) => Effect.Effect<void>;
123
129
  }
124
- declare const DaemonReporter_base: Context.TagClass<DaemonReporter, "@systemfsoftware/effect-daemon-spec/daemon-reporter/DaemonReporter", DaemonReporterService>;
125
- declare class DaemonReporter extends DaemonReporter_base {
126
- static readonly Noop: Layer.Layer<DaemonReporter>;
127
- }
128
- //#endregion
129
- //#region src/supervision-preset.d.ts
130
- interface SupervisionPolicy {
131
- readonly intensity: Intensity;
132
- readonly backoff: Schedule.Schedule<Duration.Duration>;
133
- readonly cooldown: Duration.DurationInput;
134
- }
135
- interface SupervisionConfig {
136
- readonly backoffBase: Duration.DurationInput;
137
- readonly intensity: Intensity;
138
- readonly cooldown: Duration.DurationInput;
139
- }
140
- declare const LeaderConfig_base: Context.ReferenceClass<LeaderConfig, "@systemfsoftware/effect-daemon-spec/LeaderConfig", SupervisionConfig>;
141
- declare class LeaderConfig extends LeaderConfig_base {}
142
- declare const WorkerConfig_base: Context.ReferenceClass<WorkerConfig, "@systemfsoftware/effect-daemon-spec/WorkerConfig", SupervisionConfig>;
143
- declare class WorkerConfig extends WorkerConfig_base {}
144
- declare const TaskConfig_base: Context.ReferenceClass<TaskConfig, "@systemfsoftware/effect-daemon-spec/TaskConfig", SupervisionConfig>;
145
- declare class TaskConfig extends TaskConfig_base {}
146
- declare const Supervision: {
147
- readonly leader: (cap: Duration.DurationInput) => Effect.Effect<SupervisionPolicy>;
148
- readonly worker: (cap: Duration.DurationInput) => Effect.Effect<SupervisionPolicy>;
149
- readonly task: (budget: Duration.DurationInput) => Effect.Effect<SupervisionPolicy>;
150
- readonly custom: (policy: SupervisionPolicy) => Effect.Effect<SupervisionPolicy>;
151
- };
130
+ declare const DaemonReporter_base: Context.TagClass<DaemonReporter, "@systemfsoftware/effect-daemon-spec/daemon-reporter.adapter/DaemonReporter", DaemonReporterService>;
131
+ declare class DaemonReporter extends DaemonReporter_base {}
132
+ declare const Noop: Layer.Layer<DaemonReporter>;
152
133
  //#endregion
153
- //#region src/daemon-spec.d.ts
154
- declare const WorkerTypeId: unique symbol;
155
- type WorkerTypeId = typeof WorkerTypeId;
156
- declare const SupervisorTypeId: unique symbol;
157
- type SupervisorTypeId = typeof SupervisorTypeId;
158
- declare const DynamicSpecTypeId: unique symbol;
159
- type DynamicSpecTypeId = typeof DynamicSpecTypeId;
134
+ //#region src/daemon-spec.schema.d.ts
160
135
  type LockConfig = {
161
136
  mode: 'none';
162
137
  } | {
@@ -167,6 +142,22 @@ type LockConfig = {
167
142
  key: string;
168
143
  acquireRetryBackoff: Schedule.Schedule<Duration.Duration>;
169
144
  };
145
+ interface CommonOpts<L extends LockConfig> {
146
+ readonly name: string;
147
+ readonly child?: typeof ChildPolicyConfig.Type;
148
+ readonly tick: typeof TickPolicyConfig.Type;
149
+ readonly tickHooks?: TickPolicyHooks;
150
+ readonly lock: L;
151
+ }
152
+ type PollOpts<A, E, R, L extends LockConfig> = CommonOpts<L> & {
153
+ readonly interval: Duration.DurationInput;
154
+ } & ({
155
+ readonly prereq?: undefined;
156
+ readonly work: Effect.Effect<A, E, R>;
157
+ } | {
158
+ readonly prereq: Effect.Effect<Option.Option<A>, E, R>;
159
+ readonly work: (data: A) => Effect.Effect<void, E, R>;
160
+ });
170
161
  interface TickPolicyHooks {
171
162
  readonly spanAttributes?: Effect.Effect<Record<string, string | number | boolean>>;
172
163
  readonly innerRetry?: Schedule.Schedule<unknown>;
@@ -215,42 +206,23 @@ interface DynamicSpec<E, R, Args> {
215
206
  readonly maxChildren: number;
216
207
  }
217
208
  type Child<E, R> = Worker<E, R> | Supervisor<E, R>;
218
- declare const isWorker: <E, R>(x: Child<E, R>) => x is Worker<E, R>;
219
- declare const isSupervisor: <E, R>(x: Child<E, R>) => x is Supervisor<E, R>;
220
- //#endregion
221
- //#region src/daemon.d.ts
222
- interface CommonOpts<L extends LockConfig> {
209
+ interface SupervisionPolicy {
210
+ readonly intensity: Intensity;
211
+ readonly backoff: Schedule.Schedule<Duration.Duration>;
212
+ readonly cooldown: Duration.DurationInput;
213
+ }
214
+ interface SupervisionConfig {
215
+ readonly backoffBase: Duration.DurationInput;
216
+ readonly intensity: Intensity;
217
+ readonly cooldown: Duration.DurationInput;
218
+ }
219
+ interface SupervisorOpts<E, R, L extends LockConfig> {
223
220
  readonly name: string;
224
- readonly child?: typeof ChildPolicyConfig.Type;
225
- readonly tick: typeof TickPolicyConfig.Type;
226
- readonly tickHooks?: TickPolicyHooks;
221
+ readonly children: ReadonlyArray<Child<E, R>>;
222
+ readonly supervision: Effect.Effect<SupervisionPolicy>;
227
223
  readonly lock: L;
224
+ readonly reporter?: ReporterPolicyHooks;
228
225
  }
229
- type PollOpts<A, E, R, L extends LockConfig> = CommonOpts<L> & {
230
- readonly interval: Duration.DurationInput;
231
- } & ({
232
- readonly prereq?: undefined;
233
- readonly work: Effect.Effect<A, E, R>;
234
- } | {
235
- readonly prereq: Effect.Effect<Option.Option<A>, E, R>;
236
- readonly work: (data: A) => Effect.Effect<void, E, R>;
237
- });
238
- declare const poll: <A, E, R, L extends LockConfig>(opts: PollOpts<A, E, R, L>) => Worker<E, R, L>;
239
- declare const stream: <A, E, R, L extends LockConfig>(opts: CommonOpts<L> & {
240
- readonly stream: Stream.Stream<A, E, R>;
241
- }) => Worker<E, R, L>;
242
- declare const subscription: <A, E, R, L extends LockConfig>(opts: CommonOpts<L> & {
243
- readonly acquire: Effect.Effect<A, E, R>;
244
- }) => Worker<E, R, L>;
245
- declare const Daemon: {
246
- readonly poll: <A, E, R, L extends LockConfig>(opts: PollOpts<A, E, R, L>) => Worker<E, R, L>;
247
- readonly stream: <A, E, R, L extends LockConfig>(opts: CommonOpts<L> & {
248
- readonly stream: Stream.Stream<A, E, R>;
249
- }) => Worker<E, R, L>;
250
- readonly subscription: <A, E, R, L extends LockConfig>(opts: CommonOpts<L> & {
251
- readonly acquire: Effect.Effect<A, E, R>;
252
- }) => Worker<E, R, L>;
253
- };
254
226
  //#endregion
255
227
  //#region src/leader-lock.schema.d.ts
256
228
  declare const LeaderLockNotAcquired_base: Schema.TaggedErrorClass<LeaderLockNotAcquired, "LeaderLockNotAcquired", {
@@ -268,23 +240,6 @@ declare const LeaderLockInfraError_base: Schema.TaggedErrorClass<LeaderLockInfra
268
240
  declare class LeaderLockInfraError extends LeaderLockInfraError_base {}
269
241
  type LeaderLockAcquireError = LeaderLockNotAcquired | LeaderLockInfraError;
270
242
  //#endregion
271
- //#region src/leader-lock.d.ts
272
- interface LeaderLockService {
273
- readonly withLock: <A, E, R>(key: string, self: Effect.Effect<A, E, R>) => Effect.Effect<Option.Option<A>, E | LeaderLockInfraError, R>;
274
- }
275
- declare const LeaderLock_base: Context.TagClass<LeaderLock, "@systemfsoftware/effect-daemon-spec/leader-lock/LeaderLock", LeaderLockService>;
276
- declare class LeaderLock extends LeaderLock_base {
277
- static readonly Noop: Layer.Layer<LeaderLock>;
278
- }
279
- interface LeaderLockOptions {
280
- readonly key: string;
281
- readonly mode: 'required' | 'optional';
282
- }
283
- declare const withLeaderLock: {
284
- (options: LeaderLockOptions): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A | void, E | LeaderLockAcquireError, R | LeaderLock>;
285
- <A, E, R>(self: Effect.Effect<A, E, R>, options: LeaderLockOptions): Effect.Effect<A | void, E | LeaderLockAcquireError, R | LeaderLock>;
286
- };
287
- //#endregion
288
243
  //#region src/lock-primitive.schema.d.ts
289
244
  declare const LockPrimitiveError_base: Schema.TaggedErrorClass<LockPrimitiveError, "LockPrimitiveError", {
290
245
  readonly _tag: Schema.tag<"LockPrimitiveError">;
@@ -294,44 +249,106 @@ declare const LockPrimitiveError_base: Schema.TaggedErrorClass<LockPrimitiveErro
294
249
  }>;
295
250
  declare class LockPrimitiveError extends LockPrimitiveError_base {}
296
251
  //#endregion
297
- //#region src/lock-primitive.d.ts
252
+ //#region src/leader-lock.adapter.d.ts
253
+ interface LeaderLockService {
254
+ readonly withLock: <A, E, R>(key: string, self: Effect.Effect<A, E, R>) => Effect.Effect<Option.Option<A>, E | LeaderLockInfraError, R>;
255
+ }
256
+ declare const LeaderLock_base: Context.TagClass<LeaderLock, "@systemfsoftware/effect-daemon-spec/leader-lock.adapter/LeaderLock", LeaderLockService>;
257
+ declare class LeaderLock extends LeaderLock_base {
258
+ static readonly Noop: Layer.Layer<LeaderLock>;
259
+ }
298
260
  interface LockPrimitiveService {
299
261
  readonly tryAcquire: (key: string) => Effect.Effect<boolean, LockPrimitiveError, Scope.Scope>;
300
262
  }
301
- declare const LockPrimitive_base: Context.TagClass<LockPrimitive, "@systemfsoftware/effect-daemon-spec/lock-primitive/LockPrimitive", LockPrimitiveService>;
263
+ declare const LockPrimitive_base: Context.TagClass<LockPrimitive, "@systemfsoftware/effect-daemon-spec/leader-lock.adapter/LockPrimitive", LockPrimitiveService>;
302
264
  declare class LockPrimitive extends LockPrimitive_base {}
303
265
  declare const LeaderLockFromPrimitive: Layer.Layer<LeaderLock, never, LockPrimitive>;
304
266
  //#endregion
305
- //#region src/run.d.ts
306
- declare function worker<E, R>(w: Worker<E, R, {
307
- mode: 'none';
308
- }>): Effect.Effect<DaemonHealth, never, R | DaemonReporter | Scope.Scope>;
309
- declare function worker<E, R>(w: Worker<E, R, LockConfig>): Effect.Effect<DaemonHealth, never, R | LeaderLock | DaemonReporter | Scope.Scope>;
310
- declare function supervisor<E, R>(s: Supervisor<E, R, {
311
- mode: 'none';
312
- }>): Effect.Effect<SupervisorHealth, never, R | DaemonReporter | Scope.Scope>;
313
- declare function supervisor<E, R>(s: Supervisor<E, R, LockConfig>): Effect.Effect<SupervisorHealth, never, R | LeaderLock | DaemonReporter | Scope.Scope>;
314
- declare const run: {
315
- readonly worker: typeof worker;
316
- readonly supervisor: typeof supervisor;
317
- 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>;
267
+ //#region src/internal/with-leader-lock.executor.d.ts
268
+ interface LeaderLockOptions {
269
+ readonly key: string;
270
+ readonly mode: 'required' | 'optional';
271
+ readonly acquireRetryBackoff?: Schedule.Schedule<Duration.Duration>;
272
+ }
273
+ declare const WithLeaderLockExecutorDeps_base: Context.TagClass<WithLeaderLockExecutorDeps, "WithLeaderLockExecutorDeps", {
274
+ readonly withLock: LeaderLock["Type"]["withLock"];
275
+ }>;
276
+ declare class WithLeaderLockExecutorDeps extends WithLeaderLockExecutorDeps_base {}
277
+ declare function withLeaderLock<A, E, R>(self: Effect.Effect<A, E, R>, options: LeaderLockOptions): Effect.Effect<A | void, E | LeaderLockAcquireError, R | WithLeaderLockExecutorDeps>;
278
+ //#endregion
279
+ //#region src/daemon-worker.executor.d.ts
280
+ declare const worker: {
281
+ <E, R>(w: Worker<E, R, {
282
+ mode: 'none';
283
+ }>): Effect.Effect<DaemonHealth, never, R | Scope.Scope>;
284
+ <E, R>(w: Worker<E, R, LockConfig>): Effect.Effect<DaemonHealth, never, R | WithLeaderLockExecutorDeps | Scope.Scope>;
318
285
  };
319
286
  //#endregion
320
- //#region src/supervisor.d.ts
321
- interface SupervisorOpts<E, R, L extends LockConfig> {
322
- readonly name: string;
323
- readonly children: ReadonlyArray<Child<E, R>>;
324
- readonly supervision: Effect.Effect<SupervisionPolicy>;
325
- readonly lock: L;
326
- readonly reporter?: ReporterPolicyHooks;
327
- }
328
- declare const oneForOne: <E, R, L extends LockConfig = LockConfig>(opts: SupervisorOpts<E, R, L>) => Supervisor<E, R, L>;
329
- declare const oneForAll: <E, R, L extends LockConfig = LockConfig>(opts: SupervisorOpts<E, R, L>) => Supervisor<E, R, L>;
330
- declare const restForOne: <E, R, L extends LockConfig = LockConfig>(opts: SupervisorOpts<E, R, L>) => Supervisor<E, R, L>;
287
+ //#region src/internal/supervisor-body.executor.d.ts
288
+ declare const SupervisorBodyExecutorDeps_base: Context.TagClass<SupervisorBodyExecutorDeps, "SupervisorBodyExecutorDeps", {
289
+ readonly onRestart: DaemonReporter["Type"]["onRestart"];
290
+ readonly onExhausted: DaemonReporter["Type"]["onExhausted"];
291
+ }>;
292
+ declare class SupervisorBodyExecutorDeps extends SupervisorBodyExecutorDeps_base {}
293
+ declare const supervisor: <E, R>(s: Supervisor<E, R, LockConfig>) => Effect.Effect<SupervisorHealth, never, R | SupervisorBodyExecutorDeps | WithLeaderLockExecutorDeps | Scope.Scope>;
294
+ //#endregion
295
+ //#region src/internal/supervision-leader.state.d.ts
296
+ declare const LeaderConfig_base: Context.ReferenceClass<LeaderConfig, "@systemfsoftware/effect-daemon-spec/LeaderConfig", SupervisionConfig>;
297
+ declare class LeaderConfig extends LeaderConfig_base {}
298
+ //#endregion
299
+ //#region src/internal/supervision-task.state.d.ts
300
+ declare const TaskConfig_base: Context.ReferenceClass<TaskConfig, "@systemfsoftware/effect-daemon-spec/TaskConfig", SupervisionConfig>;
301
+ declare class TaskConfig extends TaskConfig_base {}
302
+ //#endregion
303
+ //#region src/internal/supervision-worker.state.d.ts
304
+ declare const WorkerConfig_base: Context.ReferenceClass<WorkerConfig, "@systemfsoftware/effect-daemon-spec/WorkerConfig", SupervisionConfig>;
305
+ declare class WorkerConfig extends WorkerConfig_base {}
306
+ //#endregion
307
+ //#region src/mod.d.ts
308
+ declare const poll: <A, E, R, L extends LockConfig>(opts: PollOpts<A, E, R, L>) => Worker<E, R, L>;
309
+ declare const stream: <A, E, R, L extends LockConfig>(opts: CommonOpts<L> & {
310
+ readonly stream: Stream.Stream<A, E, R>;
311
+ }) => Worker<E, R, L>;
312
+ declare const subscription: <A, E, R, L extends LockConfig>(opts: CommonOpts<L> & {
313
+ readonly acquire: Effect.Effect<A, E, R>;
314
+ }) => Worker<E, R, L>;
315
+ declare const Daemon: {
316
+ readonly poll: <A, E, R, L extends LockConfig>(opts: PollOpts<A, E, R, L>) => Worker<E, R, L>;
317
+ readonly stream: <A, E, R, L extends LockConfig>(opts: CommonOpts<L> & {
318
+ readonly stream: Stream.Stream<A, E, R>;
319
+ }) => Worker<E, R, L>;
320
+ readonly subscription: <A, E, R, L extends LockConfig>(opts: CommonOpts<L> & {
321
+ readonly acquire: Effect.Effect<A, E, R>;
322
+ }) => Worker<E, R, L>;
323
+ };
324
+ declare const run: {
325
+ readonly worker: {
326
+ <E, R>(w: Worker<E, R, {
327
+ mode: "none";
328
+ }>): Effect.Effect<DaemonHealth, never, R | import("effect/Scope").Scope>;
329
+ <E, R>(w: Worker<E, R, LockConfig>): Effect.Effect<DaemonHealth, never, R | WithLeaderLockExecutorDeps | import("effect/Scope").Scope>;
330
+ };
331
+ readonly supervisor: <E, R>(s: Supervisor<E, R, LockConfig>) => Effect.Effect<SupervisorHealth, never, R | SupervisorBodyExecutorDeps | WithLeaderLockExecutorDeps | import("effect/Scope").Scope>;
332
+ readonly dynamic: <E, R, Args>(spec: DynamicSpec<E, R, Args>) => Effect.Effect<DynamicHandle<Args, R | WithLeaderLockExecutorDeps | SupervisorBodyExecutorDeps | import("effect/Scope").Scope>, never, R | WithLeaderLockExecutorDeps | SupervisorBodyExecutorDeps | import("effect/Scope").Scope>;
333
+ };
334
+ declare const leader: (cap: Duration.DurationInput) => Effect.Effect<SupervisionPolicy>;
335
+ declare const task: (budget: Duration.DurationInput) => Effect.Effect<SupervisionPolicy>;
336
+ declare const supervision: (cap: Duration.DurationInput) => Effect.Effect<SupervisionPolicy>;
337
+ declare const Supervision: {
338
+ readonly leader: (cap: Duration.DurationInput) => Effect.Effect<SupervisionPolicy>;
339
+ readonly worker: (cap: Duration.DurationInput) => Effect.Effect<SupervisionPolicy>;
340
+ readonly task: (budget: Duration.DurationInput) => Effect.Effect<SupervisionPolicy>;
341
+ readonly custom: <P>(policy: P) => Effect.Effect<P>;
342
+ };
331
343
  declare const dynamic: <E, R, Args>(opts: {
332
344
  readonly name: string;
333
345
  readonly child: (args: Args) => Worker<E, R>;
334
346
  readonly maxChildren?: number;
335
347
  }) => DynamicSpec<E, R, Args>;
348
+ declare const oneForAll: <E, R, L extends LockConfig = LockConfig>(opts: SupervisorOpts<E, R, L>) => Supervisor<E, R, L>;
349
+ declare const oneForOne: <E, R, L extends LockConfig = LockConfig>(opts: SupervisorOpts<E, R, L>) => Supervisor<E, R, L>;
350
+ declare const restForOne: <E, R, L extends LockConfig = LockConfig>(opts: SupervisorOpts<E, R, L>) => Supervisor<E, R, L>;
351
+ declare const WithLeaderLockExecutorLive: Layer.Layer<WithLeaderLockExecutorDeps, never, LeaderLock>;
352
+ declare const SupervisorBodyExecutorLive: Layer.Layer<SupervisorBodyExecutorDeps, never, DaemonReporter>;
336
353
  //#endregion
337
- export { BoundedIntensity, Child, ChildPolicyConfig, ChildRef, CommonOpts, Daemon, DaemonHealth, DaemonReporter, DaemonReporterService, DynamicHandle, DynamicLimitExceeded, DynamicSpec, DynamicSpecTypeId, Intensity, IntensityConfig, IntensityTypeId, LeaderConfig, LeaderLock, type LeaderLockAcquireError, LeaderLockFromPrimitive, LeaderLockInfraError, LeaderLockNotAcquired, LeaderLockOptions, LeaderLockService, LockConfig, LockPolicyConfig, LockPrimitive, LockPrimitiveError, LockPrimitiveService, LoopShape, PollLoop, PollOpts, ReporterPolicyHooks, StreamLoop, SubscriptionLoop, Supervision, SupervisionConfig, SupervisionPolicy, Supervisor, SupervisorHealth, type SupervisorOpts, SupervisorTypeId, TaskConfig, TickPolicyConfig, TickPolicyHooks, UnboundedIntensity, Worker, WorkerConfig, WorkerTypeId, cappedBackoff, dynamic, healthStateGauge, isSupervisor, isWorker, oneForAll, oneForOne, poll, restForOne, run, stream, subscription, supervisor, supervisorChildrenGauge, supervisorExhaustionsCounter, supervisorRestartsCounter, withLeaderLock, worker };
354
+ 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, Noop, PollLoop, PollOpts, ReporterPolicyHooks, StreamLoop, SubscriptionLoop, Supervision, SupervisionConfig, SupervisionPolicy, Supervisor, SupervisorBodyExecutorDeps, SupervisorBodyExecutorLive, SupervisorHealth, SupervisorOpts, SupervisorTypeId, TaskConfig, TickPolicyConfig, TickPolicyHooks, UnboundedIntensity, WithLeaderLockExecutorDeps, WithLeaderLockExecutorLive, Worker, WorkerConfig, WorkerTypeId, cappedBackoff, dynamic, healthStateGauge, leader, oneForAll, oneForOne, poll, restForOne, run, stream, subscription, supervision, supervisor, supervisorChildrenGauge, supervisorExhaustionsCounter, supervisorRestartsCounter, task, withLeaderLock, worker };