@resonatehq/sdk 0.5.5 → 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.
Files changed (54) hide show
  1. package/dist/core/errors.d.ts +4 -2
  2. package/dist/core/errors.d.ts.map +1 -1
  3. package/dist/core/errors.js +5 -2
  4. package/dist/core/errors.js.map +1 -1
  5. package/dist/core/options.d.ts +12 -5
  6. package/dist/core/options.d.ts.map +1 -1
  7. package/dist/core/options.js +11 -1
  8. package/dist/core/options.js.map +1 -1
  9. package/dist/core/promises/promises.d.ts.map +1 -1
  10. package/dist/core/retry.d.ts +1 -0
  11. package/dist/core/retry.d.ts.map +1 -1
  12. package/dist/core/retry.js +20 -1
  13. package/dist/core/retry.js.map +1 -1
  14. package/dist/core/schedules/schedules.d.ts +1 -1
  15. package/dist/core/schedules/schedules.d.ts.map +1 -1
  16. package/dist/core/schedules/schedules.js.map +1 -1
  17. package/dist/core/stores/local.js +2 -2
  18. package/dist/core/stores/local.js.map +1 -1
  19. package/dist/core/stores/remote.d.ts.map +1 -1
  20. package/dist/core/stores/remote.js +14 -1
  21. package/dist/core/stores/remote.js.map +1 -1
  22. package/dist/core/utils.d.ts +55 -0
  23. package/dist/core/utils.d.ts.map +1 -1
  24. package/dist/core/utils.js +67 -1
  25. package/dist/core/utils.js.map +1 -1
  26. package/dist/index.d.ts +0 -2
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +1 -5
  29. package/dist/index.js.map +1 -1
  30. package/dist/resonate.d.ts +165 -46
  31. package/dist/resonate.d.ts.map +1 -1
  32. package/dist/resonate.js +622 -169
  33. package/dist/resonate.js.map +1 -1
  34. package/package.json +1 -1
  35. package/dist/async.d.ts +0 -219
  36. package/dist/async.d.ts.map +0 -1
  37. package/dist/async.js +0 -403
  38. package/dist/async.js.map +0 -1
  39. package/dist/core/calls.d.ts +0 -23
  40. package/dist/core/calls.d.ts.map +0 -1
  41. package/dist/core/calls.js +0 -13
  42. package/dist/core/calls.js.map +0 -1
  43. package/dist/core/execution.d.ts +0 -37
  44. package/dist/core/execution.d.ts.map +0 -1
  45. package/dist/core/execution.js +0 -215
  46. package/dist/core/execution.js.map +0 -1
  47. package/dist/core/future.d.ts +0 -56
  48. package/dist/core/future.d.ts.map +0 -1
  49. package/dist/core/future.js +0 -107
  50. package/dist/core/future.js.map +0 -1
  51. package/dist/core/invocation.d.ts +0 -41
  52. package/dist/core/invocation.d.ts.map +0 -1
  53. package/dist/core/invocation.js +0 -81
  54. package/dist/core/invocation.js.map +0 -1
