@resonatehq/sdk 0.3.6 → 0.5.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 +24 -123
- package/dist/async.d.ts +95 -49
- package/dist/async.d.ts.map +1 -1
- package/dist/async.js +167 -100
- package/dist/async.js.map +1 -1
- package/dist/core/execution.d.ts +12 -10
- package/dist/core/execution.d.ts.map +1 -1
- package/dist/core/execution.js +124 -65
- package/dist/core/execution.js.map +1 -1
- package/dist/core/future.d.ts +3 -1
- package/dist/core/future.d.ts.map +1 -1
- package/dist/core/future.js +6 -0
- package/dist/core/future.js.map +1 -1
- package/dist/core/invocation.d.ts +5 -4
- package/dist/core/invocation.d.ts.map +1 -1
- package/dist/core/invocation.js +39 -13
- package/dist/core/invocation.js.map +1 -1
- package/dist/core/options.d.ts +32 -11
- package/dist/core/options.d.ts.map +1 -1
- package/dist/core/options.js +3 -3
- package/dist/core/options.js.map +1 -1
- package/dist/core/promises/promises.d.ts +3 -2
- package/dist/core/promises/promises.d.ts.map +1 -1
- package/dist/core/promises/promises.js +4 -1
- package/dist/core/promises/promises.js.map +1 -1
- package/dist/core/promises/types.d.ts.map +1 -1
- package/dist/core/promises/types.js +2 -5
- package/dist/core/promises/types.js.map +1 -1
- package/dist/core/schedules/schedules.d.ts +22 -0
- package/dist/core/schedules/schedules.d.ts.map +1 -0
- package/dist/core/schedules/schedules.js +29 -0
- package/dist/core/schedules/schedules.js.map +1 -0
- package/dist/core/store.d.ts +5 -2
- package/dist/core/store.d.ts.map +1 -1
- package/dist/core/stores/local.d.ts +1 -1
- package/dist/core/stores/local.d.ts.map +1 -1
- package/dist/core/stores/local.js +7 -5
- package/dist/core/stores/local.js.map +1 -1
- package/dist/core/stores/remote.d.ts +7 -7
- package/dist/core/stores/remote.d.ts.map +1 -1
- package/dist/core/stores/remote.js +30 -23
- package/dist/core/stores/remote.js.map +1 -1
- package/dist/generator.d.ts +36 -18
- package/dist/generator.d.ts.map +1 -1
- package/dist/generator.js +66 -73
- package/dist/generator.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -26
- package/dist/index.js.map +1 -1
- package/dist/resonate.d.ts +108 -31
- package/dist/resonate.d.ts.map +1 -1
- package/dist/resonate.js +144 -60
- package/dist/resonate.js.map +1 -1
- package/package.json +1 -1
package/dist/async.js
CHANGED
|
@@ -1,33 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Context = exports.
|
|
3
|
+
exports.Context = exports.Resonate = void 0;
|
|
27
4
|
const execution_1 = require("./core/execution");
|
|
28
5
|
const invocation_1 = require("./core/invocation");
|
|
29
6
|
const retry_1 = require("./core/retries/retry");
|
|
30
|
-
const utils = __importStar(require("./core/utils"));
|
|
31
7
|
const resonate_1 = require("./resonate");
|
|
32
8
|
/////////////////////////////////////////////////////////////////////
|
|
33
9
|
// Resonate
|
|
@@ -42,10 +18,22 @@ class Resonate extends resonate_1.ResonateBase {
|
|
|
42
18
|
*/
|
|
43
19
|
constructor(opts = {}) {
|
|
44
20
|
super(opts);
|
|
45
|
-
this.scheduler = new Scheduler();
|
|
21
|
+
this.scheduler = new Scheduler(this);
|
|
46
22
|
}
|
|
47
|
-
|
|
48
|
-
return
|
|
23
|
+
execute(name, id, func, args, opts, defaults, durablePromise) {
|
|
24
|
+
return this.scheduler.add(name, id, func, args, opts, defaults, durablePromise);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Register a function with Resonate. Registered functions can be invoked by calling {@link run}, or by the returned function.
|
|
28
|
+
*
|
|
29
|
+
* @template F The type of the function.
|
|
30
|
+
* @param name A unique name to identify the function.
|
|
31
|
+
* @param func The function to register with Resonate.
|
|
32
|
+
* @param opts Resonate options, can be constructed by calling {@link options}.
|
|
33
|
+
* @returns Resonate function
|
|
34
|
+
*/
|
|
35
|
+
register(name, func, opts) {
|
|
36
|
+
return super.register(name, func, opts);
|
|
49
37
|
}
|
|
50
38
|
/**
|
|
51
39
|
* Register a module with Resonate. Registered functions can be invoked by calling {@link run}.
|
|
@@ -58,17 +46,19 @@ class Resonate extends resonate_1.ResonateBase {
|
|
|
58
46
|
registerModule(module, opts = {}) {
|
|
59
47
|
super.registerModule(module, opts);
|
|
60
48
|
}
|
|
61
|
-
|
|
62
|
-
return
|
|
49
|
+
schedule(name, cron, func, ...args) {
|
|
50
|
+
return super.schedule(name, cron, func, ...args);
|
|
63
51
|
}
|
|
64
52
|
}
|
|
65
53
|
exports.Resonate = Resonate;
|
|
66
54
|
/////////////////////////////////////////////////////////////////////
|
|
67
55
|
// Context
|
|
68
56
|
/////////////////////////////////////////////////////////////////////
|
|
69
|
-
class
|
|
57
|
+
class Context {
|
|
58
|
+
resonate;
|
|
70
59
|
invocation;
|
|
71
|
-
constructor(invocation) {
|
|
60
|
+
constructor(resonate, invocation) {
|
|
61
|
+
this.resonate = resonate;
|
|
72
62
|
this.invocation = invocation;
|
|
73
63
|
}
|
|
74
64
|
/**
|
|
@@ -77,37 +67,6 @@ class Info {
|
|
|
77
67
|
get attempt() {
|
|
78
68
|
return this.invocation.attempt;
|
|
79
69
|
}
|
|
80
|
-
/**
|
|
81
|
-
* Uniquely identifies the function invocation.
|
|
82
|
-
*/
|
|
83
|
-
get id() {
|
|
84
|
-
return this.invocation.id;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Deduplicates function invocations with the same id.
|
|
88
|
-
*/
|
|
89
|
-
get idempotencyKey() {
|
|
90
|
-
return this.invocation.idempotencyKey;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* The timestamp in ms, once this time elapses the function invocation will timeout.
|
|
94
|
-
*/
|
|
95
|
-
get timeout() {
|
|
96
|
-
return this.invocation.timeout;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* The resonate function version.
|
|
100
|
-
*/
|
|
101
|
-
get version() {
|
|
102
|
-
return this.invocation.version;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
exports.Info = Info;
|
|
106
|
-
class Context {
|
|
107
|
-
invocation;
|
|
108
|
-
constructor(invocation) {
|
|
109
|
-
this.invocation = invocation;
|
|
110
|
-
}
|
|
111
70
|
/**
|
|
112
71
|
* The running count of child function invocations.
|
|
113
72
|
*/
|
|
@@ -126,6 +85,12 @@ class Context {
|
|
|
126
85
|
get idempotencyKey() {
|
|
127
86
|
return this.invocation.idempotencyKey;
|
|
128
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* All configured options for this context.
|
|
90
|
+
*/
|
|
91
|
+
get opts() {
|
|
92
|
+
return this.invocation.opts;
|
|
93
|
+
}
|
|
129
94
|
/**
|
|
130
95
|
* The timestamp in ms, once this time elapses the function invocation will timeout.
|
|
131
96
|
*/
|
|
@@ -136,7 +101,7 @@ class Context {
|
|
|
136
101
|
* The resonate function version.
|
|
137
102
|
*/
|
|
138
103
|
get version() {
|
|
139
|
-
return this.invocation.version;
|
|
104
|
+
return this.invocation.root.opts.version;
|
|
140
105
|
}
|
|
141
106
|
run(func, ...argsWithOpts) {
|
|
142
107
|
// the parent is the current invocation
|
|
@@ -147,59 +112,159 @@ class Context {
|
|
|
147
112
|
const id = typeof func === "string" ? func : `${parent.id}.${parent.counter}`;
|
|
148
113
|
// human readable name of the function
|
|
149
114
|
const name = typeof func === "string" ? func : func.name;
|
|
150
|
-
// version is inherited from the parent
|
|
151
|
-
const version = parent.version;
|
|
152
|
-
// the idempotency key is a hash of the id
|
|
153
|
-
const idempotencyKey = utils.hash(id);
|
|
154
115
|
// opts are optional and can be provided as the last arg
|
|
155
116
|
const { args, opts } = this.invocation.split(argsWithOpts);
|
|
117
|
+
// default opts never change
|
|
118
|
+
const defaults = this.invocation.defaults;
|
|
156
119
|
// param is only required for deferred executions
|
|
157
120
|
const param = typeof func === "string" ? args[0] : undefined;
|
|
158
121
|
// create a new invocation
|
|
159
|
-
const invocation = new invocation_1.Invocation(name,
|
|
122
|
+
const invocation = new invocation_1.Invocation(name, id, undefined, param, opts, defaults, parent);
|
|
160
123
|
let execution;
|
|
161
124
|
if (typeof func === "string") {
|
|
162
125
|
// create a deferred execution
|
|
163
126
|
// this execution will be fulfilled out-of-process
|
|
164
|
-
execution = new execution_1.DeferredExecution(invocation);
|
|
127
|
+
execution = new execution_1.DeferredExecution(this.resonate, invocation);
|
|
165
128
|
}
|
|
166
129
|
else {
|
|
167
|
-
// create an ordinary execution
|
|
130
|
+
// create an ordinary execution
|
|
168
131
|
// this execution wraps a user-provided function
|
|
169
|
-
const ctx = new Context(invocation);
|
|
170
|
-
execution = new execution_1.OrdinaryExecution(invocation, () => func(ctx, ...args)
|
|
132
|
+
const ctx = new Context(this.resonate, invocation);
|
|
133
|
+
execution = new execution_1.OrdinaryExecution(this.resonate, invocation, () => func(ctx, ...args));
|
|
171
134
|
}
|
|
172
135
|
// bump the counter
|
|
173
136
|
parent.counter++;
|
|
174
137
|
// return a resonate promise
|
|
175
138
|
return execution.execute();
|
|
176
139
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
//
|
|
187
|
-
//
|
|
188
|
-
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
140
|
+
/**
|
|
141
|
+
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
|
142
|
+
* resolve, or rejected when any Promise is rejected.
|
|
143
|
+
*
|
|
144
|
+
* @param values An array of Promises.
|
|
145
|
+
* @param opts Optional {@link options}.
|
|
146
|
+
* @returns A new ResonatePromise.
|
|
147
|
+
*/
|
|
148
|
+
all(values, opts = {}) {
|
|
149
|
+
// catch all promises to prevent unhandled promise rejections,
|
|
150
|
+
// since Promise.all will not be called in the case where the
|
|
151
|
+
// durable promise already completed
|
|
152
|
+
for (const value of values) {
|
|
153
|
+
if (value instanceof Promise) {
|
|
154
|
+
value.catch(() => { });
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// prettier-ignore
|
|
158
|
+
return this.run(() => Promise.all(values), this.options({
|
|
159
|
+
retry: retry_1.Retry.never(),
|
|
160
|
+
...opts,
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Creates a Promise that is fulfilled by the first given promise to be fulfilled, or rejected
|
|
165
|
+
* with an AggregateError.
|
|
166
|
+
*
|
|
167
|
+
* @param values An array of Promises.
|
|
168
|
+
* @param opts Optional {@link options}.
|
|
169
|
+
* @returns A new ResonatePromise.
|
|
170
|
+
*/
|
|
171
|
+
any(values, opts = {}) {
|
|
172
|
+
// catch all promises to prevent unhandled promise rejections,
|
|
173
|
+
// since Promise.any will not be called in the case where the
|
|
174
|
+
// durable promise already completed
|
|
175
|
+
for (const value of values) {
|
|
176
|
+
if (value instanceof Promise) {
|
|
177
|
+
value.catch(() => { });
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
// prettier-ignore
|
|
181
|
+
return this.run(() => Promise.any(values), this.options({
|
|
182
|
+
retry: retry_1.Retry.never(),
|
|
183
|
+
...opts,
|
|
184
|
+
}));
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
|
188
|
+
* or rejected.
|
|
189
|
+
*
|
|
190
|
+
* @param values An array of Promises.
|
|
191
|
+
* @param opts Optional {@link options}.
|
|
192
|
+
* @returns A new ResonatePromise.
|
|
193
|
+
*/
|
|
194
|
+
race(values, opts = {}) {
|
|
195
|
+
// catch all promises to prevent unhandled promise rejections,
|
|
196
|
+
// since Promise.race will not be called in the case where the
|
|
197
|
+
// durable promise already completed
|
|
198
|
+
for (const value of values) {
|
|
199
|
+
if (value instanceof Promise) {
|
|
200
|
+
value.catch(() => { });
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
// prettier-ignore
|
|
204
|
+
return this.run(() => Promise.race(values), this.options({
|
|
205
|
+
retry: retry_1.Retry.never(),
|
|
206
|
+
...opts,
|
|
207
|
+
}));
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
|
211
|
+
* resolve or reject.
|
|
212
|
+
*
|
|
213
|
+
* @param values An array of Promises.
|
|
214
|
+
* @param opts Optional {@link options}.
|
|
215
|
+
* @returns A new ResonatePromise.
|
|
216
|
+
*/
|
|
217
|
+
allSettled(values, opts = {}) {
|
|
218
|
+
// catch all promises to prevent unhandled promise rejections,
|
|
219
|
+
// since Promise.allSettled will not be called in the case where the
|
|
220
|
+
// durable promise already completed
|
|
221
|
+
for (const value of values) {
|
|
222
|
+
if (value instanceof Promise) {
|
|
223
|
+
value.catch(() => { });
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
// prettier-ignore
|
|
227
|
+
return this.run(() => Promise.allSettled(values), this.options({
|
|
228
|
+
retry: retry_1.Retry.never(),
|
|
229
|
+
...opts,
|
|
230
|
+
}));
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Generate a deterministic random number.
|
|
234
|
+
*
|
|
235
|
+
* @returns A random number.
|
|
236
|
+
*/
|
|
237
|
+
random() {
|
|
238
|
+
return this.run(Math.random);
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Get a deterministic timestamp.
|
|
242
|
+
*
|
|
243
|
+
* @returns A timestamp in ms.
|
|
244
|
+
*/
|
|
245
|
+
now() {
|
|
246
|
+
return this.run(Date.now);
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Run a Resonate function in detached mode. Functions must first be registered with Resonate.
|
|
250
|
+
*
|
|
251
|
+
* @template T The return type of the function.
|
|
252
|
+
* @param id A unique id for the function invocation.
|
|
253
|
+
* @param name The function name.
|
|
254
|
+
* @param args The function arguments.
|
|
255
|
+
* @returns A ResonatePromise.
|
|
256
|
+
*/
|
|
257
|
+
detached(name, id, ...args) {
|
|
258
|
+
return this.resonate.run(name, id, ...args);
|
|
194
259
|
}
|
|
195
260
|
/**
|
|
196
261
|
* Construct options.
|
|
197
262
|
*
|
|
198
263
|
* @param opts A partial {@link Options} object.
|
|
199
|
-
* @returns
|
|
264
|
+
* @returns PartialOptions.
|
|
200
265
|
*/
|
|
201
266
|
options(opts = {}) {
|
|
202
|
-
return
|
|
267
|
+
return this.resonate.options(opts);
|
|
203
268
|
}
|
|
204
269
|
}
|
|
205
270
|
exports.Context = Context;
|
|
@@ -207,27 +272,29 @@ exports.Context = Context;
|
|
|
207
272
|
// Scheduler
|
|
208
273
|
/////////////////////////////////////////////////////////////////////
|
|
209
274
|
class Scheduler {
|
|
275
|
+
resonate;
|
|
210
276
|
cache = {};
|
|
211
|
-
|
|
277
|
+
constructor(resonate) {
|
|
278
|
+
this.resonate = resonate;
|
|
279
|
+
}
|
|
280
|
+
add(name, id, func, args, opts, defaults, durablePromise) {
|
|
212
281
|
// if the execution is already running, and not killed,
|
|
213
282
|
// return the promise
|
|
214
|
-
if (this.cache[id] && !this.cache[id].killed) {
|
|
283
|
+
if (opts.durable && this.cache[id] && !this.cache[id].killed) {
|
|
215
284
|
// execute is idempotent
|
|
216
285
|
return this.cache[id].execute();
|
|
217
286
|
}
|
|
218
|
-
// the idempotency key is a hash of the id
|
|
219
|
-
const idempotencyKey = utils.hash(id);
|
|
220
287
|
// params, used for recovery
|
|
221
288
|
const param = {
|
|
222
289
|
func: name,
|
|
223
|
-
version,
|
|
290
|
+
version: opts.version,
|
|
224
291
|
args,
|
|
225
292
|
};
|
|
226
293
|
// create a new invocation
|
|
227
|
-
const invocation = new invocation_1.Invocation(name,
|
|
294
|
+
const invocation = new invocation_1.Invocation(name, id, undefined, param, opts, defaults);
|
|
228
295
|
// create a new execution
|
|
229
|
-
const ctx = new Context(invocation);
|
|
230
|
-
const execution = new execution_1.OrdinaryExecution(invocation, () => func(ctx, ...args));
|
|
296
|
+
const ctx = new Context(this.resonate, invocation);
|
|
297
|
+
const execution = new execution_1.OrdinaryExecution(this.resonate, invocation, () => func(ctx, ...args), durablePromise);
|
|
231
298
|
// store the execution,
|
|
232
299
|
// will be used if run is called again with the same id
|
|
233
300
|
this.cache[id] = execution;
|
package/dist/async.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async.js","sourceRoot":"","sources":["../lib/async.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"async.js","sourceRoot":"","sources":["../lib/async.ts"],"names":[],"mappings":";;;AAAA,gDAAmF;AAEnF,kDAA+C;AAG/C,gDAA6C;AAE7C,yCAA0C;AAY1C,qEAAqE;AACrE,WA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b,QAAiB,EACjB,cAAoC;QAEpC,uDAAuD;QACvD,qBAAqB;QACrB,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;YAC7D,wBAAwB;YACxB,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;QAClC,CAAC;QAED,4BAA4B;QAC5B,MAAM,KAAK,GAAG;YACZ,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI;SACL,CAAC;QAEF,0BAA0B;QAC1B,MAAM,UAAU,GAAG,IAAI,uBAAU,CAAY,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QAEzF,yBAAyB;QACzB,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QACnD,MAAM,SAAS,GAAG,IAAI,6BAAiB,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,EAAE,cAAc,CAAC,CAAC;QAE7G,uBAAuB;QACvB,uDAAuD;QACvD,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC;QAE3B,OAAO,SAAS,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;CACF"}
|
package/dist/core/execution.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { ResonateBase } from "../resonate";
|
|
1
2
|
import { Future, ResonatePromise } from "./future";
|
|
2
3
|
import { Invocation } from "./invocation";
|
|
3
4
|
import { DurablePromise } from "./promises/promises";
|
|
4
|
-
import { IRetry } from "./retry";
|
|
5
5
|
export declare abstract class Execution<T> {
|
|
6
|
+
resonate: ResonateBase;
|
|
6
7
|
invocation: Invocation<T>;
|
|
7
8
|
private promise;
|
|
8
9
|
/**
|
|
@@ -11,33 +12,34 @@ export declare abstract class Execution<T> {
|
|
|
11
12
|
* @constructor
|
|
12
13
|
* @param invocation - An invocation correpsonding to the Resonate function.
|
|
13
14
|
*/
|
|
14
|
-
constructor(invocation: Invocation<T>);
|
|
15
|
+
constructor(resonate: ResonateBase, invocation: Invocation<T>);
|
|
15
16
|
execute(): ResonatePromise<T>;
|
|
16
17
|
protected abstract fork(): Promise<Future<T>>;
|
|
17
18
|
protected abstract join(future: Future<T>): Promise<T>;
|
|
18
19
|
get killed(): boolean;
|
|
19
20
|
kill(error: unknown): void;
|
|
20
|
-
protected
|
|
21
|
+
protected acquireLock(): Promise<boolean>;
|
|
22
|
+
protected releaseLock(): Promise<void>;
|
|
21
23
|
}
|
|
22
24
|
export declare class OrdinaryExecution<T> extends Execution<T> {
|
|
23
25
|
private func;
|
|
24
|
-
private
|
|
25
|
-
constructor(invocation: Invocation<T>, func: () => T,
|
|
26
|
+
private durablePromise?;
|
|
27
|
+
constructor(resonate: ResonateBase, invocation: Invocation<T>, func: () => T, durablePromise?: DurablePromise<T> | undefined);
|
|
26
28
|
protected fork(): Promise<Future<T>>;
|
|
27
29
|
protected join(future: Future<T>): Promise<T>;
|
|
28
30
|
private run;
|
|
29
31
|
}
|
|
30
32
|
export declare class DeferredExecution<T> extends Execution<T> {
|
|
31
|
-
constructor(invocation: Invocation<T>);
|
|
32
33
|
protected fork(): Promise<Future<T>>;
|
|
33
34
|
protected join(future: Future<T>): Promise<T>;
|
|
34
35
|
}
|
|
35
36
|
export declare class GeneratorExecution<T> extends Execution<T> {
|
|
36
37
|
generator: Generator<any, T>;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
private durablePromise?;
|
|
39
|
+
constructor(resonate: ResonateBase, invocation: Invocation<T>, generator: Generator<any, T>, durablePromise?: DurablePromise<T> | undefined);
|
|
40
|
+
create(): Promise<void>;
|
|
41
|
+
resolve(value: T): Promise<void>;
|
|
42
|
+
reject(error: any): Promise<void>;
|
|
41
43
|
protected fork(): Promise<Future<T>>;
|
|
42
44
|
protected join(future: Future<T>): Promise<T>;
|
|
43
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../lib/core/execution.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../lib/core/execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAMrD,8BAAsB,SAAS,CAAC,CAAC;IAUtB,QAAQ,EAAE,YAAY;IACtB,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;IAVlC,OAAO,CAAC,OAAO,CAAmC;IAElD;;;;;OAKG;gBAEM,QAAQ,EAAE,YAAY,EACtB,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;IAGlC,OAAO,IAAI,eAAe,CAAC,CAAC,CAAC;IAY7B,SAAS,CAAC,QAAQ,CAAC,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC7C,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAEtD,IAAI,MAAM,YAET;IAED,IAAI,CAAC,KAAK,EAAE,OAAO;cAQH,WAAW;cAaX,WAAW;CAO5B;AAED,qBAAa,iBAAiB,CAAC,CAAC,CAAE,SAAQ,SAAS,CAAC,CAAC,CAAC;IAIlD,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,cAAc,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