@convex-dev/workpool 0.2.7-alpha.2 → 0.2.7-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/client/index.d.ts +47 -81
- package/dist/commonjs/client/index.d.ts.map +1 -1
- package/dist/commonjs/client/index.js +1 -1
- package/dist/commonjs/client/index.js.map +1 -1
- package/dist/esm/client/index.d.ts +47 -81
- package/dist/esm/client/index.d.ts.map +1 -1
- package/dist/esm/client/index.js +1 -1
- package/dist/esm/client/index.js.map +1 -1
- package/package.json +1 -1
- package/src/client/index.ts +49 -59
|
@@ -14,33 +14,50 @@ export type WorkId = string & {
|
|
|
14
14
|
};
|
|
15
15
|
export declare const workIdValidator: VString<WorkId, "required">;
|
|
16
16
|
export { workIdValidator as vWorkIdValidator };
|
|
17
|
+
export type NameOption = {
|
|
18
|
+
/**
|
|
19
|
+
* The name of the function. By default, if you pass in api.foo.bar.baz,
|
|
20
|
+
* it will use "foo/bar:baz" as the name. If you pass in a function handle,
|
|
21
|
+
* it will use the function handle directly.
|
|
22
|
+
*/
|
|
23
|
+
name?: string;
|
|
24
|
+
};
|
|
25
|
+
export type RetryOption = {
|
|
26
|
+
/** Whether to retry the action if it fails.
|
|
27
|
+
* If true, it will use the default retry behavior.
|
|
28
|
+
* If custom behavior is provided, it will retry using that behavior.
|
|
29
|
+
* If unset, it will use the Workpool's configured default.
|
|
30
|
+
*/
|
|
31
|
+
retry?: boolean | RetryBehavior;
|
|
32
|
+
};
|
|
33
|
+
export type WorkpoolOptions = {
|
|
34
|
+
/** How many actions/mutations can be running at once within this pool.
|
|
35
|
+
* Min 1, Max 300.
|
|
36
|
+
*/
|
|
37
|
+
maxParallelism?: number;
|
|
38
|
+
/** How much to log. This is updated on each call to `enqueue*`,
|
|
39
|
+
* `status`, or `cancel*`.
|
|
40
|
+
* Default is REPORT, which logs warnings, errors, and a periodic report.
|
|
41
|
+
* With INFO, you can also see events for started and completed work.
|
|
42
|
+
* Stats generated can be parsed by tools like
|
|
43
|
+
* [Axiom](https://axiom.co) for monitoring.
|
|
44
|
+
* With DEBUG, you can see timers and internal events for work being
|
|
45
|
+
* scheduled.
|
|
46
|
+
*/
|
|
47
|
+
logLevel?: LogLevel;
|
|
48
|
+
/** Default retry behavior for enqueued actions.
|
|
49
|
+
* See {@link RetryBehavior}.
|
|
50
|
+
*/
|
|
51
|
+
defaultRetryBehavior?: RetryBehavior;
|
|
52
|
+
/** Whether to retry actions that fail by default. Default: false.
|
|
53
|
+
* NOTE: Only enable this if your actions are idempotent.
|
|
54
|
+
* See the docs (README.md) for more details.
|
|
55
|
+
*/
|
|
56
|
+
retryActionsByDefault?: boolean;
|
|
57
|
+
};
|
|
17
58
|
export declare class Workpool {
|
|
18
59
|
private component;
|
|
19
|
-
options:
|
|
20
|
-
/** How many actions/mutations can be running at once within this pool.
|
|
21
|
-
* Min 1, Max 300.
|
|
22
|
-
*/
|
|
23
|
-
maxParallelism?: number;
|
|
24
|
-
/** How much to log. This is updated on each call to `enqueue*`,
|
|
25
|
-
* `status`, or `cancel*`.
|
|
26
|
-
* Default is REPORT, which logs warnings, errors, and a periodic report.
|
|
27
|
-
* With INFO, you can also see events for started and completed work.
|
|
28
|
-
* Stats generated can be parsed by tools like
|
|
29
|
-
* [Axiom](https://axiom.co) for monitoring.
|
|
30
|
-
* With DEBUG, you can see timers and internal events for work being
|
|
31
|
-
* scheduled.
|
|
32
|
-
*/
|
|
33
|
-
logLevel?: LogLevel;
|
|
34
|
-
/** Default retry behavior for enqueued actions.
|
|
35
|
-
* See {@link RetryBehavior}.
|
|
36
|
-
*/
|
|
37
|
-
defaultRetryBehavior?: RetryBehavior;
|
|
38
|
-
/** Whether to retry actions that fail by default. Default: false.
|
|
39
|
-
* NOTE: Only enable this if your actions are idempotent.
|
|
40
|
-
* See the docs (README.md) for more details.
|
|
41
|
-
*/
|
|
42
|
-
retryActionsByDefault?: boolean;
|
|
43
|
-
};
|
|
60
|
+
options: WorkpoolOptions;
|
|
44
61
|
/**
|
|
45
62
|
* Initializes a Workpool.
|
|
46
63
|
*
|
|
@@ -50,34 +67,10 @@ export declare class Workpool {
|
|
|
50
67
|
*
|
|
51
68
|
* @param component - The component to use, like `components.workpool` from
|
|
52
69
|
* `./_generated/api.ts`.
|
|
53
|
-
* @param options - The
|
|
70
|
+
* @param options - The {@link WorkpoolOptions} for the Workpool.
|
|
54
71
|
*/
|
|
55
72
|
constructor(component: UseApi<Mounts>, // UseApi<api> for jump to definition
|
|
56
|
-
options:
|
|
57
|
-
/** How many actions/mutations can be running at once within this pool.
|
|
58
|
-
* Min 1, Max 300.
|
|
59
|
-
*/
|
|
60
|
-
maxParallelism?: number;
|
|
61
|
-
/** How much to log. This is updated on each call to `enqueue*`,
|
|
62
|
-
* `status`, or `cancel*`.
|
|
63
|
-
* Default is REPORT, which logs warnings, errors, and a periodic report.
|
|
64
|
-
* With INFO, you can also see events for started and completed work.
|
|
65
|
-
* Stats generated can be parsed by tools like
|
|
66
|
-
* [Axiom](https://axiom.co) for monitoring.
|
|
67
|
-
* With DEBUG, you can see timers and internal events for work being
|
|
68
|
-
* scheduled.
|
|
69
|
-
*/
|
|
70
|
-
logLevel?: LogLevel;
|
|
71
|
-
/** Default retry behavior for enqueued actions.
|
|
72
|
-
* See {@link RetryBehavior}.
|
|
73
|
-
*/
|
|
74
|
-
defaultRetryBehavior?: RetryBehavior;
|
|
75
|
-
/** Whether to retry actions that fail by default. Default: false.
|
|
76
|
-
* NOTE: Only enable this if your actions are idempotent.
|
|
77
|
-
* See the docs (README.md) for more details.
|
|
78
|
-
*/
|
|
79
|
-
retryActionsByDefault?: boolean;
|
|
80
|
-
});
|
|
73
|
+
options: WorkpoolOptions);
|
|
81
74
|
/**
|
|
82
75
|
* Enqueues an action to be run.
|
|
83
76
|
*
|
|
@@ -88,20 +81,7 @@ export declare class Workpool {
|
|
|
88
81
|
* onComplete handling, and scheduling via `runAt` or `runAfter`.
|
|
89
82
|
* @returns The ID of the work that was enqueued.
|
|
90
83
|
*/
|
|
91
|
-
enqueueAction<Args extends DefaultFunctionArgs, ReturnType>(ctx: RunMutationCtx, fn: FunctionReference<"action", FunctionVisibility, Args, ReturnType>, fnArgs: Args, options?:
|
|
92
|
-
/** Whether to retry the action if it fails.
|
|
93
|
-
* If true, it will use the default retry behavior.
|
|
94
|
-
* If custom behavior is provided, it will retry using that behavior.
|
|
95
|
-
* If unset, it will use the Workpool's configured default.
|
|
96
|
-
*/
|
|
97
|
-
retry?: boolean | RetryBehavior;
|
|
98
|
-
/**
|
|
99
|
-
* The name of the function. By default, if you pass in api.foo.bar.baz,
|
|
100
|
-
* it will use "foo/bar:baz" as the name. If you pass in a function handle,
|
|
101
|
-
* it will use the function handle directly.
|
|
102
|
-
*/
|
|
103
|
-
name?: string;
|
|
104
|
-
} & CallbackOptions & SchedulerOptions): Promise<WorkId>;
|
|
84
|
+
enqueueAction<Args extends DefaultFunctionArgs, ReturnType>(ctx: RunMutationCtx, fn: FunctionReference<"action", FunctionVisibility, Args, ReturnType>, fnArgs: Args, options?: RetryOption & CallbackOptions & SchedulerOptions & NameOption): Promise<WorkId>;
|
|
105
85
|
/**
|
|
106
86
|
* Enqueues a mutation to be run.
|
|
107
87
|
*
|
|
@@ -115,22 +95,8 @@ export declare class Workpool {
|
|
|
115
95
|
* @param options - The options for the mutation to specify onComplete handling
|
|
116
96
|
* and scheduling via `runAt` or `runAfter`.
|
|
117
97
|
*/
|
|
118
|
-
enqueueMutation<Args extends DefaultFunctionArgs, ReturnType>(ctx: RunMutationCtx, fn: FunctionReference<"mutation", FunctionVisibility, Args, ReturnType>, fnArgs: Args, options?: CallbackOptions & SchedulerOptions &
|
|
119
|
-
|
|
120
|
-
* The name of the function. By default, if you pass in api.foo.bar.baz,
|
|
121
|
-
* it will use "foo/bar:baz" as the name. If you pass in a function handle,
|
|
122
|
-
* it will use the function handle directly.
|
|
123
|
-
*/
|
|
124
|
-
name?: string;
|
|
125
|
-
}): Promise<WorkId>;
|
|
126
|
-
enqueueQuery<Args extends DefaultFunctionArgs, ReturnType>(ctx: RunMutationCtx, fn: FunctionReference<"query", FunctionVisibility, Args, ReturnType>, fnArgs: Args, options?: CallbackOptions & SchedulerOptions & {
|
|
127
|
-
/**
|
|
128
|
-
* The name of the function. By default, if you pass in api.foo.bar.baz,
|
|
129
|
-
* it will use "foo/bar:baz" as the name. If you pass in a function handle,
|
|
130
|
-
* it will use the function handle directly.
|
|
131
|
-
*/
|
|
132
|
-
name?: string;
|
|
133
|
-
}): Promise<WorkId>;
|
|
98
|
+
enqueueMutation<Args extends DefaultFunctionArgs, ReturnType>(ctx: RunMutationCtx, fn: FunctionReference<"mutation", FunctionVisibility, Args, ReturnType>, fnArgs: Args, options?: CallbackOptions & SchedulerOptions & NameOption): Promise<WorkId>;
|
|
99
|
+
enqueueQuery<Args extends DefaultFunctionArgs, ReturnType>(ctx: RunMutationCtx, fn: FunctionReference<"query", FunctionVisibility, Args, ReturnType>, fnArgs: Args, options?: CallbackOptions & SchedulerOptions & NameOption): Promise<WorkId>;
|
|
134
100
|
/**
|
|
135
101
|
* Cancels a work item. If it's already started, it will be allowed to finish
|
|
136
102
|
* but will not be retried.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,EAEnB,iBAAiB,EAEjB,kBAAkB,EAEnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AACxD,OAAO,EAEL,KAAK,QAAQ,EAEd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAIL,SAAS,IAAI,eAAe,EAC5B,KAAK,aAAa,EAClB,SAAS,EAET,MAAM,EACP,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM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,cAAc,GAAG;IAC3B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,MAAM,EAAE,SAAS,CAAC;CACnB,CAAC"}
|
|
@@ -26,7 +26,7 @@ export class Workpool {
|
|
|
26
26
|
*
|
|
27
27
|
* @param component - The component to use, like `components.workpool` from
|
|
28
28
|
* `./_generated/api.ts`.
|
|
29
|
-
* @param options - The
|
|
29
|
+
* @param options - The {@link WorkpoolOptions} for the Workpool.
|
|
30
30
|
*/
|
|
31
31
|
constructor(component, // UseApi<api> for jump to definition
|
|
32
32
|
options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EAMpB,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,CAAC,EAAW,MAAM,eAAe,CAAC;AAE3C,OAAO,EACL,iBAAiB,GAGlB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,uBAAuB,EAEvB,SAAS,IAAI,eAAe,GAK7B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,eAAe,EAAsC,CAAC;AAC/D,OAAO,EAAE,aAAa,IAAI,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,QAAQ,IAAI,SAAS,EAAiB,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,eAAe,IAAI,gBAAgB,EAAE,CAAC;AAE/C,8DAA8D;AAC9D,MAAM,CAAC,MAAM,sBAAsB,GAAkB;IACnD,WAAW,EAAE,CAAC;IACd,gBAAgB,EAAE,GAAG;IACrB,IAAI,EAAE,CAAC;CACR,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,EAAqB,CAAC;AAC7D,OAAO,EAAE,eAAe,IAAI,gBAAgB,EAAE,CAAC;
|
|
1
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AK,KAAK,SAAS,EAAE;QACrD,OAAO,OAAO,CAAC,KAAK,CAAC;KACtB;IACD,IAAI,UAAU,IAAI,OAAO,IAAI,OAAO,CAAC,QAAQ,KAAK,SAAS,EAAE;QAC3D,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC;KACtC;IACD,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC;AACpB,CAAC"}
|
|
@@ -14,33 +14,50 @@ export type WorkId = string & {
|
|
|
14
14
|
};
|
|
15
15
|
export declare const workIdValidator: VString<WorkId, "required">;
|
|
16
16
|
export { workIdValidator as vWorkIdValidator };
|
|
17
|
+
export type NameOption = {
|
|
18
|
+
/**
|
|
19
|
+
* The name of the function. By default, if you pass in api.foo.bar.baz,
|
|
20
|
+
* it will use "foo/bar:baz" as the name. If you pass in a function handle,
|
|
21
|
+
* it will use the function handle directly.
|
|
22
|
+
*/
|
|
23
|
+
name?: string;
|
|
24
|
+
};
|
|
25
|
+
export type RetryOption = {
|
|
26
|
+
/** Whether to retry the action if it fails.
|
|
27
|
+
* If true, it will use the default retry behavior.
|
|
28
|
+
* If custom behavior is provided, it will retry using that behavior.
|
|
29
|
+
* If unset, it will use the Workpool's configured default.
|
|
30
|
+
*/
|
|
31
|
+
retry?: boolean | RetryBehavior;
|
|
32
|
+
};
|
|
33
|
+
export type WorkpoolOptions = {
|
|
34
|
+
/** How many actions/mutations can be running at once within this pool.
|
|
35
|
+
* Min 1, Max 300.
|
|
36
|
+
*/
|
|
37
|
+
maxParallelism?: number;
|
|
38
|
+
/** How much to log. This is updated on each call to `enqueue*`,
|
|
39
|
+
* `status`, or `cancel*`.
|
|
40
|
+
* Default is REPORT, which logs warnings, errors, and a periodic report.
|
|
41
|
+
* With INFO, you can also see events for started and completed work.
|
|
42
|
+
* Stats generated can be parsed by tools like
|
|
43
|
+
* [Axiom](https://axiom.co) for monitoring.
|
|
44
|
+
* With DEBUG, you can see timers and internal events for work being
|
|
45
|
+
* scheduled.
|
|
46
|
+
*/
|
|
47
|
+
logLevel?: LogLevel;
|
|
48
|
+
/** Default retry behavior for enqueued actions.
|
|
49
|
+
* See {@link RetryBehavior}.
|
|
50
|
+
*/
|
|
51
|
+
defaultRetryBehavior?: RetryBehavior;
|
|
52
|
+
/** Whether to retry actions that fail by default. Default: false.
|
|
53
|
+
* NOTE: Only enable this if your actions are idempotent.
|
|
54
|
+
* See the docs (README.md) for more details.
|
|
55
|
+
*/
|
|
56
|
+
retryActionsByDefault?: boolean;
|
|
57
|
+
};
|
|
17
58
|
export declare class Workpool {
|
|
18
59
|
private component;
|
|
19
|
-
options:
|
|
20
|
-
/** How many actions/mutations can be running at once within this pool.
|
|
21
|
-
* Min 1, Max 300.
|
|
22
|
-
*/
|
|
23
|
-
maxParallelism?: number;
|
|
24
|
-
/** How much to log. This is updated on each call to `enqueue*`,
|
|
25
|
-
* `status`, or `cancel*`.
|
|
26
|
-
* Default is REPORT, which logs warnings, errors, and a periodic report.
|
|
27
|
-
* With INFO, you can also see events for started and completed work.
|
|
28
|
-
* Stats generated can be parsed by tools like
|
|
29
|
-
* [Axiom](https://axiom.co) for monitoring.
|
|
30
|
-
* With DEBUG, you can see timers and internal events for work being
|
|
31
|
-
* scheduled.
|
|
32
|
-
*/
|
|
33
|
-
logLevel?: LogLevel;
|
|
34
|
-
/** Default retry behavior for enqueued actions.
|
|
35
|
-
* See {@link RetryBehavior}.
|
|
36
|
-
*/
|
|
37
|
-
defaultRetryBehavior?: RetryBehavior;
|
|
38
|
-
/** Whether to retry actions that fail by default. Default: false.
|
|
39
|
-
* NOTE: Only enable this if your actions are idempotent.
|
|
40
|
-
* See the docs (README.md) for more details.
|
|
41
|
-
*/
|
|
42
|
-
retryActionsByDefault?: boolean;
|
|
43
|
-
};
|
|
60
|
+
options: WorkpoolOptions;
|
|
44
61
|
/**
|
|
45
62
|
* Initializes a Workpool.
|
|
46
63
|
*
|
|
@@ -50,34 +67,10 @@ export declare class Workpool {
|
|
|
50
67
|
*
|
|
51
68
|
* @param component - The component to use, like `components.workpool` from
|
|
52
69
|
* `./_generated/api.ts`.
|
|
53
|
-
* @param options - The
|
|
70
|
+
* @param options - The {@link WorkpoolOptions} for the Workpool.
|
|
54
71
|
*/
|
|
55
72
|
constructor(component: UseApi<Mounts>, // UseApi<api> for jump to definition
|
|
56
|
-
options:
|
|
57
|
-
/** How many actions/mutations can be running at once within this pool.
|
|
58
|
-
* Min 1, Max 300.
|
|
59
|
-
*/
|
|
60
|
-
maxParallelism?: number;
|
|
61
|
-
/** How much to log. This is updated on each call to `enqueue*`,
|
|
62
|
-
* `status`, or `cancel*`.
|
|
63
|
-
* Default is REPORT, which logs warnings, errors, and a periodic report.
|
|
64
|
-
* With INFO, you can also see events for started and completed work.
|
|
65
|
-
* Stats generated can be parsed by tools like
|
|
66
|
-
* [Axiom](https://axiom.co) for monitoring.
|
|
67
|
-
* With DEBUG, you can see timers and internal events for work being
|
|
68
|
-
* scheduled.
|
|
69
|
-
*/
|
|
70
|
-
logLevel?: LogLevel;
|
|
71
|
-
/** Default retry behavior for enqueued actions.
|
|
72
|
-
* See {@link RetryBehavior}.
|
|
73
|
-
*/
|
|
74
|
-
defaultRetryBehavior?: RetryBehavior;
|
|
75
|
-
/** Whether to retry actions that fail by default. Default: false.
|
|
76
|
-
* NOTE: Only enable this if your actions are idempotent.
|
|
77
|
-
* See the docs (README.md) for more details.
|
|
78
|
-
*/
|
|
79
|
-
retryActionsByDefault?: boolean;
|
|
80
|
-
});
|
|
73
|
+
options: WorkpoolOptions);
|
|
81
74
|
/**
|
|
82
75
|
* Enqueues an action to be run.
|
|
83
76
|
*
|
|
@@ -88,20 +81,7 @@ export declare class Workpool {
|
|
|
88
81
|
* onComplete handling, and scheduling via `runAt` or `runAfter`.
|
|
89
82
|
* @returns The ID of the work that was enqueued.
|
|
90
83
|
*/
|
|
91
|
-
enqueueAction<Args extends DefaultFunctionArgs, ReturnType>(ctx: RunMutationCtx, fn: FunctionReference<"action", FunctionVisibility, Args, ReturnType>, fnArgs: Args, options?:
|
|
92
|
-
/** Whether to retry the action if it fails.
|
|
93
|
-
* If true, it will use the default retry behavior.
|
|
94
|
-
* If custom behavior is provided, it will retry using that behavior.
|
|
95
|
-
* If unset, it will use the Workpool's configured default.
|
|
96
|
-
*/
|
|
97
|
-
retry?: boolean | RetryBehavior;
|
|
98
|
-
/**
|
|
99
|
-
* The name of the function. By default, if you pass in api.foo.bar.baz,
|
|
100
|
-
* it will use "foo/bar:baz" as the name. If you pass in a function handle,
|
|
101
|
-
* it will use the function handle directly.
|
|
102
|
-
*/
|
|
103
|
-
name?: string;
|
|
104
|
-
} & CallbackOptions & SchedulerOptions): Promise<WorkId>;
|
|
84
|
+
enqueueAction<Args extends DefaultFunctionArgs, ReturnType>(ctx: RunMutationCtx, fn: FunctionReference<"action", FunctionVisibility, Args, ReturnType>, fnArgs: Args, options?: RetryOption & CallbackOptions & SchedulerOptions & NameOption): Promise<WorkId>;
|
|
105
85
|
/**
|
|
106
86
|
* Enqueues a mutation to be run.
|
|
107
87
|
*
|
|
@@ -115,22 +95,8 @@ export declare class Workpool {
|
|
|
115
95
|
* @param options - The options for the mutation to specify onComplete handling
|
|
116
96
|
* and scheduling via `runAt` or `runAfter`.
|
|
117
97
|
*/
|
|
118
|
-
enqueueMutation<Args extends DefaultFunctionArgs, ReturnType>(ctx: RunMutationCtx, fn: FunctionReference<"mutation", FunctionVisibility, Args, ReturnType>, fnArgs: Args, options?: CallbackOptions & SchedulerOptions &
|
|
119
|
-
|
|
120
|
-
* The name of the function. By default, if you pass in api.foo.bar.baz,
|
|
121
|
-
* it will use "foo/bar:baz" as the name. If you pass in a function handle,
|
|
122
|
-
* it will use the function handle directly.
|
|
123
|
-
*/
|
|
124
|
-
name?: string;
|
|
125
|
-
}): Promise<WorkId>;
|
|
126
|
-
enqueueQuery<Args extends DefaultFunctionArgs, ReturnType>(ctx: RunMutationCtx, fn: FunctionReference<"query", FunctionVisibility, Args, ReturnType>, fnArgs: Args, options?: CallbackOptions & SchedulerOptions & {
|
|
127
|
-
/**
|
|
128
|
-
* The name of the function. By default, if you pass in api.foo.bar.baz,
|
|
129
|
-
* it will use "foo/bar:baz" as the name. If you pass in a function handle,
|
|
130
|
-
* it will use the function handle directly.
|
|
131
|
-
*/
|
|
132
|
-
name?: string;
|
|
133
|
-
}): Promise<WorkId>;
|
|
98
|
+
enqueueMutation<Args extends DefaultFunctionArgs, ReturnType>(ctx: RunMutationCtx, fn: FunctionReference<"mutation", FunctionVisibility, Args, ReturnType>, fnArgs: Args, options?: CallbackOptions & SchedulerOptions & NameOption): Promise<WorkId>;
|
|
99
|
+
enqueueQuery<Args extends DefaultFunctionArgs, ReturnType>(ctx: RunMutationCtx, fn: FunctionReference<"query", FunctionVisibility, Args, ReturnType>, fnArgs: Args, options?: CallbackOptions & SchedulerOptions & NameOption): Promise<WorkId>;
|
|
134
100
|
/**
|
|
135
101
|
* Cancels a work item. If it's already started, it will be allowed to finish
|
|
136
102
|
* but will not be retried.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,EAEnB,iBAAiB,EAEjB,kBAAkB,EAEnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AACxD,OAAO,EAEL,KAAK,QAAQ,EAEd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAIL,SAAS,IAAI,eAAe,EAC5B,KAAK,aAAa,EAClB,SAAS,EAET,MAAM,EACP,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAE,CAAC;AAC/D,OAAO,EAAE,aAA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M,EAAE,SAAS,CAAC;CACnB,CAAC"}
|
package/dist/esm/client/index.js
CHANGED
|
@@ -26,7 +26,7 @@ export class Workpool {
|
|
|
26
26
|
*
|
|
27
27
|
* @param component - The component to use, like `components.workpool` from
|
|
28
28
|
* `./_generated/api.ts`.
|
|
29
|
-
* @param options - The
|
|
29
|
+
* @param options - The {@link WorkpoolOptions} for the Workpool.
|
|
30
30
|
*/
|
|
31
31
|
constructor(component, // UseApi<api> for jump to definition
|
|
32
32
|
options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EAMpB,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,CAAC,EAAW,MAAM,eAAe,CAAC;AAE3C,OAAO,EACL,iBAAiB,GAGlB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,uBAAuB,EAEvB,SAAS,IAAI,eAAe,GAK7B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,eAAe,EAAsC,CAAC;AAC/D,OAAO,EAAE,aAAa,IAAI,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,QAAQ,IAAI,SAAS,EAAiB,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,eAAe,IAAI,gBAAgB,EAAE,CAAC;AAE/C,8DAA8D;AAC9D,MAAM,CAAC,MAAM,sBAAsB,GAAkB;IACnD,WAAW,EAAE,CAAC;IACd,gBAAgB,EAAE,GAAG;IACrB,IAAI,EAAE,CAAC;CACR,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,EAAqB,CAAC;AAC7D,OAAO,EAAE,eAAe,IAAI,gBAAgB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EAMp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I,OAAO,CAAC,QAAQ,KAAK,SAAS,EAAE;QAC3D,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC;KACtC;IACD,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC;AACpB,CAAC"}
|
package/package.json
CHANGED
package/src/client/index.ts
CHANGED
|
@@ -40,6 +40,50 @@ export type WorkId = string & { __isWorkId: true };
|
|
|
40
40
|
export const workIdValidator = v.string() as VString<WorkId>;
|
|
41
41
|
export { workIdValidator as vWorkIdValidator };
|
|
42
42
|
|
|
43
|
+
export type NameOption = {
|
|
44
|
+
/**
|
|
45
|
+
* The name of the function. By default, if you pass in api.foo.bar.baz,
|
|
46
|
+
* it will use "foo/bar:baz" as the name. If you pass in a function handle,
|
|
47
|
+
* it will use the function handle directly.
|
|
48
|
+
*/
|
|
49
|
+
name?: string;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type RetryOption = {
|
|
53
|
+
/** Whether to retry the action if it fails.
|
|
54
|
+
* If true, it will use the default retry behavior.
|
|
55
|
+
* If custom behavior is provided, it will retry using that behavior.
|
|
56
|
+
* If unset, it will use the Workpool's configured default.
|
|
57
|
+
*/
|
|
58
|
+
retry?: boolean | RetryBehavior;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export type WorkpoolOptions = {
|
|
62
|
+
/** How many actions/mutations can be running at once within this pool.
|
|
63
|
+
* Min 1, Max 300.
|
|
64
|
+
*/
|
|
65
|
+
maxParallelism?: number;
|
|
66
|
+
/** How much to log. This is updated on each call to `enqueue*`,
|
|
67
|
+
* `status`, or `cancel*`.
|
|
68
|
+
* Default is REPORT, which logs warnings, errors, and a periodic report.
|
|
69
|
+
* With INFO, you can also see events for started and completed work.
|
|
70
|
+
* Stats generated can be parsed by tools like
|
|
71
|
+
* [Axiom](https://axiom.co) for monitoring.
|
|
72
|
+
* With DEBUG, you can see timers and internal events for work being
|
|
73
|
+
* scheduled.
|
|
74
|
+
*/
|
|
75
|
+
logLevel?: LogLevel;
|
|
76
|
+
/** Default retry behavior for enqueued actions.
|
|
77
|
+
* See {@link RetryBehavior}.
|
|
78
|
+
*/
|
|
79
|
+
defaultRetryBehavior?: RetryBehavior;
|
|
80
|
+
/** Whether to retry actions that fail by default. Default: false.
|
|
81
|
+
* NOTE: Only enable this if your actions are idempotent.
|
|
82
|
+
* See the docs (README.md) for more details.
|
|
83
|
+
*/
|
|
84
|
+
retryActionsByDefault?: boolean;
|
|
85
|
+
};
|
|
86
|
+
|
|
43
87
|
export class Workpool {
|
|
44
88
|
/**
|
|
45
89
|
* Initializes a Workpool.
|
|
@@ -50,35 +94,11 @@ export class Workpool {
|
|
|
50
94
|
*
|
|
51
95
|
* @param component - The component to use, like `components.workpool` from
|
|
52
96
|
* `./_generated/api.ts`.
|
|
53
|
-
* @param options - The
|
|
97
|
+
* @param options - The {@link WorkpoolOptions} for the Workpool.
|
|
54
98
|
*/
|
|
55
99
|
constructor(
|
|
56
100
|
private component: UseApi<Mounts>, // UseApi<api> for jump to definition
|
|
57
|
-
public options:
|
|
58
|
-
/** How many actions/mutations can be running at once within this pool.
|
|
59
|
-
* Min 1, Max 300.
|
|
60
|
-
*/
|
|
61
|
-
maxParallelism?: number;
|
|
62
|
-
/** How much to log. This is updated on each call to `enqueue*`,
|
|
63
|
-
* `status`, or `cancel*`.
|
|
64
|
-
* Default is REPORT, which logs warnings, errors, and a periodic report.
|
|
65
|
-
* With INFO, you can also see events for started and completed work.
|
|
66
|
-
* Stats generated can be parsed by tools like
|
|
67
|
-
* [Axiom](https://axiom.co) for monitoring.
|
|
68
|
-
* With DEBUG, you can see timers and internal events for work being
|
|
69
|
-
* scheduled.
|
|
70
|
-
*/
|
|
71
|
-
logLevel?: LogLevel;
|
|
72
|
-
/** Default retry behavior for enqueued actions.
|
|
73
|
-
* See {@link RetryBehavior}.
|
|
74
|
-
*/
|
|
75
|
-
defaultRetryBehavior?: RetryBehavior;
|
|
76
|
-
/** Whether to retry actions that fail by default. Default: false.
|
|
77
|
-
* NOTE: Only enable this if your actions are idempotent.
|
|
78
|
-
* See the docs (README.md) for more details.
|
|
79
|
-
*/
|
|
80
|
-
retryActionsByDefault?: boolean;
|
|
81
|
-
}
|
|
101
|
+
public options: WorkpoolOptions
|
|
82
102
|
) {}
|
|
83
103
|
/**
|
|
84
104
|
* Enqueues an action to be run.
|
|
@@ -94,21 +114,7 @@ export class Workpool {
|
|
|
94
114
|
ctx: RunMutationCtx,
|
|
95
115
|
fn: FunctionReference<"action", FunctionVisibility, Args, ReturnType>,
|
|
96
116
|
fnArgs: Args,
|
|
97
|
-
options?:
|
|
98
|
-
/** Whether to retry the action if it fails.
|
|
99
|
-
* If true, it will use the default retry behavior.
|
|
100
|
-
* If custom behavior is provided, it will retry using that behavior.
|
|
101
|
-
* If unset, it will use the Workpool's configured default.
|
|
102
|
-
*/
|
|
103
|
-
retry?: boolean | RetryBehavior;
|
|
104
|
-
/**
|
|
105
|
-
* The name of the function. By default, if you pass in api.foo.bar.baz,
|
|
106
|
-
* it will use "foo/bar:baz" as the name. If you pass in a function handle,
|
|
107
|
-
* it will use the function handle directly.
|
|
108
|
-
*/
|
|
109
|
-
name?: string;
|
|
110
|
-
} & CallbackOptions &
|
|
111
|
-
SchedulerOptions
|
|
117
|
+
options?: RetryOption & CallbackOptions & SchedulerOptions & NameOption
|
|
112
118
|
): Promise<WorkId> {
|
|
113
119
|
const retryBehavior = getRetryBehavior(
|
|
114
120
|
this.options.defaultRetryBehavior,
|
|
@@ -149,15 +155,7 @@ export class Workpool {
|
|
|
149
155
|
ctx: RunMutationCtx,
|
|
150
156
|
fn: FunctionReference<"mutation", FunctionVisibility, Args, ReturnType>,
|
|
151
157
|
fnArgs: Args,
|
|
152
|
-
options?: CallbackOptions &
|
|
153
|
-
SchedulerOptions & {
|
|
154
|
-
/**
|
|
155
|
-
* The name of the function. By default, if you pass in api.foo.bar.baz,
|
|
156
|
-
* it will use "foo/bar:baz" as the name. If you pass in a function handle,
|
|
157
|
-
* it will use the function handle directly.
|
|
158
|
-
*/
|
|
159
|
-
name?: string;
|
|
160
|
-
}
|
|
158
|
+
options?: CallbackOptions & SchedulerOptions & NameOption
|
|
161
159
|
): Promise<WorkId> {
|
|
162
160
|
const onComplete: OnComplete | undefined = options?.onComplete
|
|
163
161
|
? {
|
|
@@ -179,15 +177,7 @@ export class Workpool {
|
|
|
179
177
|
ctx: RunMutationCtx,
|
|
180
178
|
fn: FunctionReference<"query", FunctionVisibility, Args, ReturnType>,
|
|
181
179
|
fnArgs: Args,
|
|
182
|
-
options?: CallbackOptions &
|
|
183
|
-
SchedulerOptions & {
|
|
184
|
-
/**
|
|
185
|
-
* The name of the function. By default, if you pass in api.foo.bar.baz,
|
|
186
|
-
* it will use "foo/bar:baz" as the name. If you pass in a function handle,
|
|
187
|
-
* it will use the function handle directly.
|
|
188
|
-
*/
|
|
189
|
-
name?: string;
|
|
190
|
-
}
|
|
180
|
+
options?: CallbackOptions & SchedulerOptions & NameOption
|
|
191
181
|
): Promise<WorkId> {
|
|
192
182
|
const onComplete: OnComplete | undefined = options?.onComplete
|
|
193
183
|
? {
|