effect-mq 0.5.0 → 0.6.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/README.md +85 -17
- package/dist/Flow.d.ts +381 -0
- package/dist/Flow.d.ts.map +1 -0
- package/dist/Flow.js +340 -0
- package/dist/Flow.js.map +1 -0
- package/dist/Job.d.ts +31 -6
- package/dist/Job.d.ts.map +1 -1
- package/dist/Job.js +16 -2
- package/dist/Job.js.map +1 -1
- package/dist/JobStore.d.ts +312 -10
- package/dist/JobStore.d.ts.map +1 -1
- package/dist/JobStore.js.map +1 -1
- package/dist/MemoryJobStore.d.ts.map +1 -1
- package/dist/MemoryJobStore.js +334 -7
- package/dist/MemoryJobStore.js.map +1 -1
- package/dist/Metrics.d.ts +31 -0
- package/dist/Metrics.d.ts.map +1 -1
- package/dist/Metrics.js +39 -0
- package/dist/Metrics.js.map +1 -1
- package/dist/Worker.d.ts +120 -11
- package/dist/Worker.d.ts.map +1 -1
- package/dist/Worker.js +452 -26
- package/dist/Worker.js.map +1 -1
- package/dist/drizzle-postgres/DrizzleJobStore.d.ts +19 -1
- package/dist/drizzle-postgres/DrizzleJobStore.d.ts.map +1 -1
- package/dist/drizzle-postgres/DrizzleJobStore.js +653 -77
- package/dist/drizzle-postgres/DrizzleJobStore.js.map +1 -1
- package/dist/drizzle-postgres/schema.d.ts +293 -3
- package/dist/drizzle-postgres/schema.d.ts.map +1 -1
- package/dist/drizzle-postgres/schema.js +66 -1
- package/dist/drizzle-postgres/schema.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/redis/RedisJobStore.d.ts.map +1 -1
- package/dist/redis/RedisJobStore.js +219 -18
- package/dist/redis/RedisJobStore.js.map +1 -1
- package/dist/redis/scripts.d.ts +117 -10
- package/dist/redis/scripts.d.ts.map +1 -1
- package/dist/redis/scripts.js +492 -25
- package/dist/redis/scripts.js.map +1 -1
- package/dist/testing/conformance.d.ts +6 -0
- package/dist/testing/conformance.d.ts.map +1 -1
- package/dist/testing/conformance.js +728 -1
- package/dist/testing/conformance.js.map +1 -1
- package/package.json +1 -1
- package/src/Flow.ts +778 -0
- package/src/Job.ts +35 -11
- package/src/JobStore.ts +339 -9
- package/src/MemoryJobStore.ts +370 -7
- package/src/Metrics.ts +43 -0
- package/src/Worker.ts +726 -37
- package/src/drizzle-postgres/DrizzleJobStore.ts +817 -78
- package/src/drizzle-postgres/schema.ts +92 -0
- package/src/index.ts +8 -0
- package/src/redis/RedisJobStore.ts +289 -8
- package/src/redis/scripts.ts +524 -24
- package/src/testing/conformance.ts +945 -1
package/dist/Metrics.js
CHANGED
|
@@ -121,4 +121,43 @@ export const stalledRecovered = Metric.counter("effect_mq_stalled_recovered", {
|
|
|
121
121
|
export const scheduleTicks = Metric.counter("effect_mq_schedule_ticks", {
|
|
122
122
|
description: "Repeatable-schedule occurrences enqueued by the schedule sweep"
|
|
123
123
|
});
|
|
124
|
+
/**
|
|
125
|
+
* Flow fan-outs acked (manifests landed). Tags: `flow`.
|
|
126
|
+
*
|
|
127
|
+
* @since 0.6.0
|
|
128
|
+
*/
|
|
129
|
+
export const flowFanOuts = Metric.counter("effect_mq_flow_fanouts", {
|
|
130
|
+
description: "Flow fan-out acks (child manifests persisted)"
|
|
131
|
+
});
|
|
132
|
+
/**
|
|
133
|
+
* Child results recorded into parent stores. Tags: `flow`, `outcome`
|
|
134
|
+
* (completed | failed | cancelled), `source` (`report` = delivered by a
|
|
135
|
+
* worker's outbox relay; `reconcile` = synthesized by the flow sweeper from
|
|
136
|
+
* child-store state). Only applied reports count — duplicates dropped by
|
|
137
|
+
* the dependency row do not.
|
|
138
|
+
*
|
|
139
|
+
* @since 0.6.0
|
|
140
|
+
*/
|
|
141
|
+
export const flowChildReports = Metric.counter("effect_mq_flow_child_reports", {
|
|
142
|
+
description: "Applied flow child-result reports by outcome and delivery path"
|
|
143
|
+
});
|
|
144
|
+
/**
|
|
145
|
+
* Cancels delivered into child stores after a flow settle. Tags: none.
|
|
146
|
+
*
|
|
147
|
+
* @since 0.6.0
|
|
148
|
+
*/
|
|
149
|
+
export const flowCascades = Metric.counter("effect_mq_flow_cascades", {
|
|
150
|
+
description: "Child cancels cascaded into child stores after a flow settled"
|
|
151
|
+
});
|
|
152
|
+
/**
|
|
153
|
+
* Undelivered outbox entries a relay drain had to leave behind (their
|
|
154
|
+
* parent store is not reachable from this worker — no matching `flows`
|
|
155
|
+
* registration). Tags: none. Sustained growth means no process anywhere
|
|
156
|
+
* can relay these flows; reconciliation keeps the flows correct meanwhile.
|
|
157
|
+
*
|
|
158
|
+
* @since 0.6.0
|
|
159
|
+
*/
|
|
160
|
+
export const flowOutboxSkipped = Metric.counter("effect_mq_flow_outbox_skipped", {
|
|
161
|
+
description: "Outbox entries left undelivered by a relay drain (parent store unknown here)"
|
|
162
|
+
});
|
|
124
163
|
//# sourceMappingURL=Metrics.js.map
|
package/dist/Metrics.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Metrics.js","sourceRoot":"","sources":["../src/Metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,wCAAwC;AACxC,MAAM,kBAAkB,GAAG,MAAM,CAAC,qBAAqB,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAA;AAE3F;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,yBAAyB,EAAE;IACpE,WAAW,EAAE,4EAA4E;CAC1F,CAAC,CAAA;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,oBAAoB,EAAE;IAC1D,WAAW,EAAE,qEAAqE;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AE,8EAA8E;CAC5F,CAAC,CAAA"}
|
package/dist/Worker.d.ts
CHANGED
|
@@ -8,17 +8,18 @@
|
|
|
8
8
|
*
|
|
9
9
|
* claim -> decode payload -> run handler -> ack (complete | retry | fail)
|
|
10
10
|
*
|
|
11
|
-
* plus
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* plus maintenance fibers: lock renewal for in-flight jobs, stalled job
|
|
12
|
+
* recovery, schedule sweeping — and, once flows are registered, the outbox
|
|
13
|
+
* relay and flow sweeper. On scope close, in-flight handlers are interrupted
|
|
14
|
+
* and their jobs released back to `waiting` without consuming an attempt.
|
|
14
15
|
*
|
|
15
16
|
* @since 0.1.0
|
|
16
17
|
*/
|
|
17
18
|
import { Cause, Context, Duration, Effect, Exit, Layer, Schema, type Scope } from "effect";
|
|
18
|
-
import { type BackoffPolicy, JobId, JobStore, QueueName, type Service as StoreService } from "./JobStore.ts";
|
|
19
|
+
import { type BackoffPolicy, type FlowChildSpec, type FlowState, JobId, type JobRecord, JobStore, QueueName, type Service as StoreService } from "./JobStore.ts";
|
|
19
20
|
/**
|
|
20
|
-
* Information about the currently running attempt
|
|
21
|
-
*
|
|
21
|
+
* Information about the currently running attempt. Handlers (and anything
|
|
22
|
+
* they call, however deeply nested) read it from the `CurrentJob` service.
|
|
22
23
|
*
|
|
23
24
|
* @since 0.1.0
|
|
24
25
|
*/
|
|
@@ -31,6 +32,27 @@ export interface JobContext {
|
|
|
31
32
|
/** Total attempts allowed for this job. */
|
|
32
33
|
readonly attemptsMax: number;
|
|
33
34
|
}
|
|
35
|
+
declare const CurrentJob_base: Context.ServiceClass<CurrentJob, "effect-mq/Worker/CurrentJob", JobContext>;
|
|
36
|
+
/**
|
|
37
|
+
* The currently running attempt, provided by the worker around every
|
|
38
|
+
* handler run (plain jobs and both flow phases). Declaring it as a
|
|
39
|
+
* requirement makes "this code only runs inside a job" a compile-time
|
|
40
|
+
* fact — `toLayer` subtracts it, since the worker supplies it per run:
|
|
41
|
+
*
|
|
42
|
+
* ```ts
|
|
43
|
+
* const notify = Effect.gen(function*() {
|
|
44
|
+
* const { jobId, attempt } = yield* Worker.CurrentJob
|
|
45
|
+
* // ... use them however deep in the call graph this runs
|
|
46
|
+
* })
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* Outside a worker (unit tests calling such code directly), provide a
|
|
50
|
+
* value with `Effect.provideService(Worker.CurrentJob, {...})`.
|
|
51
|
+
*
|
|
52
|
+
* @since 0.6.0
|
|
53
|
+
*/
|
|
54
|
+
export declare class CurrentJob extends CurrentJob_base {
|
|
55
|
+
}
|
|
34
56
|
/**
|
|
35
57
|
* The structural shape of a job definition the worker needs for
|
|
36
58
|
* registration. `Job.Job` satisfies this — the indirection avoids a module
|
|
@@ -55,6 +77,47 @@ export interface JobDescriptor<Payload extends Schema.Top, Success extends Schem
|
|
|
55
77
|
/** When present and returning false for a typed error, retries are skipped. */
|
|
56
78
|
readonly retryable: ((error: Error["Type"]) => boolean) | undefined;
|
|
57
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* The structural shape of a flow definition the worker needs — for running
|
|
82
|
+
* flow CHILDREN (the outbox relay routes results by parent store) and, via
|
|
83
|
+
* `FlowDescriptor`, for running the parent's two phases. `Flow.Flow`
|
|
84
|
+
* satisfies this; the indirection avoids a module cycle.
|
|
85
|
+
*
|
|
86
|
+
* @since 0.6.0
|
|
87
|
+
*/
|
|
88
|
+
export interface FlowAny {
|
|
89
|
+
/** The flow's unique name (what child `parent` envelopes reference). */
|
|
90
|
+
readonly name: string;
|
|
91
|
+
readonly parent: {
|
|
92
|
+
readonly store: Context.Key<any, StoreService>;
|
|
93
|
+
};
|
|
94
|
+
/** True when the flow's `onChildFailure` policy is `"fail"`. */
|
|
95
|
+
readonly failFast: boolean;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* What `Flow.toLayer` hands to `registerFlow`: the parent job's codecs plus
|
|
99
|
+
* the two phase runners, pre-wired by the flow module (fan-out builds
|
|
100
|
+
* complete `FlowChildSpec`s — deterministic ids, `parent` envelopes, trace
|
|
101
|
+
* stamps — and collect consumes the recorded dependency rows).
|
|
102
|
+
*
|
|
103
|
+
* @internal
|
|
104
|
+
*/
|
|
105
|
+
export interface FlowDescriptor extends FlowAny {
|
|
106
|
+
readonly parent: {
|
|
107
|
+
readonly _tag: string;
|
|
108
|
+
readonly queue: QueueName;
|
|
109
|
+
readonly store: Context.Key<any, StoreService>;
|
|
110
|
+
readonly payloadJsonSchema: Schema.Top;
|
|
111
|
+
readonly exitSchema: Schema.Top;
|
|
112
|
+
readonly retryable: ((error: never) => boolean) | undefined;
|
|
113
|
+
};
|
|
114
|
+
/** Every child store the sweeper/enqueuer must reach, for context lookup. */
|
|
115
|
+
readonly childStores: ReadonlyArray<Context.Key<any, StoreService>>;
|
|
116
|
+
readonly fanOut: (payload: JobRecord["payload"], context: JobContext,
|
|
117
|
+
/** The parent's own nesting depth (0 for top-level flows). */
|
|
118
|
+
parentDepth: number) => Effect.Effect<ReadonlyArray<FlowChildSpec>, unknown, unknown>;
|
|
119
|
+
readonly collect: (payload: JobRecord["payload"], flowState: FlowState, context: JobContext) => Effect.Effect<unknown, unknown, unknown>;
|
|
120
|
+
}
|
|
58
121
|
/**
|
|
59
122
|
* @since 0.1.0
|
|
60
123
|
*/
|
|
@@ -130,6 +193,29 @@ export interface WorkerOptions<StoreId = JobStore> {
|
|
|
130
193
|
* trackers, paging), not a logging prerequisite.
|
|
131
194
|
*/
|
|
132
195
|
readonly onJobFailure?: ((failure: JobFailure) => Effect.Effect<void>) | undefined;
|
|
196
|
+
/**
|
|
197
|
+
* Flows whose CHILD jobs this worker runs. Child results are written to
|
|
198
|
+
* the child store's outbox atomically with each terminal transition; this
|
|
199
|
+
* list gives the worker the flows' parent stores (each parent StoreId
|
|
200
|
+
* lands in the layer's requirements), so its relay can push those results
|
|
201
|
+
* immediately. Without it the results wait for a relay elsewhere or for
|
|
202
|
+
* the parent-side sweeper's reconciliation — correct either way, just
|
|
203
|
+
* slower. Workers running a flow's PARENT phases get their registration
|
|
204
|
+
* implicitly from `Flow.toLayer`.
|
|
205
|
+
*/
|
|
206
|
+
readonly flows?: ReadonlyArray<FlowAny> | undefined;
|
|
207
|
+
/**
|
|
208
|
+
* Cadence of the flow sweeper (default 30s), which repairs whatever the
|
|
209
|
+
* push path missed: (re-)enqueues fanned-out children that never landed
|
|
210
|
+
* in their store, synthesizes reports for children that reached a
|
|
211
|
+
* terminal state without a delivered report, and cascades cancels after
|
|
212
|
+
* a flow settles. Also the age a dependency row must reach before it is
|
|
213
|
+
* reconciled, and the outbox relay's fallback drain cadence (the relay
|
|
214
|
+
* normally drains the moment a child result is acked). The sweeper runs
|
|
215
|
+
* only on workers that registered a flow via `Flow.toLayer`; the relay
|
|
216
|
+
* runs on any worker with flow registrations of either kind.
|
|
217
|
+
*/
|
|
218
|
+
readonly flowSweepInterval?: Duration.Input | undefined;
|
|
133
219
|
/** Identifier used in lock tokens (default: random). */
|
|
134
220
|
readonly id?: string | undefined;
|
|
135
221
|
}
|
|
@@ -152,7 +238,15 @@ export interface JobFailure {
|
|
|
152
238
|
readonly cause: Cause.Cause<unknown>;
|
|
153
239
|
}
|
|
154
240
|
declare const Worker_base: Context.ServiceClass<Worker, "effect-mq/Worker", {
|
|
155
|
-
readonly register: <Payload extends Schema.Top, Success extends Schema.Top, Error extends Schema.Top, R>(job: JobDescriptor<Payload, Success, Error>, handler: (payload: Payload["Type"]
|
|
241
|
+
readonly register: <Payload extends Schema.Top, Success extends Schema.Top, Error extends Schema.Top, R>(job: JobDescriptor<Payload, Success, Error>, handler: (payload: Payload["Type"]) => Effect.Effect<Success["Type"], Error["Type"], R>, options?: RegisterOptions | undefined) => Effect.Effect<void, never, Scope.Scope | Exclude<R, CurrentJob> | Payload["DecodingServices"] | Success["EncodingServices"] | Error["EncodingServices"]>;
|
|
242
|
+
/**
|
|
243
|
+
* Register a flow's parent phases (`fanOut`/`collect`). Called by
|
|
244
|
+
* `Flow.toLayer`, which declares the real requirements (parent + child
|
|
245
|
+
* stores, handler R, codec services) on its own signature.
|
|
246
|
+
*
|
|
247
|
+
* @internal
|
|
248
|
+
*/
|
|
249
|
+
readonly registerFlow: (flow: FlowDescriptor, options?: RegisterOptions | undefined) => Effect.Effect<void, never, Scope.Scope>;
|
|
156
250
|
}>;
|
|
157
251
|
/**
|
|
158
252
|
* @since 0.1.0
|
|
@@ -166,18 +260,33 @@ export declare class Worker extends Worker_base {
|
|
|
166
260
|
*/
|
|
167
261
|
export declare const backoffDelayMs: (backoff: BackoffPolicy | undefined, attempt: number) => number;
|
|
168
262
|
/**
|
|
169
|
-
*
|
|
170
|
-
*
|
|
263
|
+
* The parent StoreIds of the flows passed via `Worker.layer({ flows })` —
|
|
264
|
+
* a naked type parameter so the union of flows distributes.
|
|
265
|
+
*
|
|
266
|
+
* @since 0.6.0
|
|
267
|
+
*/
|
|
268
|
+
export type FlowParentStores<F> = F extends {
|
|
269
|
+
readonly parent: {
|
|
270
|
+
readonly store: Context.Key<infer Id, StoreService>;
|
|
271
|
+
};
|
|
272
|
+
} ? Id : never;
|
|
273
|
+
/**
|
|
274
|
+
* Build the worker service. Requires a `Scope` (fibers live in it), the
|
|
275
|
+
* `JobStore`, and the parent store of every flow in `flows`.
|
|
171
276
|
*
|
|
172
277
|
* @since 0.1.0
|
|
173
278
|
*/
|
|
174
|
-
export declare const make: <StoreId = JobStore>(options?: WorkerOptions<StoreId>
|
|
279
|
+
export declare const make: <StoreId = JobStore, const Flows extends ReadonlyArray<FlowAny> = ReadonlyArray<never>>(options?: (WorkerOptions<StoreId> & {
|
|
280
|
+
readonly flows?: Flows | undefined;
|
|
281
|
+
}) | undefined) => Effect.Effect<Worker["Service"], never, Scope.Scope | StoreId | FlowParentStores<Flows[number]>>;
|
|
175
282
|
/**
|
|
176
283
|
* Run a worker as a layer. Provide handler layers (`Job.toLayer(...)`) on top
|
|
177
284
|
* of this, and a `JobStore` below it.
|
|
178
285
|
*
|
|
179
286
|
* @since 0.1.0
|
|
180
287
|
*/
|
|
181
|
-
export declare const layer: <StoreId = JobStore>(options?: WorkerOptions<StoreId>
|
|
288
|
+
export declare const layer: <StoreId = JobStore, const Flows extends ReadonlyArray<FlowAny> = ReadonlyArray<never>>(options?: (WorkerOptions<StoreId> & {
|
|
289
|
+
readonly flows?: Flows | undefined;
|
|
290
|
+
}) | undefined) => Layer.Layer<Worker, never, StoreId | FlowParentStores<Flows[number]>>;
|
|
182
291
|
export {};
|
|
183
292
|
//# sourceMappingURL=Worker.d.ts.map
|
package/dist/Worker.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Worker.d.ts","sourceRoot":"","sources":["../src/Worker.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Worker.d.ts","sourceRoot":"","sources":["../src/Worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,KAAK,EAAS,OAAO,EAAY,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAmB,KAAK,EAAoC,MAAM,EAAE,KAAK,KAAK,EAA2B,MAAM,QAAQ,CAAA;AACvL,OAAO,EAEL,KAAK,aAAa,EAElB,KAAK,aAAa,EAClB,KAAK,SAAS,EAGd,KAAK,EAEL,KAAK,SAAS,EACd,QAAQ,EAIR,SAAS,EAET,KAAK,OAAO,IAAI,YAAY,EAC7B,MAAM,eAAe,CAAA;AAGtB;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;IACzB,8BAA8B;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,2CAA2C;IAC3C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAC7B;;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,q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