@versori/run 0.5.4 → 0.5.6
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/esm/src/interpreter/durable/compilers/durableworkflow.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/durableworkflow.js +46 -29
- package/esm/src/interpreter/vanilla/ObservableCompiler.d.ts +0 -2
- package/esm/src/interpreter/vanilla/ObservableCompiler.d.ts.map +1 -1
- package/esm/src/interpreter/vanilla/VanillaInterpreter.d.ts +1 -3
- package/esm/src/interpreter/vanilla/VanillaInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/vanilla/VanillaInterpreter.js +4 -12
- package/esm/src/interpreter/vanilla/compilers/durableworkflow.d.ts.map +1 -1
- package/esm/src/interpreter/vanilla/compilers/durableworkflow.js +28 -30
- package/esm/src/kv/memory/MemoryKeyValue.d.ts.map +1 -1
- package/esm/src/kv/memory/MemoryKeyValue.js +70 -19
- package/esm/src/kv/nats/NatsKeyValue.d.ts.map +1 -1
- package/esm/src/kv/nats/NatsKeyValue.js +77 -23
- package/esm/src/kv/sdk/SDKKeyValue.d.ts.map +1 -1
- package/esm/src/kv/sdk/SDKKeyValue.js +103 -38
- package/package.json +1 -1
- package/script/src/interpreter/durable/compilers/durableworkflow.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/durableworkflow.js +46 -29
- package/script/src/interpreter/vanilla/ObservableCompiler.d.ts +0 -2
- package/script/src/interpreter/vanilla/ObservableCompiler.d.ts.map +1 -1
- package/script/src/interpreter/vanilla/VanillaInterpreter.d.ts +1 -3
- package/script/src/interpreter/vanilla/VanillaInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/vanilla/VanillaInterpreter.js +4 -12
- package/script/src/interpreter/vanilla/compilers/durableworkflow.d.ts.map +1 -1
- package/script/src/interpreter/vanilla/compilers/durableworkflow.js +28 -30
- package/script/src/kv/memory/MemoryKeyValue.d.ts.map +1 -1
- package/script/src/kv/memory/MemoryKeyValue.js +73 -19
- package/script/src/kv/nats/NatsKeyValue.d.ts.map +1 -1
- package/script/src/kv/nats/NatsKeyValue.js +80 -23
- package/script/src/kv/sdk/SDKKeyValue.d.ts.map +1 -1
- package/script/src/kv/sdk/SDKKeyValue.js +106 -38
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durableworkflow.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/durableworkflow.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"durableworkflow.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/durableworkflow.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAW,WAAW,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EACH,mBAAmB,EACnB,sBAAsB,EACzB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,wBAAgB,sBAAsB,CAClC,GAAG,EAAE,sBAAsB,EAC3B,OAAO,EAAE,sBAAsB,EAC/B,MAAM,EAAE,WAAW,GACpB,UAAU,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC,CA2G9C;AAED,eAAO,MAAM,uBAAuB,EAAE,eAAe,CAAC,mBAAmB,EAAE,sBAAsB,CAIhG,CAAC"}
|
|
@@ -40,42 +40,59 @@ export function compileDurableWorkflow(ctx, trigger, signal) {
|
|
|
40
40
|
continue;
|
|
41
41
|
}
|
|
42
42
|
for (const wf of wfs.workflows) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
await ctx.tracer.startActiveSpan(`durableworkflow-${trigger.id}`, async (span) => {
|
|
44
|
+
span.setAttribute('task.id', trigger.id);
|
|
45
|
+
span.setAttribute('task.type', 'durableworkflow');
|
|
46
|
+
span.setAttribute('execution.id', wf.metadata?.executionId ?? '');
|
|
47
|
+
if (wf.metadata?.activationId) {
|
|
48
|
+
span.setAttribute('activation.id', wf.metadata.activationId);
|
|
49
|
+
}
|
|
47
50
|
try {
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
const payload = wf.payload ? atob(wf.payload) : '{}';
|
|
52
|
+
const data = JSON.parse(payload);
|
|
53
|
+
let activation;
|
|
54
|
+
if (wf.metadata?.activationId) {
|
|
55
|
+
try {
|
|
56
|
+
const { data } = await ctx.platformApi.getActivation({
|
|
57
|
+
path: {
|
|
58
|
+
activation_id: wf.metadata.activationId,
|
|
59
|
+
organisation_id: ctx.organisationId,
|
|
60
|
+
environment_id: Deno.env.get(envVarEnvId) || 'development',
|
|
61
|
+
},
|
|
62
|
+
throwOnError: true,
|
|
63
|
+
});
|
|
64
|
+
activation = data;
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
ctx.log.error('Failed to get activation', { error });
|
|
68
|
+
throw new Error('Failed to get activation');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const newContext = ctx.contextProvider.createWithExecutionId(activation, data, wf.metadata?.executionId ?? ulid().toString(), {
|
|
72
|
+
workflow: wf,
|
|
73
|
+
onSuccess: (completedContext) => {
|
|
74
|
+
// locked status means we own the workflow and it's not completed yet
|
|
75
|
+
if (wf.status !== 'locked') {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
ctx.queueProvider.complete({
|
|
79
|
+
id: wf.id,
|
|
80
|
+
output: btoa(JSON.stringify(completedContext.data)),
|
|
81
|
+
status: 'completed',
|
|
82
|
+
});
|
|
53
83
|
},
|
|
54
|
-
throwOnError: true,
|
|
55
84
|
});
|
|
56
|
-
|
|
85
|
+
consecutiveErrors = 0;
|
|
86
|
+
subscriber.next(newContext);
|
|
57
87
|
}
|
|
58
88
|
catch (error) {
|
|
59
|
-
|
|
60
|
-
|
|
89
|
+
span.recordException(error instanceof Error ? error : new Error(String(error)));
|
|
90
|
+
ctx.log.error('Error processing workflow', { error });
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
span.end();
|
|
61
94
|
}
|
|
62
|
-
}
|
|
63
|
-
const newContext = ctx.contextProvider.createWithExecutionId(activation, data, wf.metadata?.executionId ?? ulid().toString(), {
|
|
64
|
-
workflow: wf,
|
|
65
|
-
onSuccess: (completedContext) => {
|
|
66
|
-
// locked status means we own the workflow and it's not completed yet
|
|
67
|
-
if (wf.status !== 'locked') {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
ctx.queueProvider.complete({
|
|
71
|
-
id: wf.id,
|
|
72
|
-
output: btoa(JSON.stringify(completedContext.data)),
|
|
73
|
-
status: 'completed',
|
|
74
|
-
});
|
|
75
|
-
},
|
|
76
95
|
});
|
|
77
|
-
consecutiveErrors = 0;
|
|
78
|
-
subscriber.next(newContext);
|
|
79
96
|
}
|
|
80
97
|
}
|
|
81
98
|
catch (error) {
|
|
@@ -9,7 +9,6 @@ import { ConfigReader } from '../../dsl/http/types.js';
|
|
|
9
9
|
import { Task } from '../../dsl/Task.js';
|
|
10
10
|
import { Trigger } from '../../dsl/Trigger.js';
|
|
11
11
|
import { Logger } from '../../observability/logging/Logger.js';
|
|
12
|
-
import { PlatformApi } from '../../services/platform/PlatformApi.js';
|
|
13
12
|
import { QueueAPI } from '../durable/Queue.js';
|
|
14
13
|
import { ContextOperatorFunction, TaskCompiler, TriggerCompiler } from './compilers/types.js';
|
|
15
14
|
export type VanillaCompilerContext = {
|
|
@@ -18,7 +17,6 @@ export type VanillaCompilerContext = {
|
|
|
18
17
|
tracer: Tracer;
|
|
19
18
|
contextProvider: ContextProvider;
|
|
20
19
|
cnxFactory: ConnectionFactory;
|
|
21
|
-
platformApi: PlatformApi;
|
|
22
20
|
queueProvider: QueueAPI;
|
|
23
21
|
webhookRouter: Router;
|
|
24
22
|
cronRouter: Router;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservableCompiler.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/vanilla/ObservableCompiler.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAY,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAe,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAC/D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ObservableCompiler.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/vanilla/ObservableCompiler.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE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,GAAG,IAAI,EACzC,GAAG,EAAE,sBAAsB,EAC3B,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,GACpB,uBAAuB,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC;IAe1C,cAAc,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC,SAAS,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,EAC3D,GAAG,EAAE,sBAAsB,EAC3B,OAAO,EAAE,CAAC,EACV,MAAM,EAAE,WAAW,GACpB,UAAU,CAAC,cAAc,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAexC,YAAY,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,SAAS,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IAKjF,eAAe,CAAC,GAAG,EAAE,CAAC,SAAS,OAAO,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,eAAe,CAAC,GAAG,EAAE,CAAC,CAAC;CAIjF"}
|
|
@@ -8,7 +8,6 @@ import { VanillaContext, VanillaContextProvider } from '../../context/VanillaCon
|
|
|
8
8
|
import { ConfigReader, CronProvider } from '../../dsl/http/types.js';
|
|
9
9
|
import { Workflow } from '../../dsl/Workflow.js';
|
|
10
10
|
import { Logger } from '../../observability/logging/Logger.js';
|
|
11
|
-
import { PlatformApi } from '../../services/platform/PlatformApi.js';
|
|
12
11
|
import { QueueAPI } from '../durable/Queue.js';
|
|
13
12
|
import { ContextOperatorFunction } from './compilers/types.js';
|
|
14
13
|
import { ObservableCompiler } from './ObservableCompiler.js';
|
|
@@ -80,7 +79,6 @@ export declare class VanillaInterpreter {
|
|
|
80
79
|
private readonly cronProvider;
|
|
81
80
|
private readonly tracer;
|
|
82
81
|
private readonly cfgReader;
|
|
83
|
-
private readonly platformApi;
|
|
84
82
|
private readonly queueProvider;
|
|
85
83
|
private readonly otelSDK?;
|
|
86
84
|
private registeredWorkflows;
|
|
@@ -88,7 +86,7 @@ export declare class VanillaInterpreter {
|
|
|
88
86
|
private cronServer?;
|
|
89
87
|
private shutdownServer?;
|
|
90
88
|
private isShuttingDown;
|
|
91
|
-
constructor(log: Logger, compiler: ObservableCompiler, contextProvider: ContextProvider, webhookRouter: Router, cronRouter: Router, cronRegistry: Map<string, string>, cnxFetchFactory: DefaultConnectionFactory, cronProvider: CronProvider, tracer: Tracer, cfgReader: ConfigReader,
|
|
89
|
+
constructor(log: Logger, compiler: ObservableCompiler, contextProvider: ContextProvider, webhookRouter: Router, cronRouter: Router, cronRegistry: Map<string, string>, cnxFetchFactory: DefaultConnectionFactory, cronProvider: CronProvider, tracer: Tracer, cfgReader: ConfigReader, queueProvider: QueueAPI, otelSDK?: NodeSDK | undefined);
|
|
92
90
|
static newInstance(options?: VanillaInterpreterOptions): Promise<VanillaInterpreter>;
|
|
93
91
|
register<O>(workflow: Workflow<O>, options?: VanillaInterpreterOptions): Registration;
|
|
94
92
|
start(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VanillaInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/vanilla/VanillaInterpreter.ts"],"names":[],"mappings":"AAaA,OAAsB,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAG3D,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAgB,EAAqB,MAAM,EAAE,MAAM,SAAS,CAAC;AAE7D,OAAO,EAA+B,UAAU,EAAM,YAAY,EAAO,MAAM,MAAM,CAAC;AACtF,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzF,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAA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AAC,EACjC,eAAe,EAAE,wBAAwB,EACzC,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,YAAY,EACvB,aAAa,EAAE,QAAQ,EACvB,OAAO,CAAC,EAAE,OAAO,YAAA;WASzB,WAAW,CAAC,OAAO,GAAE,yBAA8B,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA6F9F,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,yBAAyB;IAsDtE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAoMtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CASxB"}
|
|
@@ -26,7 +26,6 @@ import { IssueImpl } from '../../issues/Issues.js';
|
|
|
26
26
|
import { MemoryKeyValueProvider } from '../../kv/memory/MemoryKeyValueProvider.js';
|
|
27
27
|
import { SDKKeyValueProvider } from '../../kv/sdk/SDKKeyValueProvider.js';
|
|
28
28
|
import { ConsoleLogger } from '../../observability/logging/ConsoleLogger.js';
|
|
29
|
-
import { PlatformApiImpl } from '../../services/platform/PlatformApi.js';
|
|
30
29
|
import { QueueImpl } from '../durable/Queue.js';
|
|
31
30
|
import { ObservableCompiler } from './ObservableCompiler.js';
|
|
32
31
|
function getKVProvider(runLocal) {
|
|
@@ -59,7 +58,7 @@ function getKVProvider(runLocal) {
|
|
|
59
58
|
* ```
|
|
60
59
|
*/
|
|
61
60
|
export class VanillaInterpreter {
|
|
62
|
-
constructor(log, compiler, contextProvider, webhookRouter, cronRouter, cronRegistry, cnxFetchFactory, cronProvider, tracer, cfgReader,
|
|
61
|
+
constructor(log, compiler, contextProvider, webhookRouter, cronRouter, cronRegistry, cnxFetchFactory, cronProvider, tracer, cfgReader, queueProvider, otelSDK) {
|
|
63
62
|
Object.defineProperty(this, "log", {
|
|
64
63
|
enumerable: true,
|
|
65
64
|
configurable: true,
|
|
@@ -120,12 +119,6 @@ export class VanillaInterpreter {
|
|
|
120
119
|
writable: true,
|
|
121
120
|
value: cfgReader
|
|
122
121
|
});
|
|
123
|
-
Object.defineProperty(this, "platformApi", {
|
|
124
|
-
enumerable: true,
|
|
125
|
-
configurable: true,
|
|
126
|
-
writable: true,
|
|
127
|
-
value: platformApi
|
|
128
|
-
});
|
|
129
122
|
Object.defineProperty(this, "queueProvider", {
|
|
130
123
|
enumerable: true,
|
|
131
124
|
configurable: true,
|
|
@@ -173,7 +166,7 @@ export class VanillaInterpreter {
|
|
|
173
166
|
}
|
|
174
167
|
}
|
|
175
168
|
static async newInstance(options = {}) {
|
|
176
|
-
const log = options.logger || new ConsoleLogger();
|
|
169
|
+
const log = options.logger || new ConsoleLogger("info");
|
|
177
170
|
const compiler = options.compiler || new ObservableCompiler();
|
|
178
171
|
const serviceName = Deno.env.get(envVarProjectId) || 'example-service';
|
|
179
172
|
const environmentID = Deno.env.get(envVarEnvId) || 'development';
|
|
@@ -211,13 +204,13 @@ export class VanillaInterpreter {
|
|
|
211
204
|
const connectionFactory = new DefaultConnectionFactory();
|
|
212
205
|
const issuesProvider = new IssueImpl(log);
|
|
213
206
|
if (options.contextProvider) {
|
|
214
|
-
return new VanillaInterpreter(log, compiler, options.contextProvider, express.Router(), express.Router(), new Map(), connectionFactory, CronAPIClient.fromEnv(), tracer, configReader,
|
|
207
|
+
return new VanillaInterpreter(log, compiler, options.contextProvider, express.Router(), express.Router(), new Map(), connectionFactory, CronAPIClient.fromEnv(), tracer, configReader, queueProvider, otelSDK);
|
|
215
208
|
}
|
|
216
209
|
const kvp = await getKVProvider(runLocal);
|
|
217
210
|
const organisationId = Deno.env.get(envVarOrgId) || 'development';
|
|
218
211
|
const environmentId = Deno.env.get(envVarEnvId) || 'development';
|
|
219
212
|
const ctxProvider = new VanillaContextProvider(log, kvp, organisationId, environmentId, issuesProvider, queueProvider);
|
|
220
|
-
return new VanillaInterpreter(log, compiler, ctxProvider, express.Router(), express.Router(), new Map(), connectionFactory, CronAPIClient.fromEnv(), tracer, configReader,
|
|
213
|
+
return new VanillaInterpreter(log, compiler, ctxProvider, express.Router(), express.Router(), new Map(), connectionFactory, CronAPIClient.fromEnv(), tracer, configReader, queueProvider, otelSDK);
|
|
221
214
|
}
|
|
222
215
|
register(workflow, options) {
|
|
223
216
|
const localAbortController = new AbortController();
|
|
@@ -233,7 +226,6 @@ export class VanillaInterpreter {
|
|
|
233
226
|
tracer: this.tracer,
|
|
234
227
|
contextProvider: this.contextProvider,
|
|
235
228
|
webhookRouter: this.webhookRouter,
|
|
236
|
-
platformApi: this.platformApi,
|
|
237
229
|
queueProvider: this.queueProvider,
|
|
238
230
|
cronRouter: this.cronRouter,
|
|
239
231
|
cronRegistry: this.cronRegistry,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durableworkflow.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/vanilla/compilers/durableworkflow.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"durableworkflow.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/vanilla/compilers/durableworkflow.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EACH,mBAAmB,EACnB,sBAAsB,EACzB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAqB,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEpE,wBAAgB,sBAAsB,CAClC,GAAG,EAAE,sBAAsB,EAC3B,OAAO,EAAE,sBAAsB,EAC/B,MAAM,EAAE,WAAW,GACpB,UAAU,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC,CA6FjD;AAED,eAAO,MAAM,uBAAuB,EAAE,eAAe,CAAC,mBAAmB,EAAE,sBAAsB,CAIhG,CAAC"}
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
import { ulid } from '../../../../deps/jsr.io/@std/ulid/1.0.0/mod.js';
|
|
14
14
|
import { Observable } from 'rxjs';
|
|
15
15
|
import { DurableWorkflowTrigger, } from '../../../dsl/triggers/DurableTrigger.js';
|
|
16
|
-
import { envVarEnvId } from '../../../internal/constants.js';
|
|
17
16
|
import { VanillaActivation } from '../ObservableCompiler.js';
|
|
18
17
|
export function compileDurableWorkflow(ctx, trigger, signal) {
|
|
19
18
|
return new Observable((subscriber) => {
|
|
@@ -41,42 +40,41 @@ export function compileDurableWorkflow(ctx, trigger, signal) {
|
|
|
41
40
|
continue;
|
|
42
41
|
}
|
|
43
42
|
for (const wf of wfs.workflows) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
await ctx.tracer.startActiveSpan(`durableworkflow-${trigger.id}`, (span) => {
|
|
44
|
+
span.setAttribute('task.id', trigger.id);
|
|
45
|
+
span.setAttribute('task.type', 'durableworkflow');
|
|
46
|
+
span.setAttribute('execution.id', wf.metadata?.executionId ?? '');
|
|
47
|
+
if (wf.metadata?.activationId) {
|
|
48
|
+
span.setAttribute('activation.id', wf.metadata.activationId);
|
|
49
|
+
}
|
|
48
50
|
try {
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
const payload = wf.payload ? atob(wf.payload) : '{}';
|
|
52
|
+
const data = JSON.parse(payload);
|
|
53
|
+
const newContext = ctx.contextProvider.createWithExecutionId(VanillaActivation, data, wf.metadata?.executionId ?? ulid().toString(), {
|
|
54
|
+
workflow: wf,
|
|
55
|
+
onSuccess: (completedContext) => {
|
|
56
|
+
// locked status means we own the workflow and it's not completed yet
|
|
57
|
+
if (wf.status !== 'locked') {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
ctx.queueProvider.complete({
|
|
61
|
+
id: wf.id,
|
|
62
|
+
output: btoa(JSON.stringify(completedContext.data)),
|
|
63
|
+
status: 'completed',
|
|
64
|
+
});
|
|
54
65
|
},
|
|
55
|
-
throwOnError: true,
|
|
56
66
|
});
|
|
57
|
-
|
|
67
|
+
consecutiveErrors = 0;
|
|
68
|
+
subscriber.next(newContext);
|
|
58
69
|
}
|
|
59
70
|
catch (error) {
|
|
60
|
-
|
|
61
|
-
|
|
71
|
+
span.recordException(error instanceof Error ? error : new Error(String(error)));
|
|
72
|
+
ctx.log.error('Error processing workflow', { error });
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
span.end();
|
|
62
76
|
}
|
|
63
|
-
}
|
|
64
|
-
const newContext = ctx.contextProvider.createWithExecutionId(activation ?? VanillaActivation, data, wf.metadata?.executionId ?? ulid().toString(), {
|
|
65
|
-
workflow: wf,
|
|
66
|
-
onSuccess: (completedContext) => {
|
|
67
|
-
// locked status means we own the workflow and it's not completed yet
|
|
68
|
-
if (wf.status !== 'locked') {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
ctx.queueProvider.complete({
|
|
72
|
-
id: wf.id,
|
|
73
|
-
output: btoa(JSON.stringify(completedContext.data)),
|
|
74
|
-
status: 'completed',
|
|
75
|
-
});
|
|
76
|
-
},
|
|
77
77
|
});
|
|
78
|
-
consecutiveErrors = 0;
|
|
79
|
-
subscriber.next(newContext);
|
|
80
78
|
}
|
|
81
79
|
}
|
|
82
80
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryKeyValue.d.ts","sourceRoot":"","sources":["../../../../src/src/kv/memory/MemoryKeyValue.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EACH,eAAe,EACf,aAAa,EACb,cAAc,EACjB,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"MemoryKeyValue.d.ts","sourceRoot":"","sources":["../../../../src/src/kv/memory/MemoryKeyValue.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EACH,eAAe,EACf,aAAa,EACb,cAAc,EACjB,MAAM,uCAAuC,CAAC;AAK/C,qBAAa,cAAe,YAAW,QAAQ;IAC3C,OAAO,CAAC,KAAK,CAAmC;IAE1C,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IA0B/E,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBvD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBnD,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;IAYxE,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC;CAWpD"}
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
* use of this software will be governed by the Apache License, Version 2.0.
|
|
12
12
|
*/
|
|
13
13
|
import { KVNotFoundError } from '../KVNotFoundError.js';
|
|
14
|
+
import opentelemetry from '@opentelemetry/api';
|
|
15
|
+
const tracer = opentelemetry.trace.getTracer('versori-run-kv');
|
|
14
16
|
export class MemoryKeyValue {
|
|
15
17
|
constructor() {
|
|
16
18
|
Object.defineProperty(this, "store", {
|
|
@@ -20,30 +22,79 @@ export class MemoryKeyValue {
|
|
|
20
22
|
value: new Map()
|
|
21
23
|
});
|
|
22
24
|
}
|
|
23
|
-
get(key, options) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
async get(key, options) {
|
|
26
|
+
return await tracer.startActiveSpan('kv.get', (span) => {
|
|
27
|
+
const keyStr = key instanceof Array ? key.join('.') : key;
|
|
28
|
+
span.setAttribute('kv.key', keyStr);
|
|
29
|
+
try {
|
|
30
|
+
const raw = this.store.get(keyStr);
|
|
31
|
+
if (typeof raw === 'undefined') {
|
|
32
|
+
if (options?.throwOnNotFound) {
|
|
33
|
+
throw new KVNotFoundError(keyStr);
|
|
34
|
+
}
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
return raw;
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
span.recordException(error instanceof Error ? error : new Error(String(error)));
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
span.end();
|
|
45
|
+
}
|
|
46
|
+
});
|
|
32
47
|
}
|
|
33
|
-
set(key, value) {
|
|
34
|
-
|
|
35
|
-
|
|
48
|
+
async set(key, value) {
|
|
49
|
+
return await tracer.startActiveSpan('kv.set', (span) => {
|
|
50
|
+
const keyStr = key instanceof Array ? key.join('.') : key;
|
|
51
|
+
span.setAttribute('kv.key', keyStr);
|
|
52
|
+
try {
|
|
53
|
+
this.store.set(keyStr, value);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
span.recordException(error instanceof Error ? error : new Error(String(error)));
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
finally {
|
|
60
|
+
span.end();
|
|
61
|
+
}
|
|
62
|
+
});
|
|
36
63
|
}
|
|
37
|
-
delete(key) {
|
|
38
|
-
|
|
39
|
-
|
|
64
|
+
async delete(key) {
|
|
65
|
+
return await tracer.startActiveSpan('kv.delete', (span) => {
|
|
66
|
+
const keyStr = key instanceof Array ? key.join('.') : key;
|
|
67
|
+
span.setAttribute('kv.key', keyStr);
|
|
68
|
+
try {
|
|
69
|
+
this.store.delete(keyStr);
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
span.recordException(error instanceof Error ? error : new Error(String(error)));
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
span.end();
|
|
77
|
+
}
|
|
78
|
+
});
|
|
40
79
|
}
|
|
41
80
|
list(prefix, options) {
|
|
42
|
-
|
|
43
|
-
|
|
81
|
+
return tracer.startActiveSpan('kv.list', (span) => {
|
|
82
|
+
span.setAttribute('kv.prefix', prefix.join('.'));
|
|
83
|
+
console.log('Listing not implemented', prefix, options);
|
|
84
|
+
const err = new Error('Listing not implemented');
|
|
85
|
+
span.recordException(err);
|
|
86
|
+
span.end();
|
|
87
|
+
return Promise.reject(err);
|
|
88
|
+
});
|
|
44
89
|
}
|
|
45
90
|
count(prefix) {
|
|
46
|
-
|
|
47
|
-
|
|
91
|
+
return tracer.startActiveSpan('kv.count', (span) => {
|
|
92
|
+
span.setAttribute('kv.prefix', prefix.join('.'));
|
|
93
|
+
console.log('Count not implemented', prefix);
|
|
94
|
+
const err = new Error('Count not implemented');
|
|
95
|
+
span.recordException(err);
|
|
96
|
+
span.end();
|
|
97
|
+
return Promise.reject(err);
|
|
98
|
+
});
|
|
48
99
|
}
|
|
49
100
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NatsKeyValue.d.ts","sourceRoot":"","sources":["../../../../src/src/kv/nats/NatsKeyValue.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,EAAE,EAAW,MAAM,mDAAmD,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EACH,eAAe,EACf,aAAa,EACb,cAAc,EACjB,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"NatsKeyValue.d.ts","sourceRoot":"","sources":["../../../../src/src/kv/nats/NatsKeyValue.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,EAAE,EAAW,MAAM,mDAAmD,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EACH,eAAe,EACf,aAAa,EACb,cAAc,EACjB,MAAM,uCAAuC,CAAC;AAK/C,qBAAa,YAAa,YAAW,QAAQ;IAC7B,OAAO,CAAC,QAAQ,CAAC,EAAE;IAAM,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAA/B,EAAE,EAAE,EAAE,EAAmB,MAAM,EAAE,MAAM;IAE9D,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,GAAE,UAAU,CAAC,CAAC,CAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAqCnF,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBvD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBnD,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;IAYxE,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC;IAYjD,OAAO,CAAC,WAAW;CAGtB"}
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
* use of this software will be governed by the Apache License, Version 2.0.
|
|
12
12
|
*/
|
|
13
13
|
import { KVNotFoundError } from '../KVNotFoundError.js';
|
|
14
|
+
import opentelemetry from '@opentelemetry/api';
|
|
15
|
+
const tracer = opentelemetry.trace.getTracer('versori-run-kv');
|
|
14
16
|
export class NatsKeyValue {
|
|
15
17
|
constructor(kv, prefix) {
|
|
16
18
|
Object.defineProperty(this, "kv", {
|
|
@@ -27,39 +29,91 @@ export class NatsKeyValue {
|
|
|
27
29
|
});
|
|
28
30
|
}
|
|
29
31
|
async get(key, options = {}) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
return await tracer.startActiveSpan('kv.get', async (span) => {
|
|
33
|
+
const keyStr = key instanceof Array ? key.join('.') : key;
|
|
34
|
+
span.setAttribute('kv.key', keyStr);
|
|
35
|
+
try {
|
|
36
|
+
let entry;
|
|
37
|
+
try {
|
|
38
|
+
entry = await this.kv.get(this.generateKey(keyStr));
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
span.recordException(error instanceof Error ? error : new Error(String(error)));
|
|
42
|
+
console.error('Unknown error reading from KV store', error);
|
|
43
|
+
throw new Error('Unknown error reading from KV store');
|
|
44
|
+
}
|
|
45
|
+
if (!entry || ['DEL', 'PURGE'].includes(entry.operation)) {
|
|
46
|
+
if (options.throwOnNotFound) {
|
|
47
|
+
throw new KVNotFoundError(keyStr);
|
|
48
|
+
}
|
|
49
|
+
else if (typeof options.defaultValue !== 'undefined') {
|
|
50
|
+
return options.defaultValue;
|
|
51
|
+
}
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
return entry.json();
|
|
41
55
|
}
|
|
42
|
-
|
|
43
|
-
|
|
56
|
+
catch (error) {
|
|
57
|
+
span.recordException(error instanceof Error ? error : new Error(String(error)));
|
|
58
|
+
throw error;
|
|
44
59
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
60
|
+
finally {
|
|
61
|
+
span.end();
|
|
62
|
+
}
|
|
63
|
+
});
|
|
48
64
|
}
|
|
49
65
|
async set(key, value) {
|
|
50
|
-
|
|
51
|
-
|
|
66
|
+
return await tracer.startActiveSpan('kv.set', async (span) => {
|
|
67
|
+
const keyStr = key instanceof Array ? key.join('.') : key;
|
|
68
|
+
span.setAttribute('kv.key', keyStr);
|
|
69
|
+
try {
|
|
70
|
+
const payload = JSON.stringify(value);
|
|
71
|
+
await this.kv.put(this.generateKey(keyStr), payload);
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
span.recordException(error instanceof Error ? error : new Error(String(error)));
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
finally {
|
|
78
|
+
span.end();
|
|
79
|
+
}
|
|
80
|
+
});
|
|
52
81
|
}
|
|
53
82
|
async delete(key) {
|
|
54
|
-
await
|
|
83
|
+
return await tracer.startActiveSpan('kv.delete', async (span) => {
|
|
84
|
+
const keyStr = key instanceof Array ? key.join('.') : key;
|
|
85
|
+
span.setAttribute('kv.key', keyStr);
|
|
86
|
+
try {
|
|
87
|
+
await this.kv.delete(this.generateKey(keyStr));
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
span.recordException(error instanceof Error ? error : new Error(String(error)));
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
finally {
|
|
94
|
+
span.end();
|
|
95
|
+
}
|
|
96
|
+
});
|
|
55
97
|
}
|
|
56
98
|
list(prefix, options) {
|
|
57
|
-
|
|
58
|
-
|
|
99
|
+
return tracer.startActiveSpan('kv.list', (span) => {
|
|
100
|
+
span.setAttribute('kv.prefix', prefix.join('.'));
|
|
101
|
+
console.log('Listing not implemented', prefix, options);
|
|
102
|
+
const err = new Error('Listing not implemented');
|
|
103
|
+
span.recordException(err);
|
|
104
|
+
span.end();
|
|
105
|
+
return Promise.reject(err);
|
|
106
|
+
});
|
|
59
107
|
}
|
|
60
108
|
count(prefix) {
|
|
61
|
-
|
|
62
|
-
|
|
109
|
+
return tracer.startActiveSpan('kv.count', (span) => {
|
|
110
|
+
span.setAttribute('kv.prefix', prefix.join('.'));
|
|
111
|
+
console.log('Count not implemented', prefix);
|
|
112
|
+
const err = new Error('Count not implemented');
|
|
113
|
+
span.recordException(err);
|
|
114
|
+
span.end();
|
|
115
|
+
return Promise.reject(err);
|
|
116
|
+
});
|
|
63
117
|
}
|
|
64
118
|
generateKey(key) {
|
|
65
119
|
return `${this.prefix}.${key instanceof Array ? key.join('.') : key}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SDKKeyValue.d.ts","sourceRoot":"","sources":["../../../../src/src/kv/sdk/SDKKeyValue.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,MAAM,wDAAwD,CAAC;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4DAA4D,CAAC;AACjG,OAAO,EAAE,aAAa,EAAE,MAAM,sDAAsD,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,uDAAuD,CAAC;AAGvF,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"SDKKeyValue.d.ts","sourceRoot":"","sources":["../../../../src/src/kv/sdk/SDKKeyValue.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,MAAM,wDAAwD,CAAC;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4DAA4D,CAAC;AACjG,OAAO,EAAE,aAAa,EAAE,MAAM,sDAAsD,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,uDAAuD,CAAC;AAGvF,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAKtD,qBAAa,WAAY,YAAW,QAAQ;IAC5B,OAAO,CAAC,QAAQ,CAAC,KAAK;IAAuB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAnD,KAAK,EAAE,mBAAmB,EAAmB,MAAM,EAAE,MAAM;IAElF,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,GAAE,UAAU,CAAC,CAAC,CAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAuCnF,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,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