package/dist/async.js DELETED
@@ -1,403 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.Context = exports.Resonate = void 0;
27
- const calls_1 = require("./core/calls");
28
- const execution_1 = require("./core/execution");
29
- const invocation_1 = require("./core/invocation");
30
- const retryPolicy = __importStar(require("./core/retry"));
31
- const utils = __importStar(require("./core/utils"));
32
- const resonate_1 = require("./resonate");
33
- /////////////////////////////////////////////////////////////////////
34
- // Types
35
- /////////////////////////////////////////////////////////////////////
36
- /////////////////////////////////////////////////////////////////////
37
- // Resonate
38
- /////////////////////////////////////////////////////////////////////
39
- class Resonate extends resonate_1.ResonateBase {
40
- scheduler;
41
- /**
42
- * Creates a Resonate instance. This is the starting point for using Resonate.
43
- *
44
- * @constructor
45
- * @param opts - A partial {@link ResonateOptions} object.
46
- */
47
- constructor(opts = {}) {
48
- super(opts);
49
- this.scheduler = new Scheduler(this);
50
- }
51
- execute(name, id, func, args, opts, durablePromise) {
52
- return this.scheduler.add(name, id, func, args, opts, durablePromise);
53
- }
54
- /**
55
- * Register a function with Resonate. Registered functions can be invoked by calling {@link run}, or by the returned function.
56
- *
57
- * @template F The type of the function.
58
- * @param name A unique name to identify the function.
59
- * @param func The function to register with Resonate.
60
- * @param opts Resonate options, can be constructed by calling {@link options}.
61
- * @returns Resonate function
62
- */
63
- register(name, func, opts) {
64
- return super.register(name, func, opts);
65
- }
66
- /**
67
- * Register a module with Resonate. Registered functions can be invoked by calling {@link run}.
68
- *
69
- * @template F The type of the function.
70
- * @param module The module to register with Resonate.
71
- * @param opts Resonate options, can be constructed by calling {@link options}.
72
- * @returns Resonate function
73
- */
74
- registerModule(module, opts = {}) {
75
- super.registerModule(module, opts);
76
- }
77
- schedule(name, cron, func, ...args) {
78
- return super.schedule(name, cron, func, ...args);
79
- }
80
- }
81
- exports.Resonate = Resonate;
82
- /////////////////////////////////////////////////////////////////////
83
- // Context
84
- /////////////////////////////////////////////////////////////////////
85
- class Context {
86
- resonate;
87
- invocation;
88
- constructor(resonate, invocation) {
89
- this.resonate = resonate;
90
- this.invocation = invocation;
91
- }
92
- /**
93
- * The running count of function execution attempts.
94
- */
95
- get attempt() {
96
- return this.invocation.attempt;
97
- }
98
- /**
99
- * The running count of child function invocations.
100
- */
101
- get counter() {
102
- return this.invocation.counter;
103
- }
104
- /**
105
- * The time the invocation was created. Will use the durable promise creation time if available.
106
- */
107
- get createdOn() {
108
- return this.invocation.createdOn;
109
- }
110
- /**
111
- * Uniquely identifies the function invocation.
112
- */
113
- get id() {
114
- return this.invocation.id;
115
- }
116
- /**
117
- * Deduplicates function invocations with the same id.
118
- */
119
- get idempotencyKey() {
120
- return this.invocation.idempotencyKey;
121
- }
122
- /**
123
- * All configured options for this context.
124
- */
125
- get opts() {
126
- return this.invocation.opts;
127
- }
128
- /**
129
- * The timestamp in ms, once this time elapses the function invocation will timeout.
130
- */
131
- get timeout() {
132
- return this.invocation.timeout;
133
- }
134
- /**
135
- * The resonate function version.
136
- */
137
- get version() {
138
- return this.invocation.root.opts.version;
139
- }
140
- run(funcOrFc, ...argsWithOpts) {
141
- // Function with args and possibly options
142
- if (typeof funcOrFc === "function") {
143
- const { args, opts } = utils.split(argsWithOpts);
144
- const lfc = {
145
- func: funcOrFc,
146
- args,
147
- opts: opts,
148
- };
149
- return this._run(lfc);
150
- }
151
- // String (function name) with args and possibly options
152
- if (typeof funcOrFc === "string") {
153
- const funcName = funcOrFc;
154
- const { args, opts } = utils.split(argsWithOpts);
155
- const rfc = {
156
- funcName,
157
- args,
158
- opts,
159
- };
160
- return this._run(rfc);
161
- }
162
- // We are sure it is an FC
163
- return this._run(funcOrFc);
164
- }
165
- _run(fc) {
166
- // the parent is the current invocation
167
- const parent = this.invocation;
168
- // human readable name of the function
169
- let name;
170
- // the id is either:
171
- // 1. a provided string in the case of a deferred execution
172
- // 2. a generated string in the case of an ordinary execution
173
- let id;
174
- // Params to store with the durable promise. For RemoteExecutions we just encode the
175
- // given arg(s). Otherwise we store nothing since it is unncesary.
176
- let param;
177
- if ((0, calls_1.isRFC)(fc)) {
178
- name = fc.funcName;
179
- id = name;
180
- param = fc.args;
181
- }
182
- else {
183
- name = fc.func.name;
184
- id = `${parent.id}.${parent.counter}.${name}`;
185
- param = undefined;
186
- }
187
- const registeredOptions = this.resonate.registeredOptions(this.invocation.root.name, this.invocation.root.opts.version);
188
- const resonateOptions = this.resonate.defaults();
189
- const opts = {
190
- ...resonateOptions,
191
- ...registeredOptions,
192
- ...fc.opts,
193
- };
194
- // Merge the tags
195
- opts.tags = { ...resonateOptions.tags, ...registeredOptions.tags, ...fc.opts?.tags };
196
- // Default lock is false for children execution
197
- opts.lock = opts.lock ?? false;
198
- // create a new invocation
199
- const invocation = new invocation_1.Invocation(name, id, undefined, param, opts, parent);
200
- let execution;
201
- if ((0, calls_1.isRFC)(fc)) {
202
- // create a deferred execution
203
- // this execution will be fulfilled out-of-process
204
- execution = new execution_1.DeferredExecution(this.resonate, invocation);
205
- }
206
- else {
207
- // create an ordinary execution
208
- // this execution wraps a user-provided function
209
- const ctx = new Context(this.resonate, invocation);
210
- execution = new execution_1.OrdinaryExecution(this.resonate, invocation, () => fc.func(ctx, ...(fc.args ?? [])));
211
- }
212
- // bump the counter
213
- parent.counter++;
214
- // return a resonate promise
215
- return execution.execute();
216
- }
217
- /**
218
- * Creates a Promise that is resolved with an array of results when all of the provided Promises
219
- * resolve, or rejected when any Promise is rejected.
220
- *
221
- * @param values An array of Promises.
222
- * @param opts Optional {@link options}.
223
- * @returns A new ResonatePromise.
224
- */
225
- all(values, opts = {}) {
226
- // catch all promises to prevent unhandled promise rejections,
227
- // since Promise.all will not be called in the case where the
228
- // durable promise already completed
229
- for (const value of values) {
230
- if (value instanceof Promise) {
231
- value.catch(() => { });
232
- }
233
- }
234
- // prettier-ignore
235
- return this.run(() => Promise.all(values), this.options({
236
- retry: retryPolicy.never(),
237
- ...opts,
238
- }));
239
- }
240
- /**
241
- * Creates a Promise that is fulfilled by the first given promise to be fulfilled, or rejected
242
- * with an AggregateError.
243
- *
244
- * @param values An array of Promises.
245
- * @param opts Optional {@link options}.
246
- * @returns A new ResonatePromise.
247
- */
248
- any(values, opts = {}) {
249
- // catch all promises to prevent unhandled promise rejections,
250
- // since Promise.any will not be called in the case where the
251
- // durable promise already completed
252
- for (const value of values) {
253
- if (value instanceof Promise) {
254
- value.catch(() => { });
255
- }
256
- }
257
- // prettier-ignore
258
- return this.run(() => Promise.any(values), this.options({
259
- retry: retryPolicy.never(),
260
- ...opts,
261
- }));
262
- }
263
- /**
264
- * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
265
- * or rejected.
266
- *
267
- * @param values An array of Promises.
268
- * @param opts Optional {@link options}.
269
- * @returns A new ResonatePromise.
270
- */
271
- race(values, opts = {}) {
272
- // catch all promises to prevent unhandled promise rejections,
273
- // since Promise.race will not be called in the case where the
274
- // durable promise already completed
275
- for (const value of values) {
276
- if (value instanceof Promise) {
277
- value.catch(() => { });
278
- }
279
- }
280
- // prettier-ignore
281
- return this.run(() => Promise.race(values), this.options({
282
- retry: retryPolicy.never(),
283
- ...opts,
284
- }));
285
- }
286
- /**
287
- * Creates a Promise that is resolved with an array of results when all of the provided Promises
288
- * resolve or reject.
289
- *
290
- * @param values An array of Promises.
291
- * @param opts Optional {@link options}.
292
- * @returns A new ResonatePromise.
293
- */
294
- allSettled(values, opts = {}) {
295
- // catch all promises to prevent unhandled promise rejections,
296
- // since Promise.allSettled will not be called in the case where the
297
- // durable promise already completed
298
- for (const value of values) {
299
- if (value instanceof Promise) {
300
- value.catch(() => { });
301
- }
302
- }
303
- // prettier-ignore
304
- return this.run(() => Promise.allSettled(values), this.options({
305
- retry: retryPolicy.never(),
306
- ...opts,
307
- }));
308
- }
309
- /**
310
- * Sleep for the specified time.
311
- *
312
- * @param ms Amount of time to sleep in milliseconds.
313
- * @returns A Promise that resolves after the specified time has elapsed.
314
- */
315
- async sleep(ms) {
316
- // generate id
317
- const id = `${this.invocation.id}.${this.invocation.counter++}`;
318
- // create a promise that resolves when it times out
319
- const promise = await this.resonate.promises.create(id, Date.now() + ms, {
320
- tags: { "resonate:timeout": "true" },
321
- });
322
- // wait for the promise to resolve
323
- // if wait time < 1, delay will be set to 1
324
- if (promise.pending) {
325
- await new Promise((resolve) => setTimeout(resolve, promise.timeout - Date.now()));
326
- }
327
- // tight loop in case the promise is not yet resolved
328
- await promise.wait(Infinity, this.invocation.opts.poll);
329
- }
330
- /**
331
- * Generate a deterministic random number.
332
- *
333
- * @returns A random number.
334
- */
335
- random() {
336
- return this.run(Math.random);
337
- }
338
- /**
339
- * Get a deterministic timestamp.
340
- *
341
- * @returns A timestamp in ms.
342
- */
343
- now() {
344
- return this.run(Date.now);
345
- }
346
- /**
347
- * Run a Resonate function in detached mode. Functions must first be registered with Resonate.
348
- *
349
- * @template T The return type of the function.
350
- * @param id A unique id for the function invocation.
351
- * @param name The function name.
352
- * @param args The function arguments.
353
- * @returns A ResonatePromise.
354
- */
355
- detached(name, id, ...args) {
356
- return this.resonate.run(name, id, ...args);
357
- }
358
- /**
359
- * Construct options.
360
- *
361
- * @param opts A partial {@link Options} object.
362
- * @returns PartialOptions.
363
- */
364
- options(opts = {}) {
365
- return this.resonate.options(opts);
366
- }
367
- }
368
- exports.Context = Context;
369
- /////////////////////////////////////////////////////////////////////
370
- // Scheduler
371
- /////////////////////////////////////////////////////////////////////
372
- class Scheduler {
373
- resonate;
374
- cache = {};
375
- constructor(resonate) {
376
- this.resonate = resonate;
377
- }
378
- add(name, id, func, args, opts, durablePromise) {
379
- // if the execution is already running, and not killed,
380
- // return the promise
381
- if (opts.durable && this.cache[id] && !this.cache[id].killed) {
382
- // execute is idempotent
383
- return this.cache[id].execute();
384
- }
385
- // params, used for recovery
386
- const param = {
387
- func: name,
388
- version: opts.version,
389
- retryPolicy: opts.retry,
390
- args,
391
- };
392
- // create a new invocation
393
- const invocation = new invocation_1.Invocation(name, id, undefined, param, opts);
394
- // create a new execution
395
- const ctx = new Context(this.resonate, invocation);
396
- const execution = new execution_1.OrdinaryExecution(this.resonate, invocation, () => func(ctx, ...args), durablePromise);
397
- // store the execution,
398
- // will be used if run is called again with the same id
399
- this.cache[id] = execution;
400
- return execution.execute();
401
- }
402
- }
403
- //# sourceMappingURL=async.js.map
package/dist/async.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"async.js","sourceRoot":"","sources":["../lib/async.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;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,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,WAAW,EAAE,IAAI,CAAC,KAAK;YACvB,IAAI;SACL,CAAC;QAEF,0BAA0B;QAC1B,MAAM,UAAU,GAAG,IAAI,uBAAU,CAAY,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;QAE/E,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"}
@@ -1,23 +0,0 @@
1
- import { Context } from "..";
2
- import { Options } from "./options";
3
- export type Func = (ctx: Context, ...args: any[]) => any;
4
- export type Params<F> = F extends (ctx: any, ...args: infer P) => any ? P : never;
5
- export type Return<F> = F extends (...args: any[]) => infer T ? Awaited<T> : never;
6
- export type TFC = {
7
- funcName: string;
8
- id: string;
9
- args?: any[];
10
- optsOverrides?: Partial<Pick<Options, "durable" | "eidFn" | "idempotencyKeyFn" | "retry" | "tags" | "timeout" | "version">>;
11
- };
12
- export type RFC = {
13
- funcName: string;
14
- args?: any;
15
- opts?: Partial<Options>;
16
- };
17
- export type LFC<F extends Func> = {
18
- func: F;
19
- args?: any[];
20
- opts?: Partial<Options>;
21
- };
22
- export declare function isRFC(obj: any): obj is RFC;
23
- //# sourceMappingURL=calls.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"calls.d.ts","sourceRoot":"","sources":["../../lib/core/calls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,MAAM,MAAM,IAAI,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAGzD,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,MAAM,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC;AAGlF,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;AAGnF,MAAM,MAAM,GAAG,GAAG;IAEhB,QAAQ,EAAE,MAAM,CAAC;IAEjB,EAAE,EAAE,MAAM,CAAC;IAEX,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IAIb,aAAa,CAAC,EAAE,OAAO,CACrB,IAAI,CAAC,OAAO,EAAE,SAAS,GAAG,OAAO,GAAG,kBAAkB,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC,CACnG,CAAC;CACH,CAAC;AAGF,MAAM,MAAM,GAAG,GAAG;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,IAAI,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;CACzB,CAAC;AAGF,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,IAAI,IAAI;IAChC,IAAI,EAAE,CAAC,CAAC;IACR,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;CACzB,CAAC;AAGF,wBAAgB,KAAK,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,GAAG,CAQ1C"}
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isRFC = void 0;
4
- // Type guard for RFC
5
- function isRFC(obj) {
6
- return (typeof obj === "object" &&
7
- obj !== null &&
8
- typeof obj.funcName === "string" &&
9
- (obj.args === undefined || typeof obj.args === "object") &&
10
- (obj.opts === undefined || (typeof obj.opts === "object" && obj.opts !== null)));
11
- }
12
- exports.isRFC = isRFC;
13
- //# sourceMappingURL=calls.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"calls.js","sourceRoot":"","sources":["../../lib/core/calls.ts"],"names":[],"mappings":";;;AA0CA,qBAAqB;AACrB,SAAgB,KAAK,CAAC,GAAQ;IAC5B,OAAO,CACL,OAAO,GAAG,KAAK,QAAQ;QACvB,GAAG,KAAK,IAAI;QACZ,OAAO,GAAG,CAAC,QAAQ,KAAK,QAAQ;QAChC,CAAC,GAAG,CAAC,IAAI,KAAK,SAAS,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC;QACxD,CAAC,GAAG,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAChF,CAAC;AACJ,CAAC;AARD,sBAQC"}
@@ -1,37 +0,0 @@
1
- import { ResonateBase } from "../resonate";
2
- import { Future, ResonatePromise } from "./future";
3
- import { Invocation } from "./invocation";
4
- import { DurablePromise } from "./promises/promises";
5
- export declare abstract class Execution<T> {
6
- resonate: ResonateBase;
7
- invocation: Invocation<T>;
8
- private promise;
9
- /**
10
- * Represents an execution of a Resonate function invocation.
11
- *
12
- * @constructor
13
- * @param invocation - An invocation correpsonding to the Resonate function.
14
- */
15
- constructor(resonate: ResonateBase, invocation: Invocation<T>);
16
- execute(): ResonatePromise<T>;
17
- protected abstract fork(): Promise<Future<T>>;
18
- protected abstract join(future: Future<T>): Promise<T>;
19
- get killed(): boolean;
20
- kill(error: unknown): void;
21
- protected acquireLock(): Promise<boolean>;
22
- protected releaseLock(): Promise<void>;
23
- }
24
- export declare class OrdinaryExecution<T> extends Execution<T> {
25
- private func;
26
- private durablePromise?;
27
- constructor(resonate: ResonateBase, invocation: Invocation<T>, func: () => T, durablePromise?: DurablePromise<T> | undefined);
28
- protected fork(): Promise<Future<T>>;
29
- protected join(future: Future<T>): Promise<T>;
30
- private run;
31
- }
32
- export declare class DeferredExecution<T> extends Execution<T> {
33
- private durablePromise;
34
- protected fork(): Promise<Future<T>>;
35
- protected join(future: Future<T>): Promise<T>;
36
- }
37
- //# sourceMappingURL=execution.d.ts.map
@@ -1 +0,0 @@
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;AAOrD,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;IAoB7B,SAAS,CAAC,QAAQ,CAAC,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAA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