@kinotic-ai/core 5.0.0-beta.8 → 5.0.0-beta.9
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/index.cjs +56 -34
- package/dist/index.d.cts +13 -2
- package/dist/index.d.ts +13 -2
- package/dist/index.js +56 -34
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -159,10 +159,23 @@ var EventConstants;
|
|
|
159
159
|
EventConstants2["TRACESTATE_HEADER"] = "tracestate";
|
|
160
160
|
})(EventConstants ||= {});
|
|
161
161
|
|
|
162
|
+
// packages/core/src/internal/api/Logger.ts
|
|
163
|
+
var import_debug = __toESM(require("debug"));
|
|
164
|
+
function createDebugLogger(namespace) {
|
|
165
|
+
const debugLogger = import_debug.default(namespace);
|
|
166
|
+
return {
|
|
167
|
+
trace: (...args) => debugLogger("TRACE", ...args),
|
|
168
|
+
debug: (...args) => debugLogger("DEBUG", ...args),
|
|
169
|
+
info: (...args) => debugLogger("INFO", ...args),
|
|
170
|
+
warn: (...args) => debugLogger("WARN", ...args),
|
|
171
|
+
error: (...args) => debugLogger("ERROR", ...args)
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
162
175
|
// packages/core/src/internal/api/StompConnectionManager.ts
|
|
163
176
|
var import_rx_stomp = require("@stomp/rx-stomp");
|
|
164
177
|
var import_stompjs = require("@stomp/stompjs");
|
|
165
|
-
var
|
|
178
|
+
var import_debug2 = __toESM(require("debug"));
|
|
166
179
|
var import_rxjs = require("rxjs");
|
|
167
180
|
var import_operators = require("rxjs/operators");
|
|
168
181
|
var import_uuid = require("uuid");
|
|
@@ -181,7 +194,7 @@ class StompConnectionManager {
|
|
|
181
194
|
JITTER_MAX = 5000;
|
|
182
195
|
MAX_RECONNECT_DELAY = 120000;
|
|
183
196
|
connectionAttempts = 0;
|
|
184
|
-
debugLogger =
|
|
197
|
+
debugLogger = import_debug2.default("kinotic:stomp");
|
|
185
198
|
fatalErrorsSubject = new import_rxjs.Subject;
|
|
186
199
|
_fatalErrors = this.fatalErrorsSubject.asObservable();
|
|
187
200
|
initialConnectionSuccessful = false;
|
|
@@ -251,7 +264,9 @@ class StompConnectionManager {
|
|
|
251
264
|
await this.signalFatal(new Error("Authentication required"));
|
|
252
265
|
return;
|
|
253
266
|
}
|
|
254
|
-
} catch {
|
|
267
|
+
} catch (e) {
|
|
268
|
+
this.debugLogger("Session check at %s failed: %O", sessionCheckUrl, e);
|
|
269
|
+
}
|
|
255
270
|
}
|
|
256
271
|
if (options?.maxConnectionAttempts) {
|
|
257
272
|
this.connectionAttempts++;
|
|
@@ -420,6 +435,7 @@ class Event {
|
|
|
420
435
|
|
|
421
436
|
class EventBus {
|
|
422
437
|
serverInfo = null;
|
|
438
|
+
log = createDebugLogger("kinotic:EventBus");
|
|
423
439
|
stompConnectionManager = new StompConnectionManager;
|
|
424
440
|
connectionLifecycle = Promise.resolve();
|
|
425
441
|
replyToCri = null;
|
|
@@ -470,7 +486,7 @@ class EventBus {
|
|
|
470
486
|
return result;
|
|
471
487
|
}
|
|
472
488
|
send(event) {
|
|
473
|
-
if (this.stompConnectionManager.
|
|
489
|
+
if (this.stompConnectionManager.connected) {
|
|
474
490
|
const headers = {};
|
|
475
491
|
for (const [key, value] of event.headers.entries()) {
|
|
476
492
|
headers[key] = value;
|
|
@@ -486,7 +502,8 @@ class EventBus {
|
|
|
486
502
|
this.stompConnectionManager.rxStomp.publish({
|
|
487
503
|
destination: event.cri,
|
|
488
504
|
headers,
|
|
489
|
-
binaryBody: event.data.orUndefined()
|
|
505
|
+
binaryBody: event.data.orUndefined(),
|
|
506
|
+
retryIfDisconnected: false
|
|
490
507
|
});
|
|
491
508
|
} else {
|
|
492
509
|
throw this.createSendUnavailableError();
|
|
@@ -506,6 +523,7 @@ class EventBus {
|
|
|
506
523
|
let serverSignaledCompletion = false;
|
|
507
524
|
const correlationId = import_uuid2.v4();
|
|
508
525
|
this.activeCorrelationIds.add(correlationId);
|
|
526
|
+
subscriber.add(() => this.activeCorrelationIds.delete(correlationId));
|
|
509
527
|
const defaultMessagesSubscription = this.requestRepliesObservable.pipe(import_operators2.filter((value) => {
|
|
510
528
|
return value.headers.get("__correlation-id" /* CORRELATION_ID_HEADER */) === correlationId;
|
|
511
529
|
})).subscribe({
|
|
@@ -535,15 +553,15 @@ class EventBus {
|
|
|
535
553
|
event.setHeader("reply-to" /* REPLY_TO_HEADER */, this.replyToCri);
|
|
536
554
|
event.setHeader("__correlation-id" /* CORRELATION_ID_HEADER */, correlationId);
|
|
537
555
|
this.send(event);
|
|
538
|
-
|
|
539
|
-
this.activeCorrelationIds.delete(correlationId);
|
|
556
|
+
subscriber.add(() => {
|
|
540
557
|
if (sendControlEvents && !serverSignaledCompletion) {
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
558
|
+
try {
|
|
559
|
+
this.sendCancel(event.cri, correlationId);
|
|
560
|
+
} catch (e) {
|
|
561
|
+
this.log.warn(`Could not cancel stream ${correlationId} on ${event.cri}`, e);
|
|
562
|
+
}
|
|
545
563
|
}
|
|
546
|
-
};
|
|
564
|
+
});
|
|
547
565
|
});
|
|
548
566
|
} else {
|
|
549
567
|
return import_rxjs2.throwError(() => this.createSendUnavailableError());
|
|
@@ -569,13 +587,19 @@ class EventBus {
|
|
|
569
587
|
return;
|
|
570
588
|
}
|
|
571
589
|
try {
|
|
572
|
-
|
|
573
|
-
cancelEvent.setHeader("control" /* CONTROL_HEADER */, "cancel" /* CONTROL_VALUE_CANCEL */);
|
|
574
|
-
cancelEvent.setHeader("__correlation-id" /* CORRELATION_ID_HEADER */, correlationId);
|
|
575
|
-
this.send(cancelEvent);
|
|
590
|
+
this.sendCancel(originCri, correlationId);
|
|
576
591
|
this.recentlyReaped.add(correlationId);
|
|
577
592
|
setTimeout(() => this.recentlyReaped.delete(correlationId), EventBus.REAP_DEBOUNCE_MS);
|
|
578
|
-
} catch {
|
|
593
|
+
} catch (e) {
|
|
594
|
+
this.log.warn(`Could not cancel orphaned stream ${correlationId} on ${originCri}`, e);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
sendCancel(cri, correlationId) {
|
|
598
|
+
const cancelEvent = new Event(cri);
|
|
599
|
+
cancelEvent.setHeader("control" /* CONTROL_HEADER */, "cancel" /* CONTROL_VALUE_CANCEL */);
|
|
600
|
+
cancelEvent.setHeader("__correlation-id" /* CORRELATION_ID_HEADER */, correlationId);
|
|
601
|
+
cancelEvent.setHeader("reply-to" /* REPLY_TO_HEADER */, this.replyToCri);
|
|
602
|
+
this.send(cancelEvent);
|
|
579
603
|
}
|
|
580
604
|
resetRequestReplies(reason) {
|
|
581
605
|
if (this.requestRepliesSubject != null) {
|
|
@@ -590,9 +614,13 @@ class EventBus {
|
|
|
590
614
|
}
|
|
591
615
|
}
|
|
592
616
|
createSendUnavailableError() {
|
|
593
|
-
let ret
|
|
617
|
+
let ret;
|
|
594
618
|
if (this.stompConnectionManager.maxConnectionAttemptsReached) {
|
|
595
619
|
ret = "Max connection attempts reached event bus is not available";
|
|
620
|
+
} else if (this.stompConnectionManager.active) {
|
|
621
|
+
ret = "The event bus is not connected to the server";
|
|
622
|
+
} else {
|
|
623
|
+
ret = "You must call connect on the event bus before sending any request";
|
|
596
624
|
}
|
|
597
625
|
return new Error(ret);
|
|
598
626
|
}
|
|
@@ -944,19 +972,6 @@ class BasicReturnValueConverter {
|
|
|
944
972
|
}
|
|
945
973
|
}
|
|
946
974
|
|
|
947
|
-
// packages/core/src/internal/api/Logger.ts
|
|
948
|
-
var import_debug2 = __toESM(require("debug"));
|
|
949
|
-
function createDebugLogger(namespace) {
|
|
950
|
-
const debugLogger = import_debug2.default(namespace);
|
|
951
|
-
return {
|
|
952
|
-
trace: (...args) => debugLogger("TRACE", ...args),
|
|
953
|
-
debug: (...args) => debugLogger("DEBUG", ...args),
|
|
954
|
-
info: (...args) => debugLogger("INFO", ...args),
|
|
955
|
-
warn: (...args) => debugLogger("WARN", ...args),
|
|
956
|
-
error: (...args) => debugLogger("ERROR", ...args)
|
|
957
|
-
};
|
|
958
|
-
}
|
|
959
|
-
|
|
960
975
|
// packages/core/src/api/ServiceIdentifier.ts
|
|
961
976
|
class ServiceIdentifier {
|
|
962
977
|
namespace;
|
|
@@ -1136,7 +1151,7 @@ var import_api2 = __toESM(require("@opentelemetry/api"));
|
|
|
1136
1151
|
// packages/core/package.json
|
|
1137
1152
|
var package_default = {
|
|
1138
1153
|
name: "@kinotic-ai/core",
|
|
1139
|
-
version: "5.0.0-beta.
|
|
1154
|
+
version: "5.0.0-beta.9",
|
|
1140
1155
|
type: "module",
|
|
1141
1156
|
files: [
|
|
1142
1157
|
"dist"
|
|
@@ -1427,14 +1442,21 @@ class ServiceInvocationSupervisor {
|
|
|
1427
1442
|
}
|
|
1428
1443
|
processMethodInvocationResult(event, result) {
|
|
1429
1444
|
const outgoingEvent = this.returnValueConverter.convert(event.headers, result);
|
|
1430
|
-
this.
|
|
1445
|
+
this.sendReply(outgoingEvent);
|
|
1446
|
+
}
|
|
1447
|
+
sendReply(event) {
|
|
1448
|
+
try {
|
|
1449
|
+
this._eventBus.send(event);
|
|
1450
|
+
} catch (e) {
|
|
1451
|
+
this.log.warn(`Could not send reply to ${event.cri}`, e);
|
|
1452
|
+
}
|
|
1431
1453
|
}
|
|
1432
1454
|
handleException(event, error) {
|
|
1433
1455
|
const errorEvent = Util.createReplyEvent(event.headers, new Map([
|
|
1434
1456
|
["error" /* ERROR_HEADER */, error.message || "Unknown error"],
|
|
1435
1457
|
["content-type" /* CONTENT_TYPE_HEADER */, "application/json"]
|
|
1436
1458
|
]), new TextEncoder().encode(JSON.stringify({ message: error.message })));
|
|
1437
|
-
this.
|
|
1459
|
+
this.sendReply(errorEvent);
|
|
1438
1460
|
}
|
|
1439
1461
|
validateReplyTo(event) {
|
|
1440
1462
|
const replyTo = event.getHeader("reply-to" /* REPLY_TO_HEADER */);
|
package/dist/index.d.cts
CHANGED
|
@@ -256,7 +256,8 @@ interface IEventBus {
|
|
|
256
256
|
/**
|
|
257
257
|
* Determines if the connection is active.
|
|
258
258
|
* This means {@link IEventBus#connect()} was called and was successful. The underlying connection may not be established yet.
|
|
259
|
-
*
|
|
259
|
+
* Subscriptions made while active are established once the connection comes up; sends require
|
|
260
|
+
* {@link IEventBus#isConnected}
|
|
260
261
|
* @return true if the connection is active false if not
|
|
261
262
|
*/
|
|
262
263
|
isConnectionActive(): boolean;
|
|
@@ -288,8 +289,11 @@ interface IEventBus {
|
|
|
288
289
|
*/
|
|
289
290
|
requestStream(event: IEvent, sendControlEvents: boolean): Observable<IEvent>;
|
|
290
291
|
/**
|
|
291
|
-
* Send a single {@link IEvent} to the connected server
|
|
292
|
+
* Send a single {@link IEvent} to the connected server. Events are never held for a later
|
|
293
|
+
* connection, so the caller decides what an event it could not send means — see
|
|
294
|
+
* {@link isConnected}.
|
|
292
295
|
* @param event to send
|
|
296
|
+
* @throws if the connection is not established
|
|
293
297
|
*/
|
|
294
298
|
send(event: IEvent): void;
|
|
295
299
|
}
|
|
@@ -1242,6 +1246,7 @@ declare class Event implements IEvent {
|
|
|
1242
1246
|
*/
|
|
1243
1247
|
declare class EventBus implements IEventBus {
|
|
1244
1248
|
serverInfo: ServerInfo | null;
|
|
1249
|
+
private readonly log;
|
|
1245
1250
|
private stompConnectionManager;
|
|
1246
1251
|
private connectionLifecycle;
|
|
1247
1252
|
private replyToCri;
|
|
@@ -1272,6 +1277,12 @@ declare class EventBus implements IEventBus {
|
|
|
1272
1277
|
*/
|
|
1273
1278
|
private cancelIfUnexpected;
|
|
1274
1279
|
/**
|
|
1280
|
+
* Sends the control event that stops the server stream identified by the correlationId.
|
|
1281
|
+
* @param cri the service the stream originates from
|
|
1282
|
+
* @param correlationId the correlationId of the stream to cancel
|
|
1283
|
+
*/
|
|
1284
|
+
private sendCancel;
|
|
1285
|
+
/**
|
|
1275
1286
|
* Tears down the shared request-replies stream so the next request rebuilds it against the
|
|
1276
1287
|
* current {@link replyToCri}. Any in-flight requests are failed with the given reason since
|
|
1277
1288
|
* their replies can no longer be delivered.
|
package/dist/index.d.ts
CHANGED
|
@@ -256,7 +256,8 @@ interface IEventBus {
|
|
|
256
256
|
/**
|
|
257
257
|
* Determines if the connection is active.
|
|
258
258
|
* This means {@link IEventBus#connect()} was called and was successful. The underlying connection may not be established yet.
|
|
259
|
-
*
|
|
259
|
+
* Subscriptions made while active are established once the connection comes up; sends require
|
|
260
|
+
* {@link IEventBus#isConnected}
|
|
260
261
|
* @return true if the connection is active false if not
|
|
261
262
|
*/
|
|
262
263
|
isConnectionActive(): boolean;
|
|
@@ -288,8 +289,11 @@ interface IEventBus {
|
|
|
288
289
|
*/
|
|
289
290
|
requestStream(event: IEvent, sendControlEvents: boolean): Observable<IEvent>;
|
|
290
291
|
/**
|
|
291
|
-
* Send a single {@link IEvent} to the connected server
|
|
292
|
+
* Send a single {@link IEvent} to the connected server. Events are never held for a later
|
|
293
|
+
* connection, so the caller decides what an event it could not send means — see
|
|
294
|
+
* {@link isConnected}.
|
|
292
295
|
* @param event to send
|
|
296
|
+
* @throws if the connection is not established
|
|
293
297
|
*/
|
|
294
298
|
send(event: IEvent): void;
|
|
295
299
|
}
|
|
@@ -1242,6 +1246,7 @@ declare class Event implements IEvent {
|
|
|
1242
1246
|
*/
|
|
1243
1247
|
declare class EventBus implements IEventBus {
|
|
1244
1248
|
serverInfo: ServerInfo | null;
|
|
1249
|
+
private readonly log;
|
|
1245
1250
|
private stompConnectionManager;
|
|
1246
1251
|
private connectionLifecycle;
|
|
1247
1252
|
private replyToCri;
|
|
@@ -1272,6 +1277,12 @@ declare class EventBus implements IEventBus {
|
|
|
1272
1277
|
*/
|
|
1273
1278
|
private cancelIfUnexpected;
|
|
1274
1279
|
/**
|
|
1280
|
+
* Sends the control event that stops the server stream identified by the correlationId.
|
|
1281
|
+
* @param cri the service the stream originates from
|
|
1282
|
+
* @param correlationId the correlationId of the stream to cancel
|
|
1283
|
+
*/
|
|
1284
|
+
private sendCancel;
|
|
1285
|
+
/**
|
|
1275
1286
|
* Tears down the shared request-replies stream so the next request rebuilds it against the
|
|
1276
1287
|
* current {@link replyToCri}. Any in-flight requests are failed with the given reason since
|
|
1277
1288
|
* their replies can no longer be delivered.
|
package/dist/index.js
CHANGED
|
@@ -46,10 +46,23 @@ var EventConstants;
|
|
|
46
46
|
EventConstants2["TRACESTATE_HEADER"] = "tracestate";
|
|
47
47
|
})(EventConstants ||= {});
|
|
48
48
|
|
|
49
|
+
// packages/core/src/internal/api/Logger.ts
|
|
50
|
+
import debug from "debug";
|
|
51
|
+
function createDebugLogger(namespace) {
|
|
52
|
+
const debugLogger = debug(namespace);
|
|
53
|
+
return {
|
|
54
|
+
trace: (...args) => debugLogger("TRACE", ...args),
|
|
55
|
+
debug: (...args) => debugLogger("DEBUG", ...args),
|
|
56
|
+
info: (...args) => debugLogger("INFO", ...args),
|
|
57
|
+
warn: (...args) => debugLogger("WARN", ...args),
|
|
58
|
+
error: (...args) => debugLogger("ERROR", ...args)
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
49
62
|
// packages/core/src/internal/api/StompConnectionManager.ts
|
|
50
63
|
import { RxStomp } from "@stomp/rx-stomp";
|
|
51
64
|
import { ReconnectionTimeMode } from "@stomp/stompjs";
|
|
52
|
-
import
|
|
65
|
+
import debug2 from "debug";
|
|
53
66
|
import { Subject } from "rxjs";
|
|
54
67
|
import { skip } from "rxjs/operators";
|
|
55
68
|
import { v4 as uuidv4 } from "uuid";
|
|
@@ -68,7 +81,7 @@ class StompConnectionManager {
|
|
|
68
81
|
JITTER_MAX = 5000;
|
|
69
82
|
MAX_RECONNECT_DELAY = 120000;
|
|
70
83
|
connectionAttempts = 0;
|
|
71
|
-
debugLogger =
|
|
84
|
+
debugLogger = debug2("kinotic:stomp");
|
|
72
85
|
fatalErrorsSubject = new Subject;
|
|
73
86
|
_fatalErrors = this.fatalErrorsSubject.asObservable();
|
|
74
87
|
initialConnectionSuccessful = false;
|
|
@@ -138,7 +151,9 @@ class StompConnectionManager {
|
|
|
138
151
|
await this.signalFatal(new Error("Authentication required"));
|
|
139
152
|
return;
|
|
140
153
|
}
|
|
141
|
-
} catch {
|
|
154
|
+
} catch (e) {
|
|
155
|
+
this.debugLogger("Session check at %s failed: %O", sessionCheckUrl, e);
|
|
156
|
+
}
|
|
142
157
|
}
|
|
143
158
|
if (options?.maxConnectionAttempts) {
|
|
144
159
|
this.connectionAttempts++;
|
|
@@ -307,6 +322,7 @@ class Event {
|
|
|
307
322
|
|
|
308
323
|
class EventBus {
|
|
309
324
|
serverInfo = null;
|
|
325
|
+
log = createDebugLogger("kinotic:EventBus");
|
|
310
326
|
stompConnectionManager = new StompConnectionManager;
|
|
311
327
|
connectionLifecycle = Promise.resolve();
|
|
312
328
|
replyToCri = null;
|
|
@@ -357,7 +373,7 @@ class EventBus {
|
|
|
357
373
|
return result;
|
|
358
374
|
}
|
|
359
375
|
send(event) {
|
|
360
|
-
if (this.stompConnectionManager.
|
|
376
|
+
if (this.stompConnectionManager.connected) {
|
|
361
377
|
const headers = {};
|
|
362
378
|
for (const [key, value] of event.headers.entries()) {
|
|
363
379
|
headers[key] = value;
|
|
@@ -373,7 +389,8 @@ class EventBus {
|
|
|
373
389
|
this.stompConnectionManager.rxStomp.publish({
|
|
374
390
|
destination: event.cri,
|
|
375
391
|
headers,
|
|
376
|
-
binaryBody: event.data.orUndefined()
|
|
392
|
+
binaryBody: event.data.orUndefined(),
|
|
393
|
+
retryIfDisconnected: false
|
|
377
394
|
});
|
|
378
395
|
} else {
|
|
379
396
|
throw this.createSendUnavailableError();
|
|
@@ -393,6 +410,7 @@ class EventBus {
|
|
|
393
410
|
let serverSignaledCompletion = false;
|
|
394
411
|
const correlationId = uuidv42();
|
|
395
412
|
this.activeCorrelationIds.add(correlationId);
|
|
413
|
+
subscriber.add(() => this.activeCorrelationIds.delete(correlationId));
|
|
396
414
|
const defaultMessagesSubscription = this.requestRepliesObservable.pipe(filter((value) => {
|
|
397
415
|
return value.headers.get("__correlation-id" /* CORRELATION_ID_HEADER */) === correlationId;
|
|
398
416
|
})).subscribe({
|
|
@@ -422,15 +440,15 @@ class EventBus {
|
|
|
422
440
|
event.setHeader("reply-to" /* REPLY_TO_HEADER */, this.replyToCri);
|
|
423
441
|
event.setHeader("__correlation-id" /* CORRELATION_ID_HEADER */, correlationId);
|
|
424
442
|
this.send(event);
|
|
425
|
-
|
|
426
|
-
this.activeCorrelationIds.delete(correlationId);
|
|
443
|
+
subscriber.add(() => {
|
|
427
444
|
if (sendControlEvents && !serverSignaledCompletion) {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
445
|
+
try {
|
|
446
|
+
this.sendCancel(event.cri, correlationId);
|
|
447
|
+
} catch (e) {
|
|
448
|
+
this.log.warn(`Could not cancel stream ${correlationId} on ${event.cri}`, e);
|
|
449
|
+
}
|
|
432
450
|
}
|
|
433
|
-
};
|
|
451
|
+
});
|
|
434
452
|
});
|
|
435
453
|
} else {
|
|
436
454
|
return throwError(() => this.createSendUnavailableError());
|
|
@@ -456,13 +474,19 @@ class EventBus {
|
|
|
456
474
|
return;
|
|
457
475
|
}
|
|
458
476
|
try {
|
|
459
|
-
|
|
460
|
-
cancelEvent.setHeader("control" /* CONTROL_HEADER */, "cancel" /* CONTROL_VALUE_CANCEL */);
|
|
461
|
-
cancelEvent.setHeader("__correlation-id" /* CORRELATION_ID_HEADER */, correlationId);
|
|
462
|
-
this.send(cancelEvent);
|
|
477
|
+
this.sendCancel(originCri, correlationId);
|
|
463
478
|
this.recentlyReaped.add(correlationId);
|
|
464
479
|
setTimeout(() => this.recentlyReaped.delete(correlationId), EventBus.REAP_DEBOUNCE_MS);
|
|
465
|
-
} catch {
|
|
480
|
+
} catch (e) {
|
|
481
|
+
this.log.warn(`Could not cancel orphaned stream ${correlationId} on ${originCri}`, e);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
sendCancel(cri, correlationId) {
|
|
485
|
+
const cancelEvent = new Event(cri);
|
|
486
|
+
cancelEvent.setHeader("control" /* CONTROL_HEADER */, "cancel" /* CONTROL_VALUE_CANCEL */);
|
|
487
|
+
cancelEvent.setHeader("__correlation-id" /* CORRELATION_ID_HEADER */, correlationId);
|
|
488
|
+
cancelEvent.setHeader("reply-to" /* REPLY_TO_HEADER */, this.replyToCri);
|
|
489
|
+
this.send(cancelEvent);
|
|
466
490
|
}
|
|
467
491
|
resetRequestReplies(reason) {
|
|
468
492
|
if (this.requestRepliesSubject != null) {
|
|
@@ -477,9 +501,13 @@ class EventBus {
|
|
|
477
501
|
}
|
|
478
502
|
}
|
|
479
503
|
createSendUnavailableError() {
|
|
480
|
-
let ret
|
|
504
|
+
let ret;
|
|
481
505
|
if (this.stompConnectionManager.maxConnectionAttemptsReached) {
|
|
482
506
|
ret = "Max connection attempts reached event bus is not available";
|
|
507
|
+
} else if (this.stompConnectionManager.active) {
|
|
508
|
+
ret = "The event bus is not connected to the server";
|
|
509
|
+
} else {
|
|
510
|
+
ret = "You must call connect on the event bus before sending any request";
|
|
483
511
|
}
|
|
484
512
|
return new Error(ret);
|
|
485
513
|
}
|
|
@@ -831,19 +859,6 @@ class BasicReturnValueConverter {
|
|
|
831
859
|
}
|
|
832
860
|
}
|
|
833
861
|
|
|
834
|
-
// packages/core/src/internal/api/Logger.ts
|
|
835
|
-
import debug2 from "debug";
|
|
836
|
-
function createDebugLogger(namespace) {
|
|
837
|
-
const debugLogger = debug2(namespace);
|
|
838
|
-
return {
|
|
839
|
-
trace: (...args) => debugLogger("TRACE", ...args),
|
|
840
|
-
debug: (...args) => debugLogger("DEBUG", ...args),
|
|
841
|
-
info: (...args) => debugLogger("INFO", ...args),
|
|
842
|
-
warn: (...args) => debugLogger("WARN", ...args),
|
|
843
|
-
error: (...args) => debugLogger("ERROR", ...args)
|
|
844
|
-
};
|
|
845
|
-
}
|
|
846
|
-
|
|
847
862
|
// packages/core/src/api/ServiceIdentifier.ts
|
|
848
863
|
class ServiceIdentifier {
|
|
849
864
|
namespace;
|
|
@@ -1023,7 +1038,7 @@ import opentelemetry, { context as context2, propagation as propagation2, trace,
|
|
|
1023
1038
|
// packages/core/package.json
|
|
1024
1039
|
var package_default = {
|
|
1025
1040
|
name: "@kinotic-ai/core",
|
|
1026
|
-
version: "5.0.0-beta.
|
|
1041
|
+
version: "5.0.0-beta.9",
|
|
1027
1042
|
type: "module",
|
|
1028
1043
|
files: [
|
|
1029
1044
|
"dist"
|
|
@@ -1314,14 +1329,21 @@ class ServiceInvocationSupervisor {
|
|
|
1314
1329
|
}
|
|
1315
1330
|
processMethodInvocationResult(event, result) {
|
|
1316
1331
|
const outgoingEvent = this.returnValueConverter.convert(event.headers, result);
|
|
1317
|
-
this.
|
|
1332
|
+
this.sendReply(outgoingEvent);
|
|
1333
|
+
}
|
|
1334
|
+
sendReply(event) {
|
|
1335
|
+
try {
|
|
1336
|
+
this._eventBus.send(event);
|
|
1337
|
+
} catch (e) {
|
|
1338
|
+
this.log.warn(`Could not send reply to ${event.cri}`, e);
|
|
1339
|
+
}
|
|
1318
1340
|
}
|
|
1319
1341
|
handleException(event, error) {
|
|
1320
1342
|
const errorEvent = Util.createReplyEvent(event.headers, new Map([
|
|
1321
1343
|
["error" /* ERROR_HEADER */, error.message || "Unknown error"],
|
|
1322
1344
|
["content-type" /* CONTENT_TYPE_HEADER */, "application/json"]
|
|
1323
1345
|
]), new TextEncoder().encode(JSON.stringify({ message: error.message })));
|
|
1324
|
-
this.
|
|
1346
|
+
this.sendReply(errorEvent);
|
|
1325
1347
|
}
|
|
1326
1348
|
validateReplyTo(event) {
|
|
1327
1349
|
const replyTo = event.getHeader("reply-to" /* REPLY_TO_HEADER */);
|