@versori/run 0.2.1-alpha.2 → 0.2.2-alpha.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/esm/src/dsl/http/default.d.ts +2 -2
- package/esm/src/dsl/http/default.d.ts.map +1 -1
- package/esm/src/dsl/http/default.js +6 -5
- package/esm/src/dsl/http/types.d.ts +2 -2
- package/esm/src/dsl/http/types.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/constants.d.ts +2 -0
- package/esm/src/dsl/http/versori/constants.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/constants.js +2 -0
- package/esm/src/dsl/http/versori/contextcredentials.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/credentials/client.d.ts +1 -1
- package/esm/src/dsl/http/versori/credentials/client.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/credentials/client.js +4 -4
- package/esm/src/dsl/http/versori/roundtripper.d.ts +8 -6
- package/esm/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/roundtripper.js +123 -73
- package/esm/src/dsl/tasks/HttpTask.d.ts +1 -1
- package/esm/src/dsl/tasks/HttpTask.d.ts.map +1 -1
- package/esm/src/dsl/tasks/HttpTask.js +4 -2
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +6 -2
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.js +68 -14
- package/esm/src/interpreter/memory/ObservableCompiler.d.ts +2 -0
- package/esm/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/catch.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/catch.js +24 -7
- package/esm/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/fn.js +12 -6
- package/esm/src/interpreter/memory/compilers/http.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/http.js +30 -6
- package/esm/src/interpreter/memory/compilers/parallel.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/schedule.js +29 -3
- package/esm/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
- package/package.json +5 -1
- package/script/src/dsl/http/default.d.ts +2 -2
- package/script/src/dsl/http/default.d.ts.map +1 -1
- package/script/src/dsl/http/default.js +6 -5
- package/script/src/dsl/http/types.d.ts +2 -2
- package/script/src/dsl/http/types.d.ts.map +1 -1
- package/script/src/dsl/http/versori/constants.d.ts +2 -0
- package/script/src/dsl/http/versori/constants.d.ts.map +1 -1
- package/script/src/dsl/http/versori/constants.js +3 -1
- package/script/src/dsl/http/versori/contextcredentials.d.ts.map +1 -1
- package/script/src/dsl/http/versori/credentials/client.d.ts +1 -1
- package/script/src/dsl/http/versori/credentials/client.d.ts.map +1 -1
- package/script/src/dsl/http/versori/credentials/client.js +3 -3
- package/script/src/dsl/http/versori/roundtripper.d.ts +8 -6
- package/script/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
- package/script/src/dsl/http/versori/roundtripper.js +123 -73
- package/script/src/dsl/tasks/HttpTask.d.ts +1 -1
- package/script/src/dsl/tasks/HttpTask.d.ts.map +1 -1
- package/script/src/dsl/tasks/HttpTask.js +4 -2
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts +6 -2
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/memory/MemoryInterpreter.js +68 -14
- package/script/src/interpreter/memory/ObservableCompiler.d.ts +2 -0
- package/script/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/catch.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/catch.js +24 -7
- package/script/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/fn.js +12 -6
- package/script/src/interpreter/memory/compilers/http.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/http.js +30 -6
- package/script/src/interpreter/memory/compilers/parallel.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/schedule.js +29 -3
- package/script/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
|
@@ -4,11 +4,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.MemoryInterpreter = void 0;
|
|
7
|
-
const
|
|
7
|
+
const api_1 = __importDefault(require("@opentelemetry/api"));
|
|
8
|
+
const exporter_trace_otlp_proto_1 = require("@opentelemetry/exporter-trace-otlp-proto");
|
|
9
|
+
const resources_1 = require("@opentelemetry/resources");
|
|
10
|
+
const sdk_node_1 = require("@opentelemetry/sdk-node");
|
|
8
11
|
const express_1 = __importDefault(require("express"));
|
|
12
|
+
const express_xml_bodyparser_1 = __importDefault(require("express-xml-bodyparser"));
|
|
9
13
|
const rxjs_1 = require("rxjs");
|
|
10
14
|
const ContextProvider_js_1 = require("../../context/ContextProvider.js");
|
|
11
15
|
const default_js_1 = require("../../dsl/http/default.js");
|
|
16
|
+
const constants_js_1 = require("../../dsl/http/versori/constants.js");
|
|
17
|
+
const cronapi_js_1 = require("../../dsl/http/versori/cronapi.js");
|
|
12
18
|
const platformapi_js_1 = require("../../dsl/http/versori/platformapi.js");
|
|
13
19
|
const roundtripper_js_1 = require("../../dsl/http/versori/roundtripper.js");
|
|
14
20
|
const Workflow_js_1 = require("../../dsl/Workflow.js");
|
|
@@ -16,9 +22,8 @@ const MemoryKeyValueProvider_js_1 = require("../../kv/memory/MemoryKeyValueProvi
|
|
|
16
22
|
const NatsKeyValueProvider_js_1 = require("../../kv/nats/NatsKeyValueProvider.js");
|
|
17
23
|
const ConsoleLogger_js_1 = require("../../observability/logging/ConsoleLogger.js");
|
|
18
24
|
const ObservableCompiler_js_1 = require("./ObservableCompiler.js");
|
|
19
|
-
const cronapi_js_1 = require("../../dsl/http/versori/cronapi.js");
|
|
20
25
|
class MemoryInterpreter {
|
|
21
|
-
constructor(log, compiler, contextProvider, roundTripperFactory, router, cronRegistry, connectionProvider, cronProvider) {
|
|
26
|
+
constructor(log, compiler, contextProvider, roundTripperFactory, router, cronRegistry, connectionProvider, cronProvider, tracer, otelSDK) {
|
|
22
27
|
Object.defineProperty(this, "log", {
|
|
23
28
|
enumerable: true,
|
|
24
29
|
configurable: true,
|
|
@@ -67,6 +72,18 @@ class MemoryInterpreter {
|
|
|
67
72
|
writable: true,
|
|
68
73
|
value: cronProvider
|
|
69
74
|
});
|
|
75
|
+
Object.defineProperty(this, "tracer", {
|
|
76
|
+
enumerable: true,
|
|
77
|
+
configurable: true,
|
|
78
|
+
writable: true,
|
|
79
|
+
value: tracer
|
|
80
|
+
});
|
|
81
|
+
Object.defineProperty(this, "otelSDK", {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
configurable: true,
|
|
84
|
+
writable: true,
|
|
85
|
+
value: otelSDK
|
|
86
|
+
});
|
|
70
87
|
Object.defineProperty(this, "registeredWorkflows", {
|
|
71
88
|
enumerable: true,
|
|
72
89
|
configurable: true,
|
|
@@ -92,7 +109,7 @@ class MemoryInterpreter {
|
|
|
92
109
|
value: false
|
|
93
110
|
});
|
|
94
111
|
if (typeof this.log === 'undefined') {
|
|
95
|
-
// this captures the old way of instantiating the MemoryInterpreter and provides an
|
|
112
|
+
// this captures the old way of instantiating the MemoryInterpreter and provides an
|
|
96
113
|
// error message back to the user to let them know they should use the new way.
|
|
97
114
|
throw new Error('MemoryInterpreter should not be instantiated directly. Use MemoryInterpreter.newInstance() instead.');
|
|
98
115
|
}
|
|
@@ -100,18 +117,47 @@ class MemoryInterpreter {
|
|
|
100
117
|
static async newInstance(options = {}) {
|
|
101
118
|
const log = options.logger || new ConsoleLogger_js_1.ConsoleLogger('debug');
|
|
102
119
|
const compiler = options.compiler || new ObservableCompiler_js_1.ObservableCompiler();
|
|
120
|
+
const serviceName = Deno.env.get(constants_js_1.envVarProjectId) || 'example-service';
|
|
121
|
+
const environmentID = Deno.env.get(constants_js_1.envVarEnvId) || 'development';
|
|
122
|
+
const version = Deno.env.get(constants_js_1.envVarVersion) || '1.0.0';
|
|
123
|
+
const environment = Deno.env.get(constants_js_1.envVarEnvironmentName) || 'development';
|
|
124
|
+
const orgId = Deno.env.get(constants_js_1.envVarOrgId) || 'development';
|
|
125
|
+
const orgSlug = Deno.env.get(constants_js_1.envVarOrgSlug) || 'development';
|
|
126
|
+
const otelTracesURL = Deno.env.get(constants_js_1.envVarOtelTracesURL);
|
|
127
|
+
let otelSDK;
|
|
128
|
+
// Do NOT change those attributes, they are used by the API to filter on
|
|
129
|
+
const resource = (0, resources_1.resourceFromAttributes)({
|
|
130
|
+
'service.id': serviceName,
|
|
131
|
+
'service.environment': environment,
|
|
132
|
+
'service.environment_id': environmentID,
|
|
133
|
+
'service.version': version,
|
|
134
|
+
'service.organisation_id': orgId,
|
|
135
|
+
'service.organisation_slug': orgSlug,
|
|
136
|
+
});
|
|
137
|
+
if (otelTracesURL && serviceName) {
|
|
138
|
+
otelSDK = new sdk_node_1.NodeSDK({
|
|
139
|
+
traceExporter: new exporter_trace_otlp_proto_1.OTLPTraceExporter({
|
|
140
|
+
url: otelTracesURL,
|
|
141
|
+
}),
|
|
142
|
+
serviceName: serviceName,
|
|
143
|
+
resource: resource,
|
|
144
|
+
});
|
|
145
|
+
log.info('Starting OpenTelemetry SDK');
|
|
146
|
+
otelSDK.start();
|
|
147
|
+
}
|
|
148
|
+
const tracer = api_1.default.trace.getTracer(serviceName, version);
|
|
103
149
|
const roundTripperFactory = options.skipVersoriCredentials
|
|
104
150
|
? new default_js_1.DefaultRoundTripperFactory()
|
|
105
|
-
: roundtripper_js_1.VersoriCredentialsFactory.fromEnv(log);
|
|
151
|
+
: roundtripper_js_1.VersoriCredentialsFactory.fromEnv(log, tracer);
|
|
106
152
|
if (options.contextProvider) {
|
|
107
153
|
// no need to set up a key-value provider if options.contextProvider is already
|
|
108
154
|
// initialised.
|
|
109
|
-
return new MemoryInterpreter(log, compiler, options.contextProvider, roundTripperFactory, express_1.default.Router(), new Map(), platformapi_js_1.PlatformAPIClient.fromEnv(), cronapi_js_1.CronAPIClient.fromEnv());
|
|
155
|
+
return new MemoryInterpreter(log, compiler, options.contextProvider, roundTripperFactory, express_1.default.Router(), new Map(), platformapi_js_1.PlatformAPIClient.fromEnv(), cronapi_js_1.CronAPIClient.fromEnv(), tracer, otelSDK);
|
|
110
156
|
}
|
|
111
157
|
const kvp = await (options.skipVersoriCredentials
|
|
112
158
|
? new MemoryKeyValueProvider_js_1.MemoryKeyValueProvider()
|
|
113
159
|
: NatsKeyValueProvider_js_1.NatsKeyValueProvider.fromEnv());
|
|
114
|
-
return new MemoryInterpreter(log, compiler, new ContextProvider_js_1.ContextProviderImpl(log, kvp, roundTripperFactory.credentials()), roundTripperFactory, express_1.default.Router(), new Map(), platformapi_js_1.PlatformAPIClient.fromEnv(), cronapi_js_1.CronAPIClient.fromEnv());
|
|
160
|
+
return new MemoryInterpreter(log, compiler, new ContextProvider_js_1.ContextProviderImpl(log, kvp, roundTripperFactory.credentials()), roundTripperFactory, express_1.default.Router(), new Map(), platformapi_js_1.PlatformAPIClient.fromEnv(), cronapi_js_1.CronAPIClient.fromEnv(), tracer, otelSDK);
|
|
115
161
|
}
|
|
116
162
|
register(workflow, options) {
|
|
117
163
|
const localAbortController = new AbortController();
|
|
@@ -125,11 +171,12 @@ class MemoryInterpreter {
|
|
|
125
171
|
const compilerContext = {
|
|
126
172
|
compiler: this.compiler,
|
|
127
173
|
log: this.log,
|
|
174
|
+
tracer: this.tracer,
|
|
128
175
|
contextProvider: this.contextProvider,
|
|
129
176
|
roundTripperFactory: this.roundTripperFactory,
|
|
130
177
|
router: this.router,
|
|
131
178
|
cronRegistry: this.cronRegistry,
|
|
132
|
-
connectionProvider: this.connectionProvider
|
|
179
|
+
connectionProvider: this.connectionProvider,
|
|
133
180
|
};
|
|
134
181
|
const trigger$ = this.compiler.compileTrigger(compilerContext, workflow.trigger, combinedSignal);
|
|
135
182
|
const task$ = this.compiler.compileTask(compilerContext, workflow.task);
|
|
@@ -140,7 +187,7 @@ class MemoryInterpreter {
|
|
|
140
187
|
sigintListener: () => {
|
|
141
188
|
this.log.info('Received SIGINT, shutting down workflow');
|
|
142
189
|
localAbortController.abort();
|
|
143
|
-
}
|
|
190
|
+
},
|
|
144
191
|
};
|
|
145
192
|
this.registeredWorkflows.push(registration);
|
|
146
193
|
return registration;
|
|
@@ -157,8 +204,8 @@ class MemoryInterpreter {
|
|
|
157
204
|
};
|
|
158
205
|
app.use((0, express_xml_bodyparser_1.default)(xml2jsDefaults));
|
|
159
206
|
// Add health check route
|
|
160
|
-
this.router.get(
|
|
161
|
-
res.json({ status:
|
|
207
|
+
this.router.get('/health', (_req, res) => {
|
|
208
|
+
res.json({ status: 'healthy' });
|
|
162
209
|
});
|
|
163
210
|
// Add router to the application
|
|
164
211
|
app.use(this.router);
|
|
@@ -169,7 +216,9 @@ class MemoryInterpreter {
|
|
|
169
216
|
.pipe((0, rxjs_1.tap)((ctx) => {
|
|
170
217
|
ctx.log.info('MemoryInterpreter.executionStarted', { data: ctx.data });
|
|
171
218
|
}), (0, rxjs_1.mergeMap)((ctx) => (0, rxjs_1.of)(ctx).pipe(registration.task$, (0, rxjs_1.catchError)((err) => {
|
|
172
|
-
ctx.log.error('MemoryInterpreter.executionError', {
|
|
219
|
+
ctx.log.error('MemoryInterpreter.executionError', {
|
|
220
|
+
error: err instanceof Error ? err.toString() : err,
|
|
221
|
+
});
|
|
173
222
|
try {
|
|
174
223
|
ctx.options.onError?.(ctx.withData(err));
|
|
175
224
|
}
|
|
@@ -202,7 +251,9 @@ class MemoryInterpreter {
|
|
|
202
251
|
this.contextProvider.destroy(ctx);
|
|
203
252
|
},
|
|
204
253
|
error: (err) => {
|
|
205
|
-
this.log.error('MemoryInterpreter.error', {
|
|
254
|
+
this.log.error('MemoryInterpreter.error', {
|
|
255
|
+
error: err instanceof Error ? err.toString() : err,
|
|
256
|
+
});
|
|
206
257
|
Deno.removeSignalListener('SIGINT', registration.sigintListener);
|
|
207
258
|
},
|
|
208
259
|
complete: () => {
|
|
@@ -218,7 +269,9 @@ class MemoryInterpreter {
|
|
|
218
269
|
this.cronProvider.updateCrons(this.cronRegistry);
|
|
219
270
|
}
|
|
220
271
|
catch (err) {
|
|
221
|
-
this.log.error('MemoryInterpreter.updateCronsError', {
|
|
272
|
+
this.log.error('MemoryInterpreter.updateCronsError', {
|
|
273
|
+
error: err instanceof Error ? err.toString() : err,
|
|
274
|
+
});
|
|
222
275
|
throw new Error('Unable to register scheduler tasks with central cron provider');
|
|
223
276
|
}
|
|
224
277
|
this.server = app.listen(port, () => {
|
|
@@ -263,6 +316,7 @@ class MemoryInterpreter {
|
|
|
263
316
|
});
|
|
264
317
|
}
|
|
265
318
|
async stop() {
|
|
319
|
+
this.otelSDK?.shutdown();
|
|
266
320
|
if (this.shutdownServer) {
|
|
267
321
|
this.shutdownServer();
|
|
268
322
|
}
|
|
@@ -7,9 +7,11 @@ import { ContextProvider } from '../../context/ContextProvider.js';
|
|
|
7
7
|
import { ContextImpl } from '../../context/Context.js';
|
|
8
8
|
import { ConnectionProvider, RoundTripperFactory } from '../../dsl/http/types.js';
|
|
9
9
|
import { Router } from 'express';
|
|
10
|
+
import { Tracer } from '@opentelemetry/api';
|
|
10
11
|
export type CompilerContext = {
|
|
11
12
|
compiler: ObservableCompiler;
|
|
12
13
|
log: Logger;
|
|
14
|
+
tracer: Tracer;
|
|
13
15
|
contextProvider: ContextProvider;
|
|
14
16
|
roundTripperFactory: RoundTripperFactory;
|
|
15
17
|
connectionProvider: ConnectionProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservableCompiler.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/memory/ObservableCompiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,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KjF,eAAe,CAAC,GAAG,EAAE,CAAC,SAAS,OAAO,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,eAAe,CAAC,GAAG,EAAE,CAAC,CAAC;CAIjF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catch.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/catch.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAG5D,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"catch.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/catch.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAG5D,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAmDnE,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAGrE,CAAC"}
|
|
@@ -4,15 +4,32 @@ exports.catchCompiler = void 0;
|
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const CatchTask_js_1 = require("../../../dsl/tasks/CatchTask.js");
|
|
6
6
|
const ExecutionError_js_1 = require("../ExecutionError.js");
|
|
7
|
-
function compileCatch(
|
|
8
|
-
const baseOperator =
|
|
9
|
-
const errorOperator =
|
|
7
|
+
function compileCatch(compilerCtx, task) {
|
|
8
|
+
const baseOperator = compilerCtx.compiler.compileTask(compilerCtx, task._base);
|
|
9
|
+
const errorOperator = compilerCtx.compiler.compileTask(compilerCtx, task._errorHandler);
|
|
10
10
|
return (src) => src.pipe((0, rxjs_1.mergeMap)((ctx) => {
|
|
11
11
|
return baseOperator((0, rxjs_1.of)(ctx)).pipe((0, rxjs_1.catchError)((error) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
return compilerCtx.tracer.startActiveSpan(`catch`, (span) => {
|
|
13
|
+
span.setAttribute('execution.id', ctx.executionId);
|
|
14
|
+
span.setAttribute('task.type', 'catch');
|
|
15
|
+
if (error instanceof Error) {
|
|
16
|
+
span.recordException(error);
|
|
17
|
+
span.setAttribute('error.message', error.message);
|
|
18
|
+
span.setAttribute('error.stack', error.stack ?? '');
|
|
19
|
+
span.end();
|
|
20
|
+
ctx.log.error('execution has encountered an error', {
|
|
21
|
+
error: error.message,
|
|
22
|
+
stack: error.stack,
|
|
23
|
+
});
|
|
24
|
+
return errorOperator((0, rxjs_1.of)(ctx.withData(new ExecutionError_js_1.ExecutionError(ctx, error.message, { cause: error }))));
|
|
25
|
+
}
|
|
26
|
+
ctx.log.error('execution has encountered an error', {
|
|
27
|
+
error: error,
|
|
28
|
+
});
|
|
29
|
+
span.setAttribute('error', `${error}`);
|
|
30
|
+
span.end();
|
|
31
|
+
return errorOperator((0, rxjs_1.of)(ctx.withData(new ExecutionError_js_1.ExecutionError(ctx, `${error}`, { cause: error }))));
|
|
32
|
+
});
|
|
16
33
|
}));
|
|
17
34
|
}));
|
|
18
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fn.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/fn.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtD,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"fn.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/fn.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtD,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AA4BnE,eAAO,MAAM,UAAU,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAG/D,CAAC"}
|
|
@@ -3,14 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.fnCompiler = void 0;
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const FnTask_js_1 = require("../../../dsl/tasks/FnTask.js");
|
|
6
|
-
function compileFn(
|
|
6
|
+
function compileFn(compilerCtx, task) {
|
|
7
7
|
return (src) => src.pipe((0, rxjs_1.tap)({
|
|
8
|
-
complete: () =>
|
|
8
|
+
complete: () => compilerCtx.log.debug('fn.complete')
|
|
9
9
|
}), (0, rxjs_1.mergeMap)(async (ctx) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
return await compilerCtx.tracer.startActiveSpan(`fn-${task.id}`, async (span) => {
|
|
11
|
+
span.setAttribute('task.id', task.id);
|
|
12
|
+
span.setAttribute('execution.id', ctx.executionId);
|
|
13
|
+
if (typeof ctx.idx === 'number') {
|
|
14
|
+
span.end();
|
|
15
|
+
return ctx.withData(await task._fn(ctx, ctx.idx));
|
|
16
|
+
}
|
|
17
|
+
span.end();
|
|
18
|
+
return ctx.withData(await task._fn(ctx));
|
|
19
|
+
});
|
|
14
20
|
}));
|
|
15
21
|
}
|
|
16
22
|
exports.fnCompiler = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/http.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/http.ts"],"names":[],"mappings":"AAIA,OAAO,EAAmB,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAE/E,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAyDnE,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAG5E,CAAC"}
|
|
@@ -4,17 +4,41 @@ exports.httpCompiler = void 0;
|
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const operators_1 = require("rxjs/operators");
|
|
6
6
|
const HttpTask_js_1 = require("../../../dsl/tasks/HttpTask.js");
|
|
7
|
-
function compileHttp(
|
|
8
|
-
const roundtripper =
|
|
9
|
-
const dynamicFetcher =
|
|
10
|
-
|
|
11
|
-
complete: () => ctx.log.debug('http.complete'),
|
|
12
|
-
}), (0, rxjs_1.mergeMap)(async (ctx) => {
|
|
7
|
+
function compileHttp(compilerCtx, task) {
|
|
8
|
+
const roundtripper = compilerCtx.roundTripperFactory.create(task.opts.connection);
|
|
9
|
+
const dynamicFetcher = compilerCtx.roundTripperFactory.createDynamic(task.opts.connection);
|
|
10
|
+
async function http(ctx) {
|
|
13
11
|
const _fetch = await roundtripper;
|
|
14
12
|
const _dynamicFetcher = await dynamicFetcher;
|
|
15
13
|
const httpContext = new HttpTask_js_1.HttpContextImpl(ctx, {}, _fetch, _dynamicFetcher);
|
|
16
14
|
const result = await task.fn(httpContext);
|
|
17
15
|
return ctx.withData(result);
|
|
16
|
+
}
|
|
17
|
+
return (src) => src.pipe((0, operators_1.tap)({
|
|
18
|
+
complete: () => compilerCtx.log.debug('http.complete'),
|
|
19
|
+
}), (0, rxjs_1.mergeMap)(async (ctx) => {
|
|
20
|
+
return compilerCtx.tracer.startActiveSpan(`http-${task.id}`, async (span) => {
|
|
21
|
+
span.setAttribute('task.id', task.id);
|
|
22
|
+
span.setAttribute('task.type', 'http');
|
|
23
|
+
span.setAttribute('execution.id', ctx.executionId);
|
|
24
|
+
span.setAttribute('connection.name', task.opts.connection);
|
|
25
|
+
try {
|
|
26
|
+
let result = await http(ctx);
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
if (error instanceof Error) {
|
|
31
|
+
span.recordException(error);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
span.recordException(new Error(String(error)));
|
|
35
|
+
}
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
finally {
|
|
39
|
+
span.end();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
18
42
|
}));
|
|
19
43
|
}
|
|
20
44
|
exports.httpCompiler = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parallel.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/parallel.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAElE,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"parallel.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/parallel.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAElE,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAqCnE,eAAO,MAAM,gBAAgB,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAGrF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/schedule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/schedule.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAEzF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AA0H7C,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAAC,YAAY,EAAE,eAAe,CAG3E,CAAC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.scheduleCompiler = void 0;
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
|
+
const constants_js_1 = require("../../../dsl/http/versori/constants.js");
|
|
5
6
|
const ScheduleTrigger_js_1 = require("../../../dsl/triggers/ScheduleTrigger.js");
|
|
6
7
|
function compileSchedule(ctx, trigger, signal) {
|
|
7
8
|
return new rxjs_1.Observable((subscriber) => {
|
|
@@ -9,24 +10,33 @@ function compileSchedule(ctx, trigger, signal) {
|
|
|
9
10
|
if (!ctx.router) {
|
|
10
11
|
throw new Error('Router not available in compiler context');
|
|
11
12
|
}
|
|
13
|
+
const projectId = Deno.env.get(constants_js_1.envVarProjectId) || 'example-service';
|
|
14
|
+
const environmentId = Deno.env.get(constants_js_1.envVarEnvId) || 'example-environment';
|
|
15
|
+
const environmentName = Deno.env.get(constants_js_1.envVarEnvironmentName) || 'example-environment';
|
|
16
|
+
const orgId = Deno.env.get(constants_js_1.envVarOrgId) || 'example-org';
|
|
12
17
|
const client = ctx.connectionProvider;
|
|
13
18
|
ctx.cronRegistry.set(trigger.id, trigger.schedule);
|
|
14
|
-
|
|
19
|
+
async function handleSchedule(req, res, span) {
|
|
15
20
|
try {
|
|
16
21
|
if (trigger.activationPredicate === undefined) {
|
|
17
22
|
const executionCtx = ctx.contextProvider.create({}, undefined);
|
|
23
|
+
span.setAttribute('execution.id', executionCtx.executionId);
|
|
18
24
|
try {
|
|
19
25
|
subscriber.next(executionCtx);
|
|
20
26
|
}
|
|
21
27
|
catch (error) {
|
|
22
28
|
executionCtx.log.error('execution error inside schedule', { error });
|
|
23
29
|
}
|
|
24
|
-
res.status(200).json({
|
|
30
|
+
res.status(200).json({
|
|
31
|
+
status: 'triggered',
|
|
32
|
+
executionId: executionCtx.executionId,
|
|
33
|
+
});
|
|
25
34
|
return;
|
|
26
35
|
}
|
|
27
36
|
const activations = await client.listActivations();
|
|
28
37
|
if (!activations || activations.length === 0) {
|
|
29
38
|
const executionCtx = ctx.contextProvider.create({}, undefined);
|
|
39
|
+
span.setAttribute('execution.id', executionCtx.executionId);
|
|
30
40
|
executionCtx.log.info('no activations found, continuing');
|
|
31
41
|
try {
|
|
32
42
|
subscriber.next(executionCtx);
|
|
@@ -34,7 +44,10 @@ function compileSchedule(ctx, trigger, signal) {
|
|
|
34
44
|
catch (error) {
|
|
35
45
|
executionCtx.log.error('execution error inside schedule', { error });
|
|
36
46
|
}
|
|
37
|
-
res.status(200).json({
|
|
47
|
+
res.status(200).json({
|
|
48
|
+
status: 'triggered',
|
|
49
|
+
executionId: executionCtx.executionId,
|
|
50
|
+
});
|
|
38
51
|
return;
|
|
39
52
|
}
|
|
40
53
|
activations.forEach((activation) => {
|
|
@@ -53,6 +66,19 @@ function compileSchedule(ctx, trigger, signal) {
|
|
|
53
66
|
ctx.log.error('execution error inside schedule', { error });
|
|
54
67
|
res.status(500).json({ error: 'Failed to trigger schedule' });
|
|
55
68
|
}
|
|
69
|
+
}
|
|
70
|
+
ctx.router.post(`/cron/${trigger.id}`, async (req, res) => {
|
|
71
|
+
await ctx.tracer.startActiveSpan(`schedule-${trigger.id}`, async (span) => {
|
|
72
|
+
span.setAttribute('task.id', trigger.id);
|
|
73
|
+
span.setAttribute('task.type', 'schedule');
|
|
74
|
+
span.setAttribute('schedule', trigger.schedule);
|
|
75
|
+
span.setAttribute('project.id', projectId);
|
|
76
|
+
span.setAttribute('environment.id', environmentId);
|
|
77
|
+
span.setAttribute('environment.name', environmentName);
|
|
78
|
+
span.setAttribute('org.id', orgId);
|
|
79
|
+
await handleSchedule(req, res, span);
|
|
80
|
+
span.end();
|
|
81
|
+
});
|
|
56
82
|
});
|
|
57
83
|
function cleanup() {
|
|
58
84
|
ctx.log.debug('scheduler trigger stopped');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConsoleLogger.d.ts","sourceRoot":"","sources":["../../../../src/src/observability/logging/ConsoleLogger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,+CAA+C,C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