@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
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { KvOperationsService } from '../../dsl/http/versori/kvapi/services/KvOperationsService.js';
|
|
14
14
|
import { QueryOperationsService } from '../../dsl/http/versori/kvapi/services/QueryOperationsService.js';
|
|
15
|
+
import opentelemetry from '@opentelemetry/api';
|
|
16
|
+
const tracer = opentelemetry.trace.getTracer('versori-run-kv');
|
|
15
17
|
export class SDKKeyValue {
|
|
16
18
|
constructor(store, prefix) {
|
|
17
19
|
Object.defineProperty(this, "store", {
|
|
@@ -28,59 +30,122 @@ export class SDKKeyValue {
|
|
|
28
30
|
});
|
|
29
31
|
}
|
|
30
32
|
async get(key, options = {}) {
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
return await tracer.startActiveSpan('kv.get', async (span) => {
|
|
34
|
+
const keyStr = key instanceof Array ? key.join('/') : key;
|
|
35
|
+
span.setAttribute('kv.key', keyStr);
|
|
36
|
+
span.setAttribute('kv.store_id', this.store.id);
|
|
37
|
+
try {
|
|
38
|
+
const k = this.generateKey(keyStr);
|
|
39
|
+
const entry = await KvOperationsService.getKv(this.store.id, k);
|
|
40
|
+
if (entry.value === undefined) {
|
|
41
|
+
if (options.throwOnNotFound) {
|
|
42
|
+
throw new Error('Key not found');
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
37
45
|
}
|
|
38
|
-
return
|
|
46
|
+
return JSON.parse(String(entry.value));
|
|
39
47
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
catch (error) {
|
|
49
|
+
if (options.throwOnNotFound && error instanceof Error &&
|
|
50
|
+
error.message === 'Key not found') {
|
|
51
|
+
throw new Error('Key not found');
|
|
52
|
+
}
|
|
53
|
+
else if (!options.throwOnNotFound) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
span.recordException(error instanceof Error ? error : new Error(String(error)));
|
|
57
|
+
console.error('Unknown error reading from KV store', error);
|
|
58
|
+
throw new Error('Unknown error reading from KV store');
|
|
46
59
|
}
|
|
47
|
-
|
|
48
|
-
|
|
60
|
+
finally {
|
|
61
|
+
span.end();
|
|
49
62
|
}
|
|
50
|
-
|
|
51
|
-
throw new Error('Unknown error reading from KV store');
|
|
52
|
-
}
|
|
63
|
+
});
|
|
53
64
|
}
|
|
54
65
|
async set(key, value) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
+
span.setAttribute('kv.store_id', this.store.id);
|
|
70
|
+
try {
|
|
71
|
+
const payload = JSON.stringify(value);
|
|
72
|
+
const k = this.generateKey(keyStr);
|
|
73
|
+
await KvOperationsService.setKv(this.store.id, k, {
|
|
74
|
+
value: payload,
|
|
75
|
+
options: {},
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
span.recordException(error instanceof Error ? error : new Error(String(error)));
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
finally {
|
|
83
|
+
span.end();
|
|
84
|
+
}
|
|
60
85
|
});
|
|
61
86
|
}
|
|
62
87
|
async delete(key) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
88
|
+
return await tracer.startActiveSpan('kv.delete', async (span) => {
|
|
89
|
+
const keyStr = key instanceof Array ? key.join('/') : key;
|
|
90
|
+
span.setAttribute('kv.key', keyStr);
|
|
91
|
+
span.setAttribute('kv.store_id', this.store.id);
|
|
92
|
+
try {
|
|
93
|
+
const k = this.generateKey(keyStr);
|
|
94
|
+
await KvOperationsService.deleteKv(this.store.id, k, {
|
|
95
|
+
options: {},
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
span.recordException(error instanceof Error ? error : new Error(String(error)));
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
finally {
|
|
103
|
+
span.end();
|
|
104
|
+
}
|
|
66
105
|
});
|
|
67
106
|
}
|
|
68
107
|
async count(prefix) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
108
|
+
return await tracer.startActiveSpan('kv.count', async (span) => {
|
|
109
|
+
span.setAttribute('kv.prefix', prefix.join('/'));
|
|
110
|
+
span.setAttribute('kv.store_id', this.store.id);
|
|
111
|
+
try {
|
|
112
|
+
const k = this.generateKey(prefix).split('/');
|
|
113
|
+
return await QueryOperationsService.countKv(this.store.id, {
|
|
114
|
+
selector: {
|
|
115
|
+
prefix: k,
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
span.recordException(error instanceof Error ? error : new Error(String(error)));
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
finally {
|
|
124
|
+
span.end();
|
|
125
|
+
}
|
|
74
126
|
});
|
|
75
127
|
}
|
|
76
128
|
async list(prefix, options) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
129
|
+
return await tracer.startActiveSpan('kv.list', async (span) => {
|
|
130
|
+
span.setAttribute('kv.prefix', prefix.join('/'));
|
|
131
|
+
span.setAttribute('kv.store_id', this.store.id);
|
|
132
|
+
try {
|
|
133
|
+
const k = this.generateKey(prefix).split('/');
|
|
134
|
+
return await QueryOperationsService.listKv(this.store.id, {
|
|
135
|
+
selector: {
|
|
136
|
+
prefix: k,
|
|
137
|
+
...options?.selector,
|
|
138
|
+
},
|
|
139
|
+
options: options?.options,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
span.recordException(error instanceof Error ? error : new Error(String(error)));
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
146
|
+
finally {
|
|
147
|
+
span.end();
|
|
148
|
+
}
|
|
84
149
|
});
|
|
85
150
|
}
|
|
86
151
|
generateKey(key) {
|
package/package.json
CHANGED
|
@@ -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"}
|
|
@@ -44,42 +44,59 @@ function compileDurableWorkflow(ctx, trigger, signal) {
|
|
|
44
44
|
continue;
|
|
45
45
|
}
|
|
46
46
|
for (const wf of wfs.workflows) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
await ctx.tracer.startActiveSpan(`durableworkflow-${trigger.id}`, async (span) => {
|
|
48
|
+
span.setAttribute('task.id', trigger.id);
|
|
49
|
+
span.setAttribute('task.type', 'durableworkflow');
|
|
50
|
+
span.setAttribute('execution.id', wf.metadata?.executionId ?? '');
|
|
51
|
+
if (wf.metadata?.activationId) {
|
|
52
|
+
span.setAttribute('activation.id', wf.metadata.activationId);
|
|
53
|
+
}
|
|
51
54
|
try {
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
const payload = wf.payload ? atob(wf.payload) : '{}';
|
|
56
|
+
const data = JSON.parse(payload);
|
|
57
|
+
let activation;
|
|
58
|
+
if (wf.metadata?.activationId) {
|
|
59
|
+
try {
|
|
60
|
+
const { data } = await ctx.platformApi.getActivation({
|
|
61
|
+
path: {
|
|
62
|
+
activation_id: wf.metadata.activationId,
|
|
63
|
+
organisation_id: ctx.organisationId,
|
|
64
|
+
environment_id: Deno.env.get(constants_js_1.envVarEnvId) || 'development',
|
|
65
|
+
},
|
|
66
|
+
throwOnError: true,
|
|
67
|
+
});
|
|
68
|
+
activation = data;
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
ctx.log.error('Failed to get activation', { error });
|
|
72
|
+
throw new Error('Failed to get activation');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const newContext = ctx.contextProvider.createWithExecutionId(activation, data, wf.metadata?.executionId ?? (0, mod_js_1.ulid)().toString(), {
|
|
76
|
+
workflow: wf,
|
|
77
|
+
onSuccess: (completedContext) => {
|
|
78
|
+
// locked status means we own the workflow and it's not completed yet
|
|
79
|
+
if (wf.status !== 'locked') {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
ctx.queueProvider.complete({
|
|
83
|
+
id: wf.id,
|
|
84
|
+
output: btoa(JSON.stringify(completedContext.data)),
|
|
85
|
+
status: 'completed',
|
|
86
|
+
});
|
|
57
87
|
},
|
|
58
|
-
throwOnError: true,
|
|
59
88
|
});
|
|
60
|
-
|
|
89
|
+
consecutiveErrors = 0;
|
|
90
|
+
subscriber.next(newContext);
|
|
61
91
|
}
|
|
62
92
|
catch (error) {
|
|
63
|
-
|
|
64
|
-
|
|
93
|
+
span.recordException(error instanceof Error ? error : new Error(String(error)));
|
|
94
|
+
ctx.log.error('Error processing workflow', { error });
|
|
95
|
+
}
|
|
96
|
+
finally {
|
|
97
|
+
span.end();
|
|
65
98
|
}
|
|
66
|
-
}
|
|
67
|
-
const newContext = ctx.contextProvider.createWithExecutionId(activation, data, wf.metadata?.executionId ?? (0, mod_js_1.ulid)().toString(), {
|
|
68
|
-
workflow: wf,
|
|
69
|
-
onSuccess: (completedContext) => {
|
|
70
|
-
// locked status means we own the workflow and it's not completed yet
|
|
71
|
-
if (wf.status !== 'locked') {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
ctx.queueProvider.complete({
|
|
75
|
-
id: wf.id,
|
|
76
|
-
output: btoa(JSON.stringify(completedContext.data)),
|
|
77
|
-
status: 'completed',
|
|
78
|
-
});
|
|
79
|
-
},
|
|
80
99
|
});
|
|
81
|
-
consecutiveErrors = 0;
|
|
82
|
-
subscriber.next(newContext);
|
|
83
100
|
}
|
|
84
101
|
}
|
|
85
102
|
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,gB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E,EAAE,GAAG,CAAC,CAAC;AAE/B,qBAAa,kBAAkB;IAC3B,OAAO,CAAC,aAAa,CAAkD;IACvE,OAAO,CAAC,gBAAgB,CAAgD;;IAkBxE,WAAW,CAAC,EAAE,GAAG,GAAG,EAAE,GAAG,GAAG,GAAG,EAAE,KAAK,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,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AC,cAAc,CAAS;gBAGV,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,kBAAkB,EAC5B,eAAe,EAAE,eAAe,EAChC,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,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"}
|
|
@@ -32,7 +32,6 @@ const Issues_js_1 = require("../../issues/Issues.js");
|
|
|
32
32
|
const MemoryKeyValueProvider_js_1 = require("../../kv/memory/MemoryKeyValueProvider.js");
|
|
33
33
|
const SDKKeyValueProvider_js_1 = require("../../kv/sdk/SDKKeyValueProvider.js");
|
|
34
34
|
const ConsoleLogger_js_1 = require("../../observability/logging/ConsoleLogger.js");
|
|
35
|
-
const PlatformApi_js_1 = require("../../services/platform/PlatformApi.js");
|
|
36
35
|
const Queue_js_1 = require("../durable/Queue.js");
|
|
37
36
|
const ObservableCompiler_js_1 = require("./ObservableCompiler.js");
|
|
38
37
|
function getKVProvider(runLocal) {
|
|
@@ -65,7 +64,7 @@ function getKVProvider(runLocal) {
|
|
|
65
64
|
* ```
|
|
66
65
|
*/
|
|
67
66
|
class VanillaInterpreter {
|
|
68
|
-
constructor(log, compiler, contextProvider, webhookRouter, cronRouter, cronRegistry, cnxFetchFactory, cronProvider, tracer, cfgReader,
|
|
67
|
+
constructor(log, compiler, contextProvider, webhookRouter, cronRouter, cronRegistry, cnxFetchFactory, cronProvider, tracer, cfgReader, queueProvider, otelSDK) {
|
|
69
68
|
Object.defineProperty(this, "log", {
|
|
70
69
|
enumerable: true,
|
|
71
70
|
configurable: true,
|
|
@@ -126,12 +125,6 @@ class VanillaInterpreter {
|
|
|
126
125
|
writable: true,
|
|
127
126
|
value: cfgReader
|
|
128
127
|
});
|
|
129
|
-
Object.defineProperty(this, "platformApi", {
|
|
130
|
-
enumerable: true,
|
|
131
|
-
configurable: true,
|
|
132
|
-
writable: true,
|
|
133
|
-
value: platformApi
|
|
134
|
-
});
|
|
135
128
|
Object.defineProperty(this, "queueProvider", {
|
|
136
129
|
enumerable: true,
|
|
137
130
|
configurable: true,
|
|
@@ -179,7 +172,7 @@ class VanillaInterpreter {
|
|
|
179
172
|
}
|
|
180
173
|
}
|
|
181
174
|
static async newInstance(options = {}) {
|
|
182
|
-
const log = options.logger || new ConsoleLogger_js_1.ConsoleLogger();
|
|
175
|
+
const log = options.logger || new ConsoleLogger_js_1.ConsoleLogger("info");
|
|
183
176
|
const compiler = options.compiler || new ObservableCompiler_js_1.ObservableCompiler();
|
|
184
177
|
const serviceName = Deno.env.get(constants_js_1.envVarProjectId) || 'example-service';
|
|
185
178
|
const environmentID = Deno.env.get(constants_js_1.envVarEnvId) || 'development';
|
|
@@ -217,13 +210,13 @@ class VanillaInterpreter {
|
|
|
217
210
|
const connectionFactory = new VanillaConnectionFactory_js_1.DefaultConnectionFactory();
|
|
218
211
|
const issuesProvider = new Issues_js_1.IssueImpl(log);
|
|
219
212
|
if (options.contextProvider) {
|
|
220
|
-
return new VanillaInterpreter(log, compiler, options.contextProvider, express_1.default.Router(), express_1.default.Router(), new Map(), connectionFactory, cronapi_js_1.CronAPIClient.fromEnv(), tracer, configReader,
|
|
213
|
+
return new VanillaInterpreter(log, compiler, options.contextProvider, express_1.default.Router(), express_1.default.Router(), new Map(), connectionFactory, cronapi_js_1.CronAPIClient.fromEnv(), tracer, configReader, queueProvider, otelSDK);
|
|
221
214
|
}
|
|
222
215
|
const kvp = await getKVProvider(runLocal);
|
|
223
216
|
const organisationId = Deno.env.get(constants_js_1.envVarOrgId) || 'development';
|
|
224
217
|
const environmentId = Deno.env.get(constants_js_1.envVarEnvId) || 'development';
|
|
225
218
|
const ctxProvider = new VanillaContext_js_1.VanillaContextProvider(log, kvp, organisationId, environmentId, issuesProvider, queueProvider);
|
|
226
|
-
return new VanillaInterpreter(log, compiler, ctxProvider, express_1.default.Router(), express_1.default.Router(), new Map(), connectionFactory, cronapi_js_1.CronAPIClient.fromEnv(), tracer, configReader,
|
|
219
|
+
return new VanillaInterpreter(log, compiler, ctxProvider, express_1.default.Router(), express_1.default.Router(), new Map(), connectionFactory, cronapi_js_1.CronAPIClient.fromEnv(), tracer, configReader, queueProvider, otelSDK);
|
|
227
220
|
}
|
|
228
221
|
register(workflow, options) {
|
|
229
222
|
const localAbortController = new AbortController();
|
|
@@ -239,7 +232,6 @@ class VanillaInterpreter {
|
|
|
239
232
|
tracer: this.tracer,
|
|
240
233
|
contextProvider: this.contextProvider,
|
|
241
234
|
webhookRouter: this.webhookRouter,
|
|
242
|
-
platformApi: this.platformApi,
|
|
243
235
|
queueProvider: this.queueProvider,
|
|
244
236
|
cronRouter: this.cronRouter,
|
|
245
237
|
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"}
|
|
@@ -17,7 +17,6 @@ exports.compileDurableWorkflow = compileDurableWorkflow;
|
|
|
17
17
|
const mod_js_1 = require("../../../../deps/jsr.io/@std/ulid/1.0.0/mod.js");
|
|
18
18
|
const rxjs_1 = require("rxjs");
|
|
19
19
|
const DurableTrigger_js_1 = require("../../../dsl/triggers/DurableTrigger.js");
|
|
20
|
-
const constants_js_1 = require("../../../internal/constants.js");
|
|
21
20
|
const ObservableCompiler_js_1 = require("../ObservableCompiler.js");
|
|
22
21
|
function compileDurableWorkflow(ctx, trigger, signal) {
|
|
23
22
|
return new rxjs_1.Observable((subscriber) => {
|
|
@@ -45,42 +44,41 @@ function compileDurableWorkflow(ctx, trigger, signal) {
|
|
|
45
44
|
continue;
|
|
46
45
|
}
|
|
47
46
|
for (const wf of wfs.workflows) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
await ctx.tracer.startActiveSpan(`durableworkflow-${trigger.id}`, (span) => {
|
|
48
|
+
span.setAttribute('task.id', trigger.id);
|
|
49
|
+
span.setAttribute('task.type', 'durableworkflow');
|
|
50
|
+
span.setAttribute('execution.id', wf.metadata?.executionId ?? '');
|
|
51
|
+
if (wf.metadata?.activationId) {
|
|
52
|
+
span.setAttribute('activation.id', wf.metadata.activationId);
|
|
53
|
+
}
|
|
52
54
|
try {
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
const payload = wf.payload ? atob(wf.payload) : '{}';
|
|
56
|
+
const data = JSON.parse(payload);
|
|
57
|
+
const newContext = ctx.contextProvider.createWithExecutionId(ObservableCompiler_js_1.VanillaActivation, data, wf.metadata?.executionId ?? (0, mod_js_1.ulid)().toString(), {
|
|
58
|
+
workflow: wf,
|
|
59
|
+
onSuccess: (completedContext) => {
|
|
60
|
+
// locked status means we own the workflow and it's not completed yet
|
|
61
|
+
if (wf.status !== 'locked') {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
ctx.queueProvider.complete({
|
|
65
|
+
id: wf.id,
|
|
66
|
+
output: btoa(JSON.stringify(completedContext.data)),
|
|
67
|
+
status: 'completed',
|
|
68
|
+
});
|
|
58
69
|
},
|
|
59
|
-
throwOnError: true,
|
|
60
70
|
});
|
|
61
|
-
|
|
71
|
+
consecutiveErrors = 0;
|
|
72
|
+
subscriber.next(newContext);
|
|
62
73
|
}
|
|
63
74
|
catch (error) {
|
|
64
|
-
|
|
65
|
-
|
|
75
|
+
span.recordException(error instanceof Error ? error : new Error(String(error)));
|
|
76
|
+
ctx.log.error('Error processing workflow', { error });
|
|
77
|
+
}
|
|
78
|
+
finally {
|
|
79
|
+
span.end();
|
|
66
80
|
}
|
|
67
|
-
}
|
|
68
|
-
const newContext = ctx.contextProvider.createWithExecutionId(activation ?? ObservableCompiler_js_1.VanillaActivation, data, wf.metadata?.executionId ?? (0, mod_js_1.ulid)().toString(), {
|
|
69
|
-
workflow: wf,
|
|
70
|
-
onSuccess: (completedContext) => {
|
|
71
|
-
// locked status means we own the workflow and it's not completed yet
|
|
72
|
-
if (wf.status !== 'locked') {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
ctx.queueProvider.complete({
|
|
76
|
-
id: wf.id,
|
|
77
|
-
output: btoa(JSON.stringify(completedContext.data)),
|
|
78
|
-
status: 'completed',
|
|
79
|
-
});
|
|
80
|
-
},
|
|
81
81
|
});
|
|
82
|
-
consecutiveErrors = 0;
|
|
83
|
-
subscriber.next(newContext);
|
|
84
82
|
}
|
|
85
83
|
}
|
|
86
84
|
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,9 +11,14 @@
|
|
|
11
11
|
* As of the Change Date, in accordance with the Business Source License,
|
|
12
12
|
* use of this software will be governed by the Apache License, Version 2.0.
|
|
13
13
|
*/
|
|
14
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
+
};
|
|
14
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
18
|
exports.MemoryKeyValue = void 0;
|
|
16
19
|
const KVNotFoundError_js_1 = require("../KVNotFoundError.js");
|
|
20
|
+
const api_1 = __importDefault(require("@opentelemetry/api"));
|
|
21
|
+
const tracer = api_1.default.trace.getTracer('versori-run-kv');
|
|
17
22
|
class MemoryKeyValue {
|
|
18
23
|
constructor() {
|
|
19
24
|
Object.defineProperty(this, "store", {
|
|
@@ -23,31 +28,80 @@ class MemoryKeyValue {
|
|
|
23
28
|
value: new Map()
|
|
24
29
|
});
|
|
25
30
|
}
|
|
26
|
-
get(key, options) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
async get(key, options) {
|
|
32
|
+
return await tracer.startActiveSpan('kv.get', (span) => {
|
|
33
|
+
const keyStr = key instanceof Array ? key.join('.') : key;
|
|
34
|
+
span.setAttribute('kv.key', keyStr);
|
|
35
|
+
try {
|
|
36
|
+
const raw = this.store.get(keyStr);
|
|
37
|
+
if (typeof raw === 'undefined') {
|
|
38
|
+
if (options?.throwOnNotFound) {
|
|
39
|
+
throw new KVNotFoundError_js_1.KVNotFoundError(keyStr);
|
|
40
|
+
}
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
return raw;
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
span.recordException(error instanceof Error ? error : new Error(String(error)));
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
span.end();
|
|
51
|
+
}
|
|
52
|
+
});
|
|
35
53
|
}
|
|
36
|
-
set(key, value) {
|
|
37
|
-
|
|
38
|
-
|
|
54
|
+
async set(key, value) {
|
|
55
|
+
return await tracer.startActiveSpan('kv.set', (span) => {
|
|
56
|
+
const keyStr = key instanceof Array ? key.join('.') : key;
|
|
57
|
+
span.setAttribute('kv.key', keyStr);
|
|
58
|
+
try {
|
|
59
|
+
this.store.set(keyStr, value);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
span.recordException(error instanceof Error ? error : new Error(String(error)));
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
span.end();
|
|
67
|
+
}
|
|
68
|
+
});
|
|
39
69
|
}
|
|
40
|
-
delete(key) {
|
|
41
|
-
|
|
42
|
-
|
|
70
|
+
async delete(key) {
|
|
71
|
+
return await tracer.startActiveSpan('kv.delete', (span) => {
|
|
72
|
+
const keyStr = key instanceof Array ? key.join('.') : key;
|
|
73
|
+
span.setAttribute('kv.key', keyStr);
|
|
74
|
+
try {
|
|
75
|
+
this.store.delete(keyStr);
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
span.recordException(error instanceof Error ? error : new Error(String(error)));
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
finally {
|
|
82
|
+
span.end();
|
|
83
|
+
}
|
|
84
|
+
});
|
|
43
85
|
}
|
|
44
86
|
list(prefix, options) {
|
|
45
|
-
|
|
46
|
-
|
|
87
|
+
return tracer.startActiveSpan('kv.list', (span) => {
|
|
88
|
+
span.setAttribute('kv.prefix', prefix.join('.'));
|
|
89
|
+
console.log('Listing not implemented', prefix, options);
|
|
90
|
+
const err = new Error('Listing not implemented');
|
|
91
|
+
span.recordException(err);
|
|
92
|
+
span.end();
|
|
93
|
+
return Promise.reject(err);
|
|
94
|
+
});
|
|
47
95
|
}
|
|
48
96
|
count(prefix) {
|
|
49
|
-
|
|
50
|
-
|
|
97
|
+
return tracer.startActiveSpan('kv.count', (span) => {
|
|
98
|
+
span.setAttribute('kv.prefix', prefix.join('.'));
|
|
99
|
+
console.log('Count not implemented', prefix);
|
|
100
|
+
const err = new Error('Count not implemented');
|
|
101
|
+
span.recordException(err);
|
|
102
|
+
span.end();
|
|
103
|
+
return Promise.reject(err);
|
|
104
|
+
});
|
|
51
105
|
}
|
|
52
106
|
}
|
|
53
107
|
exports.MemoryKeyValue = MemoryKeyValue;
|
|
@@ -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,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