@convex-dev/workpool 0.2.19 → 0.3.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 +77 -68
- package/dist/client/index.d.ts +7 -8
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +2 -8
- package/dist/client/index.js.map +1 -1
- package/dist/client/utils.d.ts +1 -8
- package/dist/client/utils.d.ts.map +1 -1
- package/dist/client/utils.js.map +1 -1
- package/dist/component/_generated/api.d.ts +27 -124
- package/dist/component/_generated/api.d.ts.map +1 -1
- package/dist/component/_generated/api.js +10 -1
- package/dist/component/_generated/api.js.map +1 -1
- package/dist/component/_generated/component.d.ts +98 -0
- package/dist/component/_generated/component.d.ts.map +1 -0
- package/dist/component/_generated/component.js +11 -0
- package/dist/component/_generated/component.js.map +1 -0
- package/dist/component/_generated/dataModel.d.ts +4 -18
- package/dist/component/_generated/dataModel.d.ts.map +1 -0
- package/dist/component/_generated/dataModel.js +11 -0
- package/dist/component/_generated/dataModel.js.map +1 -0
- package/dist/component/_generated/server.d.ts +10 -38
- package/dist/component/_generated/server.d.ts.map +1 -1
- package/dist/component/_generated/server.js +9 -5
- package/dist/component/_generated/server.js.map +1 -1
- package/dist/component/danger.d.ts +2 -2
- package/dist/component/lib.d.ts +9 -9
- package/dist/component/schema.d.ts +15 -15
- package/dist/component/shared.d.ts +4 -3
- package/dist/component/shared.d.ts.map +1 -1
- package/dist/component/shared.js +6 -0
- package/dist/component/shared.js.map +1 -1
- package/dist/component/stats.d.ts +2 -2
- package/dist/component/worker.d.ts +3 -3
- package/package.json +32 -30
- package/src/client/index.ts +23 -29
- package/src/client/utils.ts +3 -32
- package/src/component/README.md +6 -6
- package/src/component/_generated/api.ts +70 -0
- package/src/component/_generated/component.ts +117 -0
- package/src/component/_generated/{server.d.ts → server.ts} +33 -21
- package/src/component/complete.test.ts +1 -1
- package/src/component/complete.ts +6 -6
- package/src/component/danger.ts +3 -3
- package/src/component/kick.test.ts +5 -5
- package/src/component/kick.ts +6 -6
- package/src/component/lib.test.ts +3 -3
- package/src/component/lib.ts +8 -8
- package/src/component/logging.ts +2 -2
- package/src/component/loop.test.ts +9 -9
- package/src/component/loop.ts +33 -33
- package/src/component/recovery.test.ts +7 -7
- package/src/component/recovery.ts +2 -2
- package/src/component/schema.ts +2 -2
- package/src/component/shared.ts +11 -5
- package/src/component/stats.test.ts +3 -3
- package/src/component/stats.ts +6 -6
- package/src/test.ts +10 -3
- package/src/component/_generated/api.d.ts +0 -151
- package/src/component/_generated/api.js +0 -23
- package/src/component/_generated/server.js +0 -90
- /package/src/component/_generated/{dataModel.d.ts → dataModel.ts} +0 -0
package/README.md
CHANGED
|
@@ -8,7 +8,8 @@ This Convex component pools actions and mutations to restrict parallel requests.
|
|
|
8
8
|
|
|
9
9
|
- Configure multiple pools with different parallelism.
|
|
10
10
|
- Retry failed actions (with backoff and jitter) for
|
|
11
|
-
[idempotent actions](#idempotency), fully configurable (respecting
|
|
11
|
+
[idempotent actions](#idempotency), fully configurable (respecting
|
|
12
|
+
parallelism).
|
|
12
13
|
- An `onComplete` callback so you can build durable, reliable workflows. Called
|
|
13
14
|
when the work is finished, whether it succeeded, failed, or was canceled.
|
|
14
15
|
|
|
@@ -53,15 +54,15 @@ export const downloadLatestWeather = mutation({
|
|
|
53
54
|
|
|
54
55
|
### Retry management
|
|
55
56
|
|
|
56
|
-
Imagine that the payment processor is a 3rd party API, and they temporarily have
|
|
57
|
-
outage. Now imagine you implement your own action retrying logic for your
|
|
58
|
-
You'll find very quickly that your entire backend is overwhelmed with
|
|
59
|
-
This could bog down live traffic with background work, and/or
|
|
60
|
-
rate limits with the payment provider.
|
|
57
|
+
Imagine that the payment processor is a 3rd party API, and they temporarily have
|
|
58
|
+
an outage. Now imagine you implement your own action retrying logic for your
|
|
59
|
+
busy app. You'll find very quickly that your entire backend is overwhelmed with
|
|
60
|
+
retrying actions. This could bog down live traffic with background work, and/or
|
|
61
|
+
cause you to exceed rate limits with the payment provider.
|
|
61
62
|
|
|
62
|
-
Creating an upper bound on how much work will be done in parallel is a good way
|
|
63
|
-
mitigate this risk. Actions that are currently backing off awaiting retry
|
|
64
|
-
up a thread in the workpool.
|
|
63
|
+
Creating an upper bound on how much work will be done in parallel is a good way
|
|
64
|
+
to mitigate this risk. Actions that are currently backing off awaiting retry
|
|
65
|
+
will not tie up a thread in the workpool.
|
|
65
66
|
|
|
66
67
|
### Completion handling
|
|
67
68
|
|
|
@@ -70,9 +71,9 @@ you can account for temporary failures, while avoiding a "stampeding herd"
|
|
|
70
71
|
during third party outages.
|
|
71
72
|
|
|
72
73
|
With the `onComplete` callback, you can define how to proceed after each step,
|
|
73
|
-
whether that enqueues another job to the workpool, updates the database, etc.
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
whether that enqueues another job to the workpool, updates the database, etc. It
|
|
75
|
+
will always be called, whether the work was successful, failed, or was canceled.
|
|
76
|
+
See [below](#options-for-enqueueing-work) for more info.
|
|
76
77
|
|
|
77
78
|
Example:
|
|
78
79
|
|
|
@@ -102,7 +103,7 @@ const sendEmailReliablyWithRetries = mutation({
|
|
|
102
103
|
|
|
103
104
|
export const emailSent = internalMutation({
|
|
104
105
|
args: vOnCompleteValidator(
|
|
105
|
-
v.object({ emailType: v.string(), userId: v.id("users") })
|
|
106
|
+
v.object({ emailType: v.string(), userId: v.id("users") }),
|
|
106
107
|
),
|
|
107
108
|
handler: async (ctx, { workId, context, result }) => {
|
|
108
109
|
if (result.kind === "canceled") return;
|
|
@@ -121,7 +122,7 @@ export const emailSent = internalMutation({
|
|
|
121
122
|
retry: { maxAttempts: 10, initialBackoffMs: 250, base: 2 }, // custom
|
|
122
123
|
onComplete: internal.email.handleEmailStatus,
|
|
123
124
|
context: { emailLogId },
|
|
124
|
-
}
|
|
125
|
+
},
|
|
125
126
|
);
|
|
126
127
|
}
|
|
127
128
|
},
|
|
@@ -129,12 +130,12 @@ export const emailSent = internalMutation({
|
|
|
129
130
|
```
|
|
130
131
|
|
|
131
132
|
Note: the `onComplete` handler runs in a different transaction than the job
|
|
132
|
-
enqueued. If you want to run it in the same transaction, you can do that work
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
enqueued. If you want to run it in the same transaction, you can do that work at
|
|
134
|
+
the end of the enqueued function, before returning. This is generally faster and
|
|
135
|
+
more typesafe when handling the "success" case.
|
|
135
136
|
|
|
136
|
-
You can also use this equivalent helper to define an `onComplete` mutation.
|
|
137
|
-
|
|
137
|
+
You can also use this equivalent helper to define an `onComplete` mutation. Note
|
|
138
|
+
the `DataModel` type parameter, if you want ctx.db to be type safe.
|
|
138
139
|
|
|
139
140
|
```ts
|
|
140
141
|
export const emailSent = pool.defineOnComplete<DataModel>({
|
|
@@ -147,19 +148,20 @@ export const emailSent = pool.defineOnComplete<DataModel>({
|
|
|
147
148
|
|
|
148
149
|
### Idempotency
|
|
149
150
|
|
|
150
|
-
Idempotent actions are actions that can be run multiple times safely. This
|
|
151
|
-
means they don't cause any side effects that would be a problem if
|
|
151
|
+
Idempotent actions are actions that can be run multiple times safely. This
|
|
152
|
+
typically means they don't cause any side effects that would be a problem if
|
|
153
|
+
executed twice or more.
|
|
152
154
|
|
|
153
|
-
As an example of an unsafe, non-idempotent action, consider an action that
|
|
154
|
-
a user's credit card without providing a unique transaction id to the
|
|
155
|
-
processor. The first time the action is run, imagine that the API call
|
|
156
|
-
payment provider, but then the action throws an exception before
|
|
157
|
-
finished in our Convex database. If the action is run
|
|
158
|
-
double charged for the transaction!
|
|
155
|
+
As an example of an unsafe, non-idempotent action, consider an action that
|
|
156
|
+
charges a user's credit card without providing a unique transaction id to the
|
|
157
|
+
payment processor. The first time the action is run, imagine that the API call
|
|
158
|
+
succeeds to the payment provider, but then the action throws an exception before
|
|
159
|
+
the transaction is marked finished in our Convex database. If the action is run
|
|
160
|
+
twice, the user may be double charged for the transaction!
|
|
159
161
|
|
|
160
|
-
If we alter this action to provide a consistent transaction id to the payment
|
|
161
|
-
can simply NOOP the second payment attempt. The this makes the
|
|
162
|
-
it can safely be retried.
|
|
162
|
+
If we alter this action to provide a consistent transaction id to the payment
|
|
163
|
+
provider, they can simply NOOP the second payment attempt. The this makes the
|
|
164
|
+
action idempotent, and it can safely be retried.
|
|
163
165
|
|
|
164
166
|
If you're creating complex workflows with many steps involving 3rd party APIs:
|
|
165
167
|
|
|
@@ -169,12 +171,12 @@ If you're creating complex workflows with many steps involving 3rd party APIs:
|
|
|
169
171
|
### Reducing database write conflicts (aka OCC errors)
|
|
170
172
|
|
|
171
173
|
With limited parallelism, you can reduce
|
|
172
|
-
[write conflicts](https://docs.convex.dev/error#1)
|
|
173
|
-
|
|
174
|
+
[write conflicts](https://docs.convex.dev/error#1) from mutations that read and
|
|
175
|
+
write the same data.
|
|
174
176
|
|
|
175
|
-
Consider this action that calls a mutation to increment a singleton counter.
|
|
176
|
-
|
|
177
|
-
|
|
177
|
+
Consider this action that calls a mutation to increment a singleton counter. By
|
|
178
|
+
calling the mutation on a workpool with `maxParallelism: 1`, it will never throw
|
|
179
|
+
an error due to conflicts with parallel mutations.
|
|
178
180
|
|
|
179
181
|
```ts
|
|
180
182
|
const counterPool = new Workpool(components.counterWorkpool, {
|
|
@@ -200,16 +202,16 @@ export const increment = internalMutation({
|
|
|
200
202
|
```
|
|
201
203
|
|
|
202
204
|
Effectively, Workpool runs async functions similar to
|
|
203
|
-
`ctx.scheduler.runAfter(0, ...)`, but it limits the number of functions that
|
|
204
|
-
|
|
205
|
+
`ctx.scheduler.runAfter(0, ...)`, but it limits the number of functions that can
|
|
206
|
+
run in parallel.
|
|
205
207
|
|
|
206
208
|
## Reactive status of asynchronous work
|
|
207
209
|
|
|
208
210
|
The workpool stores the status of each function in the database, and thanks to
|
|
209
211
|
Convex's reactive queries, you can read it in a query to power a reactive UI.
|
|
210
212
|
|
|
211
|
-
By default, it will keep the status for 1 day but you can change this with
|
|
212
|
-
|
|
213
|
+
By default, it will keep the status for 1 day but you can change this with the
|
|
214
|
+
`statusTtl` option to `Workpool`.
|
|
213
215
|
|
|
214
216
|
To keep the status forever, set `statusTtl: Number.POSITIVE_INFINITY`.
|
|
215
217
|
|
|
@@ -230,8 +232,10 @@ export const getStatus = query({
|
|
|
230
232
|
|
|
231
233
|
The status will be one of:
|
|
232
234
|
|
|
233
|
-
- `{ kind: "pending"; previousAttempts: number }`: The function has not started
|
|
234
|
-
|
|
235
|
+
- `{ kind: "pending"; previousAttempts: number }`: The function has not started
|
|
236
|
+
yet.
|
|
237
|
+
- `{ kind: "running"; previousAttempts: number }`: The function is currently
|
|
238
|
+
running.
|
|
235
239
|
- `{ kind: "finished" }`: The function has succeeded, failed, or been canceled.
|
|
236
240
|
|
|
237
241
|
To get the result of your function, you can either write to the database from
|
|
@@ -242,11 +246,12 @@ within your function, call or schedule another function from there, or use the
|
|
|
242
246
|
|
|
243
247
|
### Pre-requisite: Convex
|
|
244
248
|
|
|
245
|
-
You'll need an existing Convex project to use the component.
|
|
246
|
-
|
|
247
|
-
|
|
249
|
+
You'll need an existing Convex project to use the component. Convex is a hosted
|
|
250
|
+
backend platform, including a database, serverless functions, and a ton more you
|
|
251
|
+
can learn about [here](https://docs.convex.dev/get-started).
|
|
248
252
|
|
|
249
|
-
Run `npm create convex` or follow any of the
|
|
253
|
+
Run `npm create convex` or follow any of the
|
|
254
|
+
[quickstarts](https://docs.convex.dev/home) to set one up.
|
|
250
255
|
|
|
251
256
|
### Install the component
|
|
252
257
|
|
|
@@ -264,7 +269,7 @@ npm install @convex-dev/workpool
|
|
|
264
269
|
```ts
|
|
265
270
|
// convex/convex.config.ts
|
|
266
271
|
import { defineApp } from "convex/server";
|
|
267
|
-
import workpool from "@convex-dev/workpool/convex.config";
|
|
272
|
+
import workpool from "@convex-dev/workpool/convex.config.js";
|
|
268
273
|
|
|
269
274
|
const app = defineApp();
|
|
270
275
|
app.use(workpool, { name: "emailWorkpool" });
|
|
@@ -279,7 +284,8 @@ See example usage in [example.ts](./example/convex/example.ts).
|
|
|
279
284
|
Check out the [docstrings](./src/client/index.ts), but notable options include:
|
|
280
285
|
|
|
281
286
|
- `maxParallelism`: How many actions/mutations can run at once within this pool.
|
|
282
|
-
Avoid exceeding 100 on Pro, 20 on the free plan, across all workpools and
|
|
287
|
+
Avoid exceeding 100 on Pro, 20 on the free plan, across all workpools and
|
|
288
|
+
workflows.
|
|
283
289
|
- `retryActionsByDefault`: Whether to retry actions that fail by default.
|
|
284
290
|
- `defaultRetryBehavior`: The default retry behavior for enqueued actions.
|
|
285
291
|
|
|
@@ -287,11 +293,12 @@ You can override the retry behavior per-call with the `retry` option.
|
|
|
287
293
|
|
|
288
294
|
### Options for enqueueing work
|
|
289
295
|
|
|
290
|
-
See the [docstrings](./src/client/index.ts) for more details, but notable
|
|
296
|
+
See the [docstrings](./src/client/index.ts) for more details, but notable
|
|
297
|
+
options include:
|
|
291
298
|
|
|
292
|
-
- `retry`: Whether to retry the action if it fails. Overrides defaults.
|
|
293
|
-
|
|
294
|
-
|
|
299
|
+
- `retry`: Whether to retry the action if it fails. Overrides defaults. If it's
|
|
300
|
+
set to `true`, it will use the `defaultRetryBehavior`. If it's set to a custom
|
|
301
|
+
config, it will use that (and do retries).
|
|
295
302
|
- `onComplete`: A mutation to run after the function finishes.
|
|
296
303
|
- `context`: Any data you want to pass to the `onComplete` mutation.
|
|
297
304
|
- `runAt` and `runAfter`: Similar to `ctx.scheduler.run*`, allows you to
|
|
@@ -305,8 +312,8 @@ The retry options work like this:
|
|
|
305
312
|
- If it fails, it will wait _around_ `initialBackoffMs` and then try again.
|
|
306
313
|
- Each subsequent retry waits `initialBackoffMs * base^<retryNumber - 1>`.
|
|
307
314
|
- The standard base is 2.
|
|
308
|
-
- The actual wait time uses "jitter" to avoid all retries happening at once
|
|
309
|
-
|
|
315
|
+
- The actual wait time uses "jitter" to avoid all retries happening at once if
|
|
316
|
+
they all fail at the same time.
|
|
310
317
|
|
|
311
318
|
You can override the retry behavior per-call with the `retry` option.
|
|
312
319
|
|
|
@@ -315,8 +322,8 @@ You can override the retry behavior per-call with the `retry` option.
|
|
|
315
322
|
The benefit of Workpool is that it won't fall over if there are many jobs
|
|
316
323
|
scheduled at once, and it allows you to throttle low-priority jobs.
|
|
317
324
|
|
|
318
|
-
However, Workpool has some overhead and can slow down your workload compared
|
|
319
|
-
|
|
325
|
+
However, Workpool has some overhead and can slow down your workload compared to
|
|
326
|
+
using `ctx.scheduler` directly.
|
|
320
327
|
|
|
321
328
|
Since each Workpool has some overhead -- each runs several functions to
|
|
322
329
|
coordinate its work -- don't create too many of them.
|
|
@@ -330,17 +337,18 @@ alternatives to Workpool:
|
|
|
330
337
|
- In particular, an action calling `ctx.runAction` has more overhead than just
|
|
331
338
|
calling the action's handler directly.
|
|
332
339
|
|
|
333
|
-
See [best practices](https://docs.convex.dev/production/best-practices) for
|
|
340
|
+
See [best practices](https://docs.convex.dev/production/best-practices) for
|
|
341
|
+
more.
|
|
334
342
|
|
|
335
343
|
### Batching
|
|
336
344
|
|
|
337
|
-
If you're enqueuing a lot of work, you can use `enqueueActionBatch` to enqueue
|
|
338
|
-
|
|
345
|
+
If you're enqueuing a lot of work, you can use `enqueueActionBatch` to enqueue a
|
|
346
|
+
batch of actions at once, or the equivalents for queries or mutations.
|
|
339
347
|
|
|
340
348
|
This helps in two ways:
|
|
341
349
|
|
|
342
|
-
1. It reduces the number of calls to the component, which reduces overhead
|
|
343
|
-
|
|
350
|
+
1. It reduces the number of calls to the component, which reduces overhead as
|
|
351
|
+
each component call runs in a fresh container (for strong isolation).
|
|
344
352
|
2. When called from an action, it reduces the number of mutations that might
|
|
345
353
|
conflict with each other, especially if they were being called in parallel.
|
|
346
354
|
|
|
@@ -372,9 +380,9 @@ This will avoid starting or retrying, but will not stop in-progress work.
|
|
|
372
380
|
## Monitoring the workpool
|
|
373
381
|
|
|
374
382
|
If you want to know the status of your workpool, here are some queries to use
|
|
375
|
-
for [Axiom](https://axiom.co/docs/send-data/convex).
|
|
376
|
-
|
|
377
|
-
|
|
383
|
+
for [Axiom](https://axiom.co/docs/send-data/convex). Just replace `your-dataset`
|
|
384
|
+
with your dataset's name (which is also what you enter in the log streaming
|
|
385
|
+
configuration in the Convex dashboard).
|
|
378
386
|
|
|
379
387
|
Note: these are optimized for monitors. For dashboards, you might want to change
|
|
380
388
|
`bin(_time, X)` to `bin_auto(_time)`.
|
|
@@ -397,7 +405,8 @@ max for 1 minute intervals (which is roughly how often the report is generated).
|
|
|
397
405
|
|
|
398
406
|
### Are functions failing (after retries)
|
|
399
407
|
|
|
400
|
-
Reports the overall average failure rate per registered workpool in 5 minute
|
|
408
|
+
Reports the overall average failure rate per registered workpool in 5 minute
|
|
409
|
+
intervals.
|
|
401
410
|
|
|
402
411
|
```txt
|
|
403
412
|
['your-dataset']
|
|
@@ -427,8 +436,8 @@ Note: to get this data, set the workpool `logLevel` to `"INFO"` (or `"DEBUG"`).
|
|
|
427
436
|
|
|
428
437
|
### Is there a big delay between being enqueued and starting
|
|
429
438
|
|
|
430
|
-
Reports the average time between enqueueing work and it actually starting.
|
|
431
|
-
|
|
439
|
+
Reports the average time between enqueueing work and it actually starting. Note:
|
|
440
|
+
to get this data, set the workpool `logLevel` to `"INFO"` (or `"DEBUG"`).
|
|
432
441
|
|
|
433
442
|
```txt
|
|
434
443
|
['your-dataset']
|
|
@@ -443,8 +452,8 @@ Note: to get this data, set the workpool `logLevel` to `"INFO"` (or `"DEBUG"`).
|
|
|
443
452
|
While similar to the backlog size, this is a more concrete value, since the
|
|
444
453
|
events in the backlog may take variable amounts of time. This is a more user-
|
|
445
454
|
visible metric, though it is a "lagging" indicator - this will be high when the
|
|
446
|
-
backlog was large enough to delay the processing of an entry. So alerting on
|
|
447
|
-
|
|
455
|
+
backlog was large enough to delay the processing of an entry. So alerting on the
|
|
456
|
+
backlog size will give you a faster indicator, while this is a metric of the
|
|
448
457
|
severity of the incident.
|
|
449
458
|
|
|
450
459
|
<!-- END: Include on https://convex.dev/components -->
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type DefaultFunctionArgs, type FunctionReference, type FunctionType, type FunctionVisibility, type GenericDataModel, type GenericMutationCtx, type RegisteredMutation } from "convex/server";
|
|
2
2
|
import { type Infer, type Validator, type VAny, type VString } from "convex/values";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ComponentApi } from "../component/_generated/component.js";
|
|
4
4
|
import { type LogLevel } from "../component/logging.js";
|
|
5
|
-
import { type RetryBehavior, type RunResult, type Status, vResultValidator } from "../component/shared.js";
|
|
6
|
-
import { type RunMutationCtx, type RunQueryCtx
|
|
5
|
+
import { DEFAULT_RETRY_BEHAVIOR, type RetryBehavior, type RunResult, type Status, vResultValidator } from "../component/shared.js";
|
|
6
|
+
import { type RunMutationCtx, type RunQueryCtx } from "./utils.js";
|
|
7
7
|
export { logLevel as vLogLevel, type LogLevel } from "../component/logging.js";
|
|
8
8
|
export { retryBehavior as vRetryBehavior } from "../component/shared.js";
|
|
9
9
|
export { vResultValidator, type RetryBehavior, type RunResult };
|
|
@@ -11,7 +11,7 @@ export type WorkId = string & {
|
|
|
11
11
|
__isWorkId: true;
|
|
12
12
|
};
|
|
13
13
|
export declare const vWorkIdValidator: VString<WorkId>;
|
|
14
|
-
export {
|
|
14
|
+
export { DEFAULT_RETRY_BEHAVIOR,
|
|
15
15
|
/** @deprecated Use `vResultValidator` instead. */
|
|
16
16
|
vResultValidator as resultValidator,
|
|
17
17
|
/** @deprecated Use `vWorkIdValidator` instead. */
|
|
@@ -60,8 +60,7 @@ export declare const vOnComplete: import("convex/values").VObject<{
|
|
|
60
60
|
}, "required", "context" | `context.${string}` | "workId" | "result" | "result.kind" | "result.returnValue" | `result.returnValue.${string}` | "result.error">;
|
|
61
61
|
/** @deprecated Use `vOnCompleteArgs()` instead. */
|
|
62
62
|
export declare const vOnCompleteValidator: typeof vOnCompleteArgs;
|
|
63
|
-
export
|
|
64
|
-
export type WorkpoolComponent = UseApi<Mounts>;
|
|
63
|
+
export type WorkpoolComponent = ComponentApi;
|
|
65
64
|
export declare class Workpool {
|
|
66
65
|
component: WorkpoolComponent;
|
|
67
66
|
options: WorkpoolOptions;
|
|
@@ -418,12 +417,12 @@ export type OnCompleteArgs = {
|
|
|
418
417
|
*/
|
|
419
418
|
result: RunResult;
|
|
420
419
|
};
|
|
421
|
-
export declare function enqueueBatch<FnType extends FunctionType, Args extends DefaultFunctionArgs, ReturnType>(component:
|
|
420
|
+
export declare function enqueueBatch<FnType extends FunctionType, Args extends DefaultFunctionArgs, ReturnType>(component: WorkpoolComponent, ctx: RunMutationCtx, fnType: FnType, fn: FunctionReference<FnType, FunctionVisibility, Args, ReturnType>, fnArgsArray: Array<Args>, options: EnqueueOptions & {
|
|
422
421
|
retryBehavior?: RetryBehavior;
|
|
423
422
|
maxParallelism?: number;
|
|
424
423
|
logLevel?: LogLevel;
|
|
425
424
|
}): Promise<WorkId[]>;
|
|
426
|
-
export declare function enqueue<FnType extends FunctionType, Args extends DefaultFunctionArgs, ReturnType>(component:
|
|
425
|
+
export declare function enqueue<FnType extends FunctionType, Args extends DefaultFunctionArgs, ReturnType>(component: WorkpoolComponent, ctx: RunMutationCtx, fnType: FnType, fn: FunctionReference<FnType, FunctionVisibility, Args, ReturnType>, fnArgs: Args, options: EnqueueOptions & {
|
|
427
426
|
retryBehavior?: RetryBehavior;
|
|
428
427
|
maxParallelism?: number;
|
|
429
428
|
logLevel?: LogLevel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,mBAAmB,EAExB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EAEvB,KAAK,kBAAkB,EACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,KAAK,KAAK,EAEV,KAAK,SAAS,EACd,KAAK,IAAI,EACT,KAAK,OAAO,EACb,MAAM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EAC5B,GAAG,EAAE,cAAc,EACnB,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,iBAAiB,CAAC,MAAM,EAAE,kBAAkB,EAAE,IAAI,EAAE,UAAU,CAAC,EACnE,MAAM,EAAE,IAAI,EACZ,OAAO,EAAE,cAAc,GAAG;IACxB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB,GACA,OAAO,CAAC,MAAM,CAAC,CAOjB"}
|
package/dist/client/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { createFunctionHandle, internalMutationGeneric, } from "convex/server";
|
|
2
2
|
import { v, } from "convex/values";
|
|
3
3
|
import { DEFAULT_LOG_LEVEL } from "../component/logging.js";
|
|
4
|
-
import { DEFAULT_MAX_PARALLELISM, vResultValidator, } from "../component/shared.js";
|
|
4
|
+
import { DEFAULT_MAX_PARALLELISM, DEFAULT_RETRY_BEHAVIOR, vResultValidator, } from "../component/shared.js";
|
|
5
5
|
import { safeFunctionName, } from "./utils.js";
|
|
6
6
|
export { logLevel as vLogLevel } from "../component/logging.js";
|
|
7
7
|
export { retryBehavior as vRetryBehavior } from "../component/shared.js";
|
|
8
8
|
export { vResultValidator };
|
|
9
9
|
export const vWorkIdValidator = v.string();
|
|
10
|
-
export {
|
|
10
|
+
export { DEFAULT_RETRY_BEHAVIOR,
|
|
11
11
|
/** @deprecated Use `vResultValidator` instead. */
|
|
12
12
|
vResultValidator as resultValidator,
|
|
13
13
|
/** @deprecated Use `vWorkIdValidator` instead. */
|
|
@@ -16,12 +16,6 @@ vWorkIdValidator as workIdValidator, };
|
|
|
16
16
|
export const vOnComplete = vOnCompleteArgs(v.any());
|
|
17
17
|
/** @deprecated Use `vOnCompleteArgs()` instead. */
|
|
18
18
|
export const vOnCompleteValidator = vOnCompleteArgs;
|
|
19
|
-
// Attempts will run with delay [0, 250, 500, 1000, 2000] (ms)
|
|
20
|
-
export const DEFAULT_RETRY_BEHAVIOR = {
|
|
21
|
-
maxAttempts: 5,
|
|
22
|
-
initialBackoffMs: 250,
|
|
23
|
-
base: 2,
|
|
24
|
-
};
|
|
25
19
|
export class Workpool {
|
|
26
20
|
component;
|
|
27
21
|
options;
|
package/dist/client/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EAQpB,uBAAuB,GAExB,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,CAAC,GAIF,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,iBAAiB,EAAiB,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAEL,uBAAuB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EAQpB,uBAAuB,GAExB,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,CAAC,GAIF,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,iBAAiB,EAAiB,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAEL,uBAAuB,EACvB,sBAAsB,EAMtB,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAGL,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,QAAQ,IAAI,SAAS,EAAiB,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,aAAa,IAAI,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAsC,CAAC;AAGhE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,EAAqB,CAAC;AAC9D,OAAO,EACL,sBAAsB;AACtB,kDAAkD;AAClD,gBAAgB,IAAI,eAAe;AACnC,kDAAkD;AAClD,gBAAgB,IAAI,eAAe,GACpC,CAAC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O,CAAC,CAAC;QACnC,MAAM;QACN,MAAM;KACP,CAAC,CAAC;IACH,OAAO,EAAY,CAAC;AACtB,CAAC"}
|
package/dist/client/utils.d.ts
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type { GenericId } from "convex/values";
|
|
1
|
+
import { type FunctionArgs, type FunctionReference, type FunctionReturnType, type FunctionType, type FunctionVisibility } from "convex/server";
|
|
3
2
|
export type RunQueryCtx = {
|
|
4
3
|
runQuery: <Query extends FunctionReference<"query", "internal">>(query: Query, args: FunctionArgs<Query>) => Promise<FunctionReturnType<Query>>;
|
|
5
4
|
};
|
|
6
5
|
export type RunMutationCtx = RunQueryCtx & {
|
|
7
6
|
runMutation: <Mutation extends FunctionReference<"mutation", "internal">>(mutation: Mutation, args: FunctionArgs<Mutation>) => Promise<FunctionReturnType<Mutation>>;
|
|
8
7
|
};
|
|
9
|
-
export type OpaqueIds<T> = T extends GenericId<infer _T> ? string : T extends (infer U)[] ? OpaqueIds<U>[] : T extends object ? {
|
|
10
|
-
[K in keyof T]: OpaqueIds<T[K]>;
|
|
11
|
-
} : T;
|
|
12
|
-
export type UseApi<API> = Expand<{
|
|
13
|
-
[mod in keyof API]: API[mod] extends FunctionReference<infer FType, "public", infer FArgs, infer FReturnType, infer FComponentPath> ? FunctionReference<FType, "internal", OpaqueIds<FArgs>, OpaqueIds<FReturnType>, FComponentPath> : UseApi<API[mod]>;
|
|
14
|
-
}>;
|
|
15
8
|
export declare function safeFunctionName(f: FunctionReference<FunctionType, FunctionVisibility>): any;
|
|
16
9
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/client/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/client/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EAGxB,MAAM,eAAe,CAAC;AAIvB,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,CAAC,KAAK,SAAS,iBAAiB,CAAC,OAAO,EAAE,UAAU,CAAC,EAC7D,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,KACtB,OAAO,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;CACzC,CAAC;AACF,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG;IACzC,WAAW,EAAE,CAAC,QAAQ,SAAS,iBAAiB,CAAC,UAAU,EAAE,UAAU,CAAC,EACtE,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,YAAY,CAAC,QAAQ,CAAC,KACzB,OAAO,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC;CAC5C,CAAC;AAEF,wBAAgB,gBAAgB,CAC9B,CAAC,EAAE,iBAAiB,CAAC,YAAY,EAAE,kBAAkB,CAAC,OASvD"}
|
package/dist/client/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/client/utils.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/client/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,kBAAkB,EAClB,eAAe,GAChB,MAAM,eAAe,CAAC;AAiBvB,MAAM,UAAU,gBAAgB,CAC9B,CAAsD;IAEtD,MAAM,OAAO,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC;IACtC,OAAO,CACL,OAAO,CAAC,IAAI;QACZ,OAAO,CAAC,SAAS;QACjB,OAAO,CAAC,cAAc;QACtB,eAAe,CAAC,CAAC,CAAC,CACnB,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
1
|
/**
|
|
3
2
|
* Generated `api` utility.
|
|
4
3
|
*
|
|
@@ -7,7 +6,6 @@
|
|
|
7
6
|
* To regenerate, run `npx convex dev`.
|
|
8
7
|
* @module
|
|
9
8
|
*/
|
|
10
|
-
|
|
11
9
|
import type * as complete from "../complete.js";
|
|
12
10
|
import type * as crons from "../crons.js";
|
|
13
11
|
import type * as danger from "../danger.js";
|
|
@@ -19,133 +17,38 @@ import type * as recovery from "../recovery.js";
|
|
|
19
17
|
import type * as shared from "../shared.js";
|
|
20
18
|
import type * as stats from "../stats.js";
|
|
21
19
|
import type * as worker from "../worker.js";
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
import type { ApiFromModules, FilterApi, FunctionReference } from "convex/server";
|
|
21
|
+
declare const fullApi: ApiFromModules<{
|
|
22
|
+
complete: typeof complete;
|
|
23
|
+
crons: typeof crons;
|
|
24
|
+
danger: typeof danger;
|
|
25
|
+
kick: typeof kick;
|
|
26
|
+
lib: typeof lib;
|
|
27
|
+
logging: typeof logging;
|
|
28
|
+
loop: typeof loop;
|
|
29
|
+
recovery: typeof recovery;
|
|
30
|
+
shared: typeof shared;
|
|
31
|
+
stats: typeof stats;
|
|
32
|
+
worker: typeof worker;
|
|
33
|
+
}>;
|
|
29
34
|
/**
|
|
30
|
-
* A utility for referencing Convex functions in your app's API.
|
|
35
|
+
* A utility for referencing Convex functions in your app's public API.
|
|
31
36
|
*
|
|
32
37
|
* Usage:
|
|
33
38
|
* ```js
|
|
34
39
|
* const myFunctionReference = api.myModule.myFunction;
|
|
35
40
|
* ```
|
|
36
41
|
*/
|
|
37
|
-
declare const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
stats: typeof stats;
|
|
48
|
-
worker: typeof worker;
|
|
49
|
-
}>;
|
|
50
|
-
export type Mounts = {
|
|
51
|
-
lib: {
|
|
52
|
-
cancel: FunctionReference<
|
|
53
|
-
"mutation",
|
|
54
|
-
"public",
|
|
55
|
-
{
|
|
56
|
-
id: string;
|
|
57
|
-
logLevel: "DEBUG" | "TRACE" | "INFO" | "REPORT" | "WARN" | "ERROR";
|
|
58
|
-
},
|
|
59
|
-
any
|
|
60
|
-
>;
|
|
61
|
-
cancelAll: FunctionReference<
|
|
62
|
-
"mutation",
|
|
63
|
-
"public",
|
|
64
|
-
{
|
|
65
|
-
before?: number;
|
|
66
|
-
limit?: number;
|
|
67
|
-
logLevel: "DEBUG" | "TRACE" | "INFO" | "REPORT" | "WARN" | "ERROR";
|
|
68
|
-
},
|
|
69
|
-
any
|
|
70
|
-
>;
|
|
71
|
-
enqueue: FunctionReference<
|
|
72
|
-
"mutation",
|
|
73
|
-
"public",
|
|
74
|
-
{
|
|
75
|
-
config: {
|
|
76
|
-
logLevel: "DEBUG" | "TRACE" | "INFO" | "REPORT" | "WARN" | "ERROR";
|
|
77
|
-
maxParallelism: number;
|
|
78
|
-
};
|
|
79
|
-
fnArgs: any;
|
|
80
|
-
fnHandle: string;
|
|
81
|
-
fnName: string;
|
|
82
|
-
fnType: "action" | "mutation" | "query";
|
|
83
|
-
onComplete?: { context?: any; fnHandle: string };
|
|
84
|
-
retryBehavior?: {
|
|
85
|
-
base: number;
|
|
86
|
-
initialBackoffMs: number;
|
|
87
|
-
maxAttempts: number;
|
|
88
|
-
};
|
|
89
|
-
runAt: number;
|
|
90
|
-
},
|
|
91
|
-
string
|
|
92
|
-
>;
|
|
93
|
-
enqueueBatch: FunctionReference<
|
|
94
|
-
"mutation",
|
|
95
|
-
"public",
|
|
96
|
-
{
|
|
97
|
-
config: {
|
|
98
|
-
logLevel: "DEBUG" | "TRACE" | "INFO" | "REPORT" | "WARN" | "ERROR";
|
|
99
|
-
maxParallelism: number;
|
|
100
|
-
};
|
|
101
|
-
items: Array<{
|
|
102
|
-
fnArgs: any;
|
|
103
|
-
fnHandle: string;
|
|
104
|
-
fnName: string;
|
|
105
|
-
fnType: "action" | "mutation" | "query";
|
|
106
|
-
onComplete?: { context?: any; fnHandle: string };
|
|
107
|
-
retryBehavior?: {
|
|
108
|
-
base: number;
|
|
109
|
-
initialBackoffMs: number;
|
|
110
|
-
maxAttempts: number;
|
|
111
|
-
};
|
|
112
|
-
runAt: number;
|
|
113
|
-
}>;
|
|
114
|
-
},
|
|
115
|
-
Array<string>
|
|
116
|
-
>;
|
|
117
|
-
status: FunctionReference<
|
|
118
|
-
"query",
|
|
119
|
-
"public",
|
|
120
|
-
{ id: string },
|
|
121
|
-
| { previousAttempts: number; state: "pending" }
|
|
122
|
-
| { previousAttempts: number; state: "running" }
|
|
123
|
-
| { state: "finished" }
|
|
124
|
-
>;
|
|
125
|
-
statusBatch: FunctionReference<
|
|
126
|
-
"query",
|
|
127
|
-
"public",
|
|
128
|
-
{ ids: Array<string> },
|
|
129
|
-
Array<
|
|
130
|
-
| { previousAttempts: number; state: "pending" }
|
|
131
|
-
| { previousAttempts: number; state: "running" }
|
|
132
|
-
| { state: "finished" }
|
|
133
|
-
>
|
|
134
|
-
>;
|
|
135
|
-
};
|
|
136
|
-
};
|
|
137
|
-
// For now fullApiWithMounts is only fullApi which provides
|
|
138
|
-
// jump-to-definition in component client code.
|
|
139
|
-
// Use Mounts for the same type without the inference.
|
|
140
|
-
declare const fullApiWithMounts: typeof fullApi;
|
|
141
|
-
|
|
142
|
-
export declare const api: FilterApi<
|
|
143
|
-
typeof fullApiWithMounts,
|
|
144
|
-
FunctionReference<any, "public">
|
|
145
|
-
>;
|
|
146
|
-
export declare const internal: FilterApi<
|
|
147
|
-
typeof fullApiWithMounts,
|
|
148
|
-
FunctionReference<any, "internal">
|
|
149
|
-
>;
|
|
150
|
-
|
|
42
|
+
export declare const api: FilterApi<typeof fullApi, FunctionReference<any, "public">>;
|
|
43
|
+
/**
|
|
44
|
+
* A utility for referencing Convex functions in your app's internal API.
|
|
45
|
+
*
|
|
46
|
+
* Usage:
|
|
47
|
+
* ```js
|
|
48
|
+
* const myFunctionReference = internal.myModule.myFunction;
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare const internal: FilterApi<typeof fullApi, FunctionReference<any, "internal">>;
|
|
151
52
|
export declare const components: {};
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=api.d.ts.map
|