@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.
- package/dist/core/errors.d.ts +4 -2
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +5 -2
- package/dist/core/errors.js.map +1 -1
- package/dist/core/options.d.ts +12 -5
- package/dist/core/options.d.ts.map +1 -1
- package/dist/core/options.js +11 -1
- package/dist/core/options.js.map +1 -1
- package/dist/core/promises/promises.d.ts.map +1 -1
- package/dist/core/retry.d.ts +1 -0
- package/dist/core/retry.d.ts.map +1 -1
- package/dist/core/retry.js +20 -1
- package/dist/core/retry.js.map +1 -1
- package/dist/core/schedules/schedules.d.ts +1 -1
- package/dist/core/schedules/schedules.d.ts.map +1 -1
- package/dist/core/schedules/schedules.js.map +1 -1
- package/dist/core/stores/local.js +2 -2
- package/dist/core/stores/local.js.map +1 -1
- package/dist/core/stores/remote.d.ts.map +1 -1
- package/dist/core/stores/remote.js +14 -1
- package/dist/core/stores/remote.js.map +1 -1
- package/dist/core/utils.d.ts +55 -0
- package/dist/core/utils.d.ts.map +1 -1
- package/dist/core/utils.js +67 -1
- package/dist/core/utils.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -5
- package/dist/index.js.map +1 -1
- package/dist/resonate.d.ts +165 -46
- package/dist/resonate.d.ts.map +1 -1
- package/dist/resonate.js +622 -169
- package/dist/resonate.js.map +1 -1
- package/package.json +1 -1
- package/dist/async.d.ts +0 -219
- package/dist/async.d.ts.map +0 -1
- package/dist/async.js +0 -403
- package/dist/async.js.map +0 -1
- package/dist/core/calls.d.ts +0 -23
- package/dist/core/calls.d.ts.map +0 -1
- package/dist/core/calls.js +0 -13
- package/dist/core/calls.js.map +0 -1
- package/dist/core/execution.d.ts +0 -37
- package/dist/core/execution.d.ts.map +0 -1
- package/dist/core/execution.js +0 -215
- package/dist/core/execution.js.map +0 -1
- package/dist/core/future.d.ts +0 -56
- package/dist/core/future.d.ts.map +0 -1
- package/dist/core/future.js +0 -107
- package/dist/core/future.js.map +0 -1
- package/dist/core/invocation.d.ts +0 -41
- package/dist/core/invocation.d.ts.map +0 -1
- package/dist/core/invocation.js +0 -81
- package/dist/core/invocation.js.map +0 -1
package/dist/core/execution.js
DELETED
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DeferredExecution = exports.OrdinaryExecution = exports.Execution = void 0;
|
|
4
|
-
const errors_1 = require("./errors");
|
|
5
|
-
const future_1 = require("./future");
|
|
6
|
-
const promises_1 = require("./promises/promises");
|
|
7
|
-
const retry_1 = require("./retry");
|
|
8
|
-
/////////////////////////////////////////////////////////////////////
|
|
9
|
-
// Execution
|
|
10
|
-
/////////////////////////////////////////////////////////////////////
|
|
11
|
-
class Execution {
|
|
12
|
-
resonate;
|
|
13
|
-
invocation;
|
|
14
|
-
promise = null;
|
|
15
|
-
/**
|
|
16
|
-
* Represents an execution of a Resonate function invocation.
|
|
17
|
-
*
|
|
18
|
-
* @constructor
|
|
19
|
-
* @param invocation - An invocation correpsonding to the Resonate function.
|
|
20
|
-
*/
|
|
21
|
-
constructor(resonate, invocation) {
|
|
22
|
-
this.resonate = resonate;
|
|
23
|
-
this.invocation = invocation;
|
|
24
|
-
}
|
|
25
|
-
execute() {
|
|
26
|
-
if (this.promise) {
|
|
27
|
-
return this.promise;
|
|
28
|
-
}
|
|
29
|
-
// each execution has a fork phase and a join phase
|
|
30
|
-
// fork phase is responsible for spawning the invocation,
|
|
31
|
-
// which in general means creating a durable promise (if necessary)
|
|
32
|
-
const forkPromise = this.fork();
|
|
33
|
-
// join phase is responsible for awaiting the invocation,
|
|
34
|
-
// if the invocation is backed by a durable promise the durable
|
|
35
|
-
// promise is completed before the invocation is completed
|
|
36
|
-
const joinPromise = forkPromise.then((f) => this.join(f));
|
|
37
|
-
this.promise = new future_1.ResonatePromise(this.invocation.id, forkPromise, joinPromise);
|
|
38
|
-
return this.promise;
|
|
39
|
-
}
|
|
40
|
-
get killed() {
|
|
41
|
-
return this.invocation.root.killed;
|
|
42
|
-
}
|
|
43
|
-
kill(error) {
|
|
44
|
-
// this will mark the entire invocation tree as killed
|
|
45
|
-
this.invocation.root.killed = true;
|
|
46
|
-
// reject only the root invocation
|
|
47
|
-
this.invocation.root.reject(new errors_1.ResonateError("Resonate function killed", errors_1.ErrorCodes.KILLED, error, true));
|
|
48
|
-
}
|
|
49
|
-
async acquireLock() {
|
|
50
|
-
try {
|
|
51
|
-
return await this.resonate.store.locks.tryAcquire(this.invocation.id, this.invocation.eid);
|
|
52
|
-
}
|
|
53
|
-
catch (e) {
|
|
54
|
-
// if lock is already acquired, return false so we can poll
|
|
55
|
-
if (e instanceof errors_1.ResonateError && e.code === errors_1.ErrorCodes.STORE_FORBIDDEN) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
throw e;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
async releaseLock() {
|
|
62
|
-
try {
|
|
63
|
-
await this.resonate.store.locks.release(this.invocation.id, this.invocation.eid);
|
|
64
|
-
}
|
|
65
|
-
catch (e) {
|
|
66
|
-
this.resonate.logger.warn("Failed to release lock", e);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
exports.Execution = Execution;
|
|
71
|
-
class OrdinaryExecution extends Execution {
|
|
72
|
-
func;
|
|
73
|
-
durablePromise;
|
|
74
|
-
constructor(resonate, invocation, func, durablePromise) {
|
|
75
|
-
super(resonate, invocation);
|
|
76
|
-
this.func = func;
|
|
77
|
-
this.durablePromise = durablePromise;
|
|
78
|
-
}
|
|
79
|
-
async fork() {
|
|
80
|
-
if (this.invocation.opts.durable && !this.durablePromise) {
|
|
81
|
-
// if durable, create a durable promise
|
|
82
|
-
try {
|
|
83
|
-
this.durablePromise = await promises_1.DurablePromise.create(this.resonate.store.promises, this.invocation.opts.encoder, this.invocation.id, this.invocation.timeout, {
|
|
84
|
-
idempotencyKey: this.invocation.idempotencyKey,
|
|
85
|
-
headers: this.invocation.headers,
|
|
86
|
-
param: this.invocation.param,
|
|
87
|
-
tags: this.invocation.opts.tags,
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
catch (e) {
|
|
91
|
-
// if an error occurs, kill the execution
|
|
92
|
-
this.kill(e);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
if (this.durablePromise) {
|
|
96
|
-
// override the invocation creation time
|
|
97
|
-
this.invocation.createdOn = this.durablePromise.createdOn;
|
|
98
|
-
// override the invocation timeout
|
|
99
|
-
this.invocation.timeout = this.durablePromise.timeout;
|
|
100
|
-
}
|
|
101
|
-
return this.invocation.future;
|
|
102
|
-
}
|
|
103
|
-
async join(future) {
|
|
104
|
-
try {
|
|
105
|
-
// acquire lock if necessary
|
|
106
|
-
while (this.invocation.opts.lock && !(await this.acquireLock())) {
|
|
107
|
-
await new Promise((resolve) => setTimeout(resolve, this.invocation.opts.poll));
|
|
108
|
-
}
|
|
109
|
-
if (this.durablePromise) {
|
|
110
|
-
if (this.durablePromise.pending) {
|
|
111
|
-
// if durable and pending, invoke the function and resolve/reject the durable promise
|
|
112
|
-
let value;
|
|
113
|
-
let error;
|
|
114
|
-
// we need to hold on to a boolean to determine if the function was successful,
|
|
115
|
-
// we cannot rely on the value or error as these values could be undefined
|
|
116
|
-
let success = true;
|
|
117
|
-
try {
|
|
118
|
-
value = await this.run();
|
|
119
|
-
}
|
|
120
|
-
catch (e) {
|
|
121
|
-
error = e;
|
|
122
|
-
success = false;
|
|
123
|
-
}
|
|
124
|
-
if (success) {
|
|
125
|
-
await this.durablePromise.resolve(value, { idempotencyKey: this.invocation.idempotencyKey });
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
await this.durablePromise.reject(error, { idempotencyKey: this.invocation.idempotencyKey });
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
// if durable resolve/reject the invocation
|
|
132
|
-
if (this.durablePromise.resolved) {
|
|
133
|
-
this.invocation.resolve(this.durablePromise.value());
|
|
134
|
-
}
|
|
135
|
-
else if (this.durablePromise.rejected || this.durablePromise.canceled || this.durablePromise.timedout) {
|
|
136
|
-
this.invocation.reject(this.durablePromise.error());
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
// if not durable, invoke the function and resolve/reject the invocation
|
|
141
|
-
try {
|
|
142
|
-
this.invocation.resolve(await this.run());
|
|
143
|
-
}
|
|
144
|
-
catch (e) {
|
|
145
|
-
this.invocation.reject(e);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
// release lock if necessary
|
|
149
|
-
if (this.invocation.opts.lock) {
|
|
150
|
-
await this.releaseLock();
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
catch (e) {
|
|
154
|
-
// if an error occurs, kill the execution
|
|
155
|
-
this.kill(e);
|
|
156
|
-
}
|
|
157
|
-
return await future.promise;
|
|
158
|
-
}
|
|
159
|
-
async run() {
|
|
160
|
-
let error;
|
|
161
|
-
// invoke the function according to the retry policy
|
|
162
|
-
for (const delay of (0, retry_1.retryIterator)(this.invocation)) {
|
|
163
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
164
|
-
try {
|
|
165
|
-
return await this.func();
|
|
166
|
-
}
|
|
167
|
-
catch (e) {
|
|
168
|
-
error = e;
|
|
169
|
-
// bump the attempt count
|
|
170
|
-
this.invocation.attempt++;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
// if all attempts fail throw the last error
|
|
174
|
-
throw error;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
exports.OrdinaryExecution = OrdinaryExecution;
|
|
178
|
-
class DeferredExecution extends Execution {
|
|
179
|
-
durablePromise = null;
|
|
180
|
-
async fork() {
|
|
181
|
-
try {
|
|
182
|
-
// create a durable promise
|
|
183
|
-
this.durablePromise = await promises_1.DurablePromise.create(this.resonate.store.promises, this.invocation.opts.encoder, this.invocation.id, this.invocation.timeout, {
|
|
184
|
-
idempotencyKey: this.invocation.idempotencyKey,
|
|
185
|
-
headers: this.invocation.headers,
|
|
186
|
-
param: this.invocation.param,
|
|
187
|
-
tags: this.invocation.opts.tags,
|
|
188
|
-
});
|
|
189
|
-
// override the invocation creation time
|
|
190
|
-
this.invocation.createdOn = this.durablePromise.createdOn;
|
|
191
|
-
// override the invocation timeout
|
|
192
|
-
this.invocation.timeout = this.durablePromise.timeout;
|
|
193
|
-
}
|
|
194
|
-
catch (e) {
|
|
195
|
-
// if an error occurs, kill the execution
|
|
196
|
-
this.kill(e);
|
|
197
|
-
}
|
|
198
|
-
return this.invocation.future;
|
|
199
|
-
}
|
|
200
|
-
async join(future) {
|
|
201
|
-
if (this.durablePromise) {
|
|
202
|
-
// poll the completion of the durable promise
|
|
203
|
-
await this.durablePromise.sync(Infinity, this.invocation.opts.poll);
|
|
204
|
-
if (this.durablePromise.resolved) {
|
|
205
|
-
this.invocation.resolve(this.durablePromise.value());
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
this.invocation.reject(this.durablePromise.error());
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
return await future.promise;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
exports.DeferredExecution = DeferredExecution;
|
|
215
|
-
//# sourceMappingURL=execution.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"execution.js","sourceRoot":"","sources":["../../lib/core/execution.ts"],"names":[],"mappings":";;;AACA,qCAAqD;AACrD,qCAAmD;AAEnD,kDAAqD;AACrD,mCAAwC;AAExC,qEAAqE;AACrE,YAAY;AACZ,qEAAqE;AAErE,MAAsB,SAAS;IAUpB;IACA;IAVD,OAAO,GAA8B,IAAI,CAAC;IAElD;;;;;OAKG;IACH,YACS,QAAsB,EACtB,UAAyB;QADzB,aAAQ,GAAR,QAAQ,CAAc;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U,CAAC,KAAK;gBAC5B,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI;aAChC,CACF,CAAC;YAEF,wCAAwC;YACxC,IAAI,CAAC,UAAU,CAAC,SAAS,GAAG,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC;YAE1D,kCAAkC;YAClC,IAAI,CAAC,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;QACxD,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,yCAAyC;YACzC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACf,CAAC;QAED,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;IAChC,CAAC;IAES,KAAK,CAAC,IAAI,CAAC,MAAiB;QACpC,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACxB,6CAA6C;YAC7C,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAEpE,IAAI,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;gBACjC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC,CAAC;YACvD,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC,CAAC;YACtD,CAAC;QACH,CAAC;QAED,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC;IAC9B,CAAC;CACF;AA9CD,8CA8CC"}
|
package/dist/core/future.d.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Invocation } from "./invocation";
|
|
2
|
-
export declare class ResonatePromise<T> extends Promise<T> {
|
|
3
|
-
id: string;
|
|
4
|
-
created: Promise<string>;
|
|
5
|
-
static [Symbol.species]: PromiseConstructor;
|
|
6
|
-
/**
|
|
7
|
-
* Represents the eventual return value of a Resonate function. This is achieved by wrapping a Javscript promise.
|
|
8
|
-
*
|
|
9
|
-
* @constructor
|
|
10
|
-
* @param id - A unique identifier for this promise.
|
|
11
|
-
* @param created - A promise that resolves when the durable promise has been created.
|
|
12
|
-
* @param completed - A promise that resolves when the durable promise has been fulfilled.
|
|
13
|
-
*/
|
|
14
|
-
constructor(id: string, created: Promise<Future<T>>, completed: Promise<T>);
|
|
15
|
-
}
|
|
16
|
-
export type FutureValue<T> = {
|
|
17
|
-
kind: "pending";
|
|
18
|
-
} | {
|
|
19
|
-
kind: "resolved";
|
|
20
|
-
value: T;
|
|
21
|
-
} | {
|
|
22
|
-
kind: "rejected";
|
|
23
|
-
error: unknown;
|
|
24
|
-
};
|
|
25
|
-
export declare class Future<T> {
|
|
26
|
-
private invocation;
|
|
27
|
-
promise: Promise<T>;
|
|
28
|
-
private _resolve;
|
|
29
|
-
private _reject;
|
|
30
|
-
readonly kind = "future";
|
|
31
|
-
private _value;
|
|
32
|
-
/**
|
|
33
|
-
* Represents the eventual return value of a Resonate function.
|
|
34
|
-
*
|
|
35
|
-
* @constructor
|
|
36
|
-
* @param invocation - An invocation correpsonding to the Resonate function.
|
|
37
|
-
* @param promise - A promise that resolves to the return value of the Resonate function.
|
|
38
|
-
*/
|
|
39
|
-
constructor(invocation: Invocation<T>, promise: Promise<T>, _resolve: (v: T) => void, _reject: (v?: unknown) => void);
|
|
40
|
-
static deferred<T>(invocation: Invocation<T>): {
|
|
41
|
-
future: Future<T>;
|
|
42
|
-
resolve: (value: T) => void;
|
|
43
|
-
reject: (error: unknown) => void;
|
|
44
|
-
};
|
|
45
|
-
get id(): string;
|
|
46
|
-
get idempotencyKey(): string;
|
|
47
|
-
get root(): Future<any>;
|
|
48
|
-
get parent(): Future<any> | null;
|
|
49
|
-
get children(): Future<any>[];
|
|
50
|
-
get value(): FutureValue<T>;
|
|
51
|
-
get pending(): boolean;
|
|
52
|
-
get completed(): boolean;
|
|
53
|
-
private resolve;
|
|
54
|
-
private reject;
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=future.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"future.d.ts","sourceRoot":"","sources":["../../lib/core/future.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAM1C,qBAAa,eAAe,CAAC,CAAC,CAAE,SAAQ,OAAO,CAAC,CAAC,CAAC;IAkBvC,EAAE,EAAE,MAAM;IAfnB,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAIzB,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,qBAAW;IAElC;;;;;;;OAOG;gBAEM,EAAE,EAAE,MAAM,EACjB,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAC3B,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;CAUxB;AAMD,MAAM,MAAM,WAAW,CAAC,CAAC,IACrB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAEzC,qBAAa,MAAM,CAAC,CAAC;IAejB,OAAO,CAAC,UAAU;IACX,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAC1B,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,OAAO;IAhBjB,QAAQ,CAAC,IAAI,YAAY;IAGzB,OAAO,CAAC,MAAM,CAAuC;IAErD;;;;;;OAMG;gBAEO,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,EAC1B,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAClB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,EACxB,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI;IAGxC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;;;;;IAqB5C,IAAI,EAAE,WAEL;IAED,IAAI,cAAc,WAEjB;IAED,IAAI,IAAI,gBAEP;IAED,IAAI,MAAM,uBAET;IAED,IAAI,QAAQ,kBAEX;IAED,IAAI,KAAK,mBAER;IAED,IAAI,OAAO,YAEV;IAED,IAAI,SAAS,YAEZ;IAED,OAAO,CAAC,OAAO;IAKf,OAAO,CAAC,MAAM;CAIf"}
|
package/dist/core/future.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Future = exports.ResonatePromise = void 0;
|
|
4
|
-
/////////////////////////////////////////////////////////////////////
|
|
5
|
-
// Promise
|
|
6
|
-
/////////////////////////////////////////////////////////////////////
|
|
7
|
-
class ResonatePromise extends Promise {
|
|
8
|
-
id;
|
|
9
|
-
// resolves to the id of the durable promise
|
|
10
|
-
// can be used to await durable promise creation
|
|
11
|
-
created;
|
|
12
|
-
// You are not expected to understand this (we don't either)
|
|
13
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/@@species
|
|
14
|
-
static [Symbol.species] = Promise;
|
|
15
|
-
/**
|
|
16
|
-
* Represents the eventual return value of a Resonate function. This is achieved by wrapping a Javscript promise.
|
|
17
|
-
*
|
|
18
|
-
* @constructor
|
|
19
|
-
* @param id - A unique identifier for this promise.
|
|
20
|
-
* @param created - A promise that resolves when the durable promise has been created.
|
|
21
|
-
* @param completed - A promise that resolves when the durable promise has been fulfilled.
|
|
22
|
-
*/
|
|
23
|
-
constructor(id, created, completed) {
|
|
24
|
-
// bind the promise to the completed promise
|
|
25
|
-
super((resolve, reject) => {
|
|
26
|
-
completed.then(resolve, reject);
|
|
27
|
-
});
|
|
28
|
-
this.id = id;
|
|
29
|
-
// expose the id when the durable promise has been created
|
|
30
|
-
this.created = created.then((future) => future.id);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.ResonatePromise = ResonatePromise;
|
|
34
|
-
class Future {
|
|
35
|
-
invocation;
|
|
36
|
-
promise;
|
|
37
|
-
_resolve;
|
|
38
|
-
_reject;
|
|
39
|
-
// a discriminate property
|
|
40
|
-
kind = "future";
|
|
41
|
-
// initial value
|
|
42
|
-
_value = { kind: "pending" };
|
|
43
|
-
/**
|
|
44
|
-
* Represents the eventual return value of a Resonate function.
|
|
45
|
-
*
|
|
46
|
-
* @constructor
|
|
47
|
-
* @param invocation - An invocation correpsonding to the Resonate function.
|
|
48
|
-
* @param promise - A promise that resolves to the return value of the Resonate function.
|
|
49
|
-
*/
|
|
50
|
-
constructor(invocation, promise, _resolve, _reject) {
|
|
51
|
-
this.invocation = invocation;
|
|
52
|
-
this.promise = promise;
|
|
53
|
-
this._resolve = _resolve;
|
|
54
|
-
this._reject = _reject;
|
|
55
|
-
}
|
|
56
|
-
static deferred(invocation) {
|
|
57
|
-
let resolve;
|
|
58
|
-
let reject;
|
|
59
|
-
// construct a javascript promise
|
|
60
|
-
const promise = new Promise((_resolve, _reject) => {
|
|
61
|
-
resolve = _resolve;
|
|
62
|
-
reject = _reject;
|
|
63
|
-
});
|
|
64
|
-
// construct a new future
|
|
65
|
-
const future = new Future(invocation, promise, resolve, reject);
|
|
66
|
-
// return future and resolvers
|
|
67
|
-
return {
|
|
68
|
-
future: future,
|
|
69
|
-
resolve: future.resolve.bind(future),
|
|
70
|
-
reject: future.reject.bind(future),
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
get id() {
|
|
74
|
-
return this.invocation.id;
|
|
75
|
-
}
|
|
76
|
-
get idempotencyKey() {
|
|
77
|
-
return this.invocation.idempotencyKey;
|
|
78
|
-
}
|
|
79
|
-
get root() {
|
|
80
|
-
return this.invocation.root.future;
|
|
81
|
-
}
|
|
82
|
-
get parent() {
|
|
83
|
-
return this.invocation.parent?.future ?? null;
|
|
84
|
-
}
|
|
85
|
-
get children() {
|
|
86
|
-
return this.invocation.children.map((i) => i.future);
|
|
87
|
-
}
|
|
88
|
-
get value() {
|
|
89
|
-
return this._value;
|
|
90
|
-
}
|
|
91
|
-
get pending() {
|
|
92
|
-
return this._value.kind === "pending";
|
|
93
|
-
}
|
|
94
|
-
get completed() {
|
|
95
|
-
return !this.pending;
|
|
96
|
-
}
|
|
97
|
-
resolve(value) {
|
|
98
|
-
this._resolve(value);
|
|
99
|
-
this._value = { kind: "resolved", value };
|
|
100
|
-
}
|
|
101
|
-
reject(error) {
|
|
102
|
-
this._reject(error);
|
|
103
|
-
this._value = { kind: "rejected", error };
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
exports.Future = Future;
|
|
107
|
-
//# sourceMappingURL=future.js.map
|
package/dist/core/future.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"future.js","sourceRoot":"","sources":["../../lib/core/future.ts"],"names":[],"mappings":";;;AAEA,qEAAqE;AACrE,UAAU;AACV,qEAAqE;AAErE,MAAa,eAAmB,SAAQ,OAAU;IAkBvC;IAjBT,4CAA4C;IAC5C,gDAAgD;IAChD,OAAO,CAAkB;IAEzB,4DAA4D;IAC5D,qGAAqG;IACrG,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IAElC;;;;;;;OAOG;IACH,YACS,EAAU,EACjB,OAA2B,EAC3B,SAAqB;QAErB,4CAA4C;QAC5C,KAAK,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACxB,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;QAPI,OAAE,GAAF,EAAE,CAAQ;QASjB,0DAA0D;QAC1D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAA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AC,MAAM,CAAC;IACrC,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,IAAI,IAAI,CAAC;IAChD,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IACvD,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC;IACxC,CAAC;IAED,IAAI,SAAS;QACX,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;IACvB,CAAC;IAEO,OAAO,CAAC,KAAQ;QACtB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;IAC5C,CAAC;IAEO,MAAM,CAAC,KAAc;QAC3B,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACpB,IAAI,CAAC,MAAM,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;IAC5C,CAAC;CACF;AAnFD,wBAmFC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Future } from "./future";
|
|
2
|
-
import { Options } from "./options";
|
|
3
|
-
import { RetryPolicy } from "./retry";
|
|
4
|
-
export declare class Invocation<T> {
|
|
5
|
-
readonly name: string;
|
|
6
|
-
readonly id: string;
|
|
7
|
-
readonly headers: Record<string, string> | undefined;
|
|
8
|
-
readonly param: unknown;
|
|
9
|
-
readonly opts: Options;
|
|
10
|
-
future: Future<T>;
|
|
11
|
-
resolve: (v: T) => void;
|
|
12
|
-
reject: (e: unknown) => void;
|
|
13
|
-
eid: string;
|
|
14
|
-
idempotencyKey: string;
|
|
15
|
-
timeout: number;
|
|
16
|
-
killed: boolean;
|
|
17
|
-
createdOn: number;
|
|
18
|
-
counter: number;
|
|
19
|
-
attempt: number;
|
|
20
|
-
retryPolicy: RetryPolicy;
|
|
21
|
-
awaited: Future<any>[];
|
|
22
|
-
blocked: Future<any> | null;
|
|
23
|
-
readonly root: Invocation<any>;
|
|
24
|
-
readonly parent: Invocation<any> | null;
|
|
25
|
-
readonly children: Invocation<any>[];
|
|
26
|
-
/**
|
|
27
|
-
* Represents a Resonate function invocation.
|
|
28
|
-
*
|
|
29
|
-
* @constructor
|
|
30
|
-
* @param id - A unique id for this invocation.
|
|
31
|
-
* @param idempotencyKey - An idempotency key used to deduplicate invocations.
|
|
32
|
-
* @param opts - The invocation options.
|
|
33
|
-
* @param parent - The parent invocation.
|
|
34
|
-
*/
|
|
35
|
-
constructor(name: string, id: string, headers: Record<string, string> | undefined, param: unknown, opts: Options, parent?: Invocation<any>);
|
|
36
|
-
addChild(child: Invocation<any>): void;
|
|
37
|
-
await(future: Future<any>): void;
|
|
38
|
-
block(future: Future<any>): void;
|
|
39
|
-
unblock(): void;
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=invocation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invocation.d.ts","sourceRoot":"","sources":["../../lib/core/invocation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAe,MAAM,SAAS,CAAC;AAMnD,qBAAa,UAAU,CAAC,CAAC;aAiCL,IAAI,EAAE,MAAM;aACZ,EAAE,EAAE,MAAM;aACV,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS;aAC3C,KAAK,EAAE,OAAO;aACd,IAAI,EAAE,OAAO;IApC/B,MAAM,EAAE,MAAM,CAAC,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{ value: true });
|
|
3
|
-
exports.Invocation = void 0;
|
|
4
|
-
const future_1 = require("./future");
|
|
5
|
-
const retry_1 = require("./retry");
|
|
6
|
-
/////////////////////////////////////////////////////////////////////
|
|
7
|
-
// Invocation
|
|
8
|
-
/////////////////////////////////////////////////////////////////////
|
|
9
|
-
class Invocation {
|
|
10
|
-
name;
|
|
11
|
-
id;
|
|
12
|
-
headers;
|
|
13
|
-
param;
|
|
14
|
-
opts;
|
|
15
|
-
future;
|
|
16
|
-
resolve;
|
|
17
|
-
reject;
|
|
18
|
-
eid;
|
|
19
|
-
idempotencyKey;
|
|
20
|
-
timeout;
|
|
21
|
-
killed = false;
|
|
22
|
-
createdOn = Date.now();
|
|
23
|
-
counter = 0;
|
|
24
|
-
attempt = 0;
|
|
25
|
-
retryPolicy = (0, retry_1.exponential)();
|
|
26
|
-
awaited = [];
|
|
27
|
-
blocked = null;
|
|
28
|
-
root;
|
|
29
|
-
parent;
|
|
30
|
-
children = [];
|
|
31
|
-
/**
|
|
32
|
-
* Represents a Resonate function invocation.
|
|
33
|
-
*
|
|
34
|
-
* @constructor
|
|
35
|
-
* @param id - A unique id for this invocation.
|
|
36
|
-
* @param idempotencyKey - An idempotency key used to deduplicate invocations.
|
|
37
|
-
* @param opts - The invocation options.
|
|
38
|
-
* @param parent - The parent invocation.
|
|
39
|
-
*/
|
|
40
|
-
constructor(name, id, headers, param, opts, parent) {
|
|
41
|
-
this.name = name;
|
|
42
|
-
this.id = id;
|
|
43
|
-
this.headers = headers;
|
|
44
|
-
this.param = param;
|
|
45
|
-
this.opts = opts;
|
|
46
|
-
// create a future and hold on to its resolvers
|
|
47
|
-
const { future, resolve, reject } = future_1.Future.deferred(this);
|
|
48
|
-
this.future = future;
|
|
49
|
-
this.resolve = resolve;
|
|
50
|
-
this.reject = reject;
|
|
51
|
-
this.root = parent?.root ?? this;
|
|
52
|
-
this.parent = parent ?? null;
|
|
53
|
-
// get the execution id from either:
|
|
54
|
-
// - a hard coded string
|
|
55
|
-
// - a function that returns a string given the invocation id
|
|
56
|
-
this.eid = this.opts.eidFn(this.id);
|
|
57
|
-
// get the idempotency key from either:
|
|
58
|
-
// - a hard coded string
|
|
59
|
-
// - a function that returns a string given the invocation id
|
|
60
|
-
this.idempotencyKey = this.opts.idempotencyKeyFn(this.id);
|
|
61
|
-
// the timeout is the minimum of:
|
|
62
|
-
// - the current time plus the user provided relative time
|
|
63
|
-
// - the parent timeout
|
|
64
|
-
this.timeout = Math.min(this.createdOn + this.opts.timeout, this.parent?.timeout ?? Infinity);
|
|
65
|
-
this.retryPolicy = this.opts.retry;
|
|
66
|
-
}
|
|
67
|
-
addChild(child) {
|
|
68
|
-
this.children.push(child);
|
|
69
|
-
}
|
|
70
|
-
await(future) {
|
|
71
|
-
this.awaited.push(future);
|
|
72
|
-
}
|
|
73
|
-
block(future) {
|
|
74
|
-
this.blocked = future;
|
|
75
|
-
}
|
|
76
|
-
unblock() {
|
|
77
|
-
this.blocked = null;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
exports.Invocation = Invocation;
|
|
81
|
-
//# sourceMappingURL=invocation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invocation.js","sourceRoot":"","sources":["../../lib/core/invocation.ts"],"names":[],"mappings":";;;AAAA,qCAAkC;AAElC,mCAAmD;AAEnD,qEAAqE;AACrE,aAAa;AACb,qEAAqE;AAErE,MAAa,UAAU;IAiCH;IACA;IACA;IACA;IACA;IApClB,MAAM,CAAY;IAClB,OAAO,CAAiB;IACxB,MAAM,CAAuB;IAE7B,GAAG,CAAS;IACZ,cAAc,CAAS;IACvB,OAAO,CAAS;IAEhB,MAAM,GAAY,KAAK,CAAC;IAExB,SAAS,GAAW,IAAI,CAAC,GAAG,EAAE,CAAC;IAC/B,OAAO,GAAW,CAAC,CAAC;IACpB,OAAO,GAAW,CAAC,CAAC;IACpB,WAAW,GAAgB,IAAA,mBAAW,GAAE,CAAC;IAEzC,OAAO,GAAkB,E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