@kronos-ts/axon-server 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/axon-server-event-store.d.ts +0 -16
- package/dist/axon-server-event-store.d.ts.map +1 -1
- package/dist/axon-server-event-store.js +73 -45
- package/dist/axon-server-event-store.js.map +1 -1
- package/dist/axon-server-snapshotting-event-store.d.ts +30 -0
- package/dist/axon-server-snapshotting-event-store.d.ts.map +1 -0
- package/dist/axon-server-snapshotting-event-store.js +154 -0
- package/dist/axon-server-snapshotting-event-store.js.map +1 -0
- package/dist/axon-server.d.ts +46 -65
- package/dist/axon-server.d.ts.map +1 -1
- package/dist/axon-server.js +490 -317
- package/dist/axon-server.js.map +1 -1
- package/dist/bounded-read.d.ts +19 -0
- package/dist/bounded-read.d.ts.map +1 -0
- package/dist/bounded-read.js +39 -0
- package/dist/bounded-read.js.map +1 -0
- package/dist/connection-manager.d.ts +2 -2
- package/dist/connection-manager.d.ts.map +1 -1
- package/dist/connection.d.ts +36 -21
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +84 -45
- package/dist/connection.js.map +1 -1
- package/dist/context-view.d.ts +2 -2
- package/dist/context-view.d.ts.map +1 -1
- package/dist/control-plane.d.ts +14 -24
- package/dist/control-plane.d.ts.map +1 -1
- package/dist/control-plane.js +6 -37
- package/dist/control-plane.js.map +1 -1
- package/dist/event-processor-info.d.ts +7 -25
- package/dist/event-processor-info.d.ts.map +1 -1
- package/dist/event-processor-info.js +16 -20
- package/dist/event-processor-info.js.map +1 -1
- package/dist/flow-controlled-sender.d.ts +2 -2
- package/dist/flow-controlled-sender.d.ts.map +1 -1
- package/dist/flow-controlled-sender.js +37 -17
- package/dist/flow-controlled-sender.js.map +1 -1
- package/dist/generated/command.d.ts +20 -20
- package/dist/generated/command.d.ts.map +1 -1
- package/dist/generated/common.d.ts +20 -20
- package/dist/generated/common.d.ts.map +1 -1
- package/dist/generated/control.d.ts +36 -40
- package/dist/generated/control.d.ts.map +1 -1
- package/dist/generated/dcb.d.ts +88 -94
- package/dist/generated/dcb.d.ts.map +1 -1
- package/dist/generated/event.d.ts +81 -84
- package/dist/generated/event.d.ts.map +1 -1
- package/dist/generated/google/protobuf/empty.d.ts +3 -4
- package/dist/generated/google/protobuf/empty.d.ts.map +1 -1
- package/dist/generated/query.d.ts +40 -40
- package/dist/generated/query.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/message-size.d.ts +2 -2
- package/dist/message-size.d.ts.map +1 -1
- package/dist/outbound-stream.d.ts +7 -11
- package/dist/outbound-stream.d.ts.map +1 -1
- package/dist/outbound-stream.js +65 -16
- package/dist/outbound-stream.js.map +1 -1
- package/dist/platform-service.d.ts +14 -5
- package/dist/platform-service.d.ts.map +1 -1
- package/dist/platform-service.js +70 -10
- package/dist/platform-service.js.map +1 -1
- package/dist/resilience.d.ts +62 -0
- package/dist/resilience.d.ts.map +1 -0
- package/dist/resilience.js +103 -0
- package/dist/resilience.js.map +1 -0
- package/dist/shutdown-latch.d.ts +5 -4
- package/dist/shutdown-latch.d.ts.map +1 -1
- package/dist/shutdown-latch.js +20 -1
- package/dist/shutdown-latch.js.map +1 -1
- package/dist/stream-recovery.d.ts +9 -0
- package/dist/stream-recovery.d.ts.map +1 -0
- package/dist/stream-recovery.js +70 -0
- package/dist/stream-recovery.js.map +1 -0
- package/package.json +3 -3
- package/src/axon-server-event-store.ts +77 -47
- package/src/axon-server-snapshotting-event-store.ts +194 -0
- package/src/axon-server.ts +472 -374
- package/src/bounded-read.ts +43 -0
- package/src/connection-manager.ts +1 -1
- package/src/connection.ts +93 -59
- package/src/context-view.ts +1 -1
- package/src/control-plane.ts +22 -66
- package/src/event-processor-info.ts +23 -44
- package/src/flow-controlled-sender.ts +34 -15
- package/src/generated/command.ts +10 -10
- package/src/generated/common.ts +10 -10
- package/src/generated/control.ts +20 -20
- package/src/generated/dcb.ts +47 -47
- package/src/generated/event.ts +42 -42
- package/src/generated/google/protobuf/empty.ts +2 -2
- package/src/generated/query.ts +20 -20
- package/src/index.ts +1 -2
- package/src/message-size.ts +1 -1
- package/src/outbound-stream.ts +58 -28
- package/src/platform-service.ts +77 -13
- package/src/resilience.ts +149 -0
- package/src/shutdown-latch.ts +16 -3
- package/src/stream-recovery.ts +72 -0
- package/dist/axon-server-snapshot-store.d.ts +0 -12
- package/dist/axon-server-snapshot-store.d.ts.map +0 -1
- package/dist/axon-server-snapshot-store.js +0 -82
- package/dist/axon-server-snapshot-store.js.map +0 -1
- package/src/axon-server-snapshot-store.ts +0 -110
package/dist/platform-service.js
CHANGED
|
@@ -10,7 +10,7 @@ import { toEventProcessorInfo } from "./event-processor-info.js";
|
|
|
10
10
|
* 3. Receives instructions from Axon Server (split, merge, pause, resume)
|
|
11
11
|
*/
|
|
12
12
|
export function platformConnection(connection, options) {
|
|
13
|
-
const heartbeatIntervalMs = options?.heartbeatIntervalMs ??
|
|
13
|
+
const heartbeatIntervalMs = options?.heartbeatIntervalMs ?? 2500;
|
|
14
14
|
const heartbeatTimeoutMs = options?.heartbeatTimeoutMs ?? 7500;
|
|
15
15
|
const processorsNotificationRateMs = options?.processorsNotificationRateMs ?? 500;
|
|
16
16
|
const processorsNotificationInitialDelayMs = options?.processorsNotificationInitialDelayMs ?? 5000;
|
|
@@ -30,12 +30,22 @@ export function platformConnection(connection, options) {
|
|
|
30
30
|
*/
|
|
31
31
|
const pendingInstructions = [];
|
|
32
32
|
let isConnected = false;
|
|
33
|
+
let monitoringArmed = false;
|
|
34
|
+
let recoveryTimer;
|
|
33
35
|
let heartbeatTimer = null;
|
|
34
36
|
let heartbeatTimeoutTimer = null;
|
|
37
|
+
let processorStatusInitialTimer;
|
|
35
38
|
let processorStatusTimer = null;
|
|
36
39
|
/** Guards against arming the status-report timer twice — see `startProcessorStatusReporting`. */
|
|
37
40
|
let processorStatusArmed = false;
|
|
38
41
|
let lastHeartbeatResponse = Date.now();
|
|
42
|
+
// Whether this server has EVER sent a heartbeat. Axon Server only beats at
|
|
43
|
+
// clients whose registered framework version it recognises (4.2.1+); a client
|
|
44
|
+
// it does not beat at cannot be judged by the silence — that judgement fell
|
|
45
|
+
// every window and tore down a healthy stream, every 10 s, in production.
|
|
46
|
+
// Dead-channel detection for a server that never beats is gRPC keepalive's
|
|
47
|
+
// job (see `connection.ts`), not this timer's.
|
|
48
|
+
let serverBeats = false;
|
|
39
49
|
let outbound = null;
|
|
40
50
|
/**
|
|
41
51
|
* Latches once Axon Server sends its first inbound message after
|
|
@@ -50,13 +60,39 @@ export function platformConnection(connection, options) {
|
|
|
50
60
|
if (connection.config.token) {
|
|
51
61
|
grpcMetadata.set("AxonIQ-Access-Token", connection.config.token);
|
|
52
62
|
}
|
|
53
|
-
|
|
63
|
+
function scheduleRecovery() {
|
|
64
|
+
if (!monitoringArmed || recoveryTimer || connection.state === "closed" || connection.state === "reconnecting")
|
|
65
|
+
return;
|
|
66
|
+
recoveryTimer = setTimeout(() => {
|
|
67
|
+
recoveryTimer = undefined;
|
|
68
|
+
if (!monitoringArmed || connection.state === "closed")
|
|
69
|
+
return;
|
|
70
|
+
void connection.reconnect().catch((error) => console.error("Platform recovery failed", error));
|
|
71
|
+
}, connection.config.reconnectIntervalMs ?? 2000);
|
|
72
|
+
}
|
|
73
|
+
connection.onDisconnect?.(() => {
|
|
74
|
+
isConnected = false;
|
|
75
|
+
outbound?.close();
|
|
76
|
+
});
|
|
77
|
+
connection.onReconnect(() => {
|
|
78
|
+
if (!monitoringArmed)
|
|
79
|
+
return;
|
|
80
|
+
clearTimeout(recoveryTimer);
|
|
81
|
+
recoveryTimer = undefined;
|
|
82
|
+
isConnected = false;
|
|
83
|
+
openPlatformStream();
|
|
84
|
+
});
|
|
85
|
+
async function processInboundInstructions(inbound, stream) {
|
|
54
86
|
try {
|
|
55
87
|
for await (const message of inbound) {
|
|
88
|
+
if (stream !== outbound || !monitoringArmed)
|
|
89
|
+
return;
|
|
56
90
|
// First inbound message after start() = the platform has accepted our
|
|
57
91
|
// registration and is talking back. Latch the ack flag (mirror of
|
|
58
92
|
// kronosdb Plan 09-03 / D-102 — replaces the legacy 1s sleep).
|
|
59
93
|
acked = true;
|
|
94
|
+
if (message.requestReconnect)
|
|
95
|
+
scheduleRecovery();
|
|
60
96
|
// Parse instruction type
|
|
61
97
|
const instruction = parseInstruction(message);
|
|
62
98
|
if (instruction) {
|
|
@@ -74,18 +110,30 @@ export function platformConnection(connection, options) {
|
|
|
74
110
|
}
|
|
75
111
|
}
|
|
76
112
|
}
|
|
77
|
-
//
|
|
113
|
+
// A heartbeat from the server is BOTH the liveness signal this side
|
|
114
|
+
// tracks and a request: Axon Server measures client inactivity by the
|
|
115
|
+
// heartbeats it receives, so every one it sends is answered at once
|
|
116
|
+
// (what Axon Framework's connector does). Without the echo, the only
|
|
117
|
+
// activity the server ever sees is the periodic beat below.
|
|
78
118
|
if (message.heartbeat) {
|
|
119
|
+
serverBeats = true;
|
|
79
120
|
lastHeartbeatResponse = Date.now();
|
|
121
|
+
outbound?.send({ heartbeat: { clientId: connection.config.clientId }, instructionId: "" });
|
|
80
122
|
}
|
|
81
123
|
}
|
|
82
124
|
}
|
|
83
125
|
catch (err) {
|
|
84
|
-
if (isConnected) {
|
|
126
|
+
if (stream === outbound && monitoringArmed && isConnected) {
|
|
85
127
|
console.error("Platform stream error:", err);
|
|
86
128
|
isConnected = false;
|
|
87
129
|
}
|
|
88
130
|
}
|
|
131
|
+
finally {
|
|
132
|
+
if (stream === outbound && monitoringArmed) {
|
|
133
|
+
isConnected = false;
|
|
134
|
+
scheduleRecovery();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
89
137
|
}
|
|
90
138
|
function parseInstruction(message) {
|
|
91
139
|
if (message.requestReconnect) {
|
|
@@ -137,9 +185,13 @@ export function platformConnection(connection, options) {
|
|
|
137
185
|
heartbeatTimer = setInterval(() => {
|
|
138
186
|
if (!isConnected || !outbound)
|
|
139
187
|
return;
|
|
140
|
-
//
|
|
188
|
+
// Not before the server has acknowledged the registration: a heartbeat
|
|
189
|
+
// from a stream it has not filed yet is an error on its side, not a beat.
|
|
190
|
+
if (!acked)
|
|
191
|
+
return;
|
|
192
|
+
// Judge silence only from a server that has beaten before.
|
|
141
193
|
const timeSinceLastResponse = Date.now() - lastHeartbeatResponse;
|
|
142
|
-
if (timeSinceLastResponse > heartbeatTimeoutMs) {
|
|
194
|
+
if (serverBeats && timeSinceLastResponse > heartbeatTimeoutMs) {
|
|
143
195
|
console.warn(`Platform heartbeat timeout: no response in ${timeSinceLastResponse}ms ` +
|
|
144
196
|
`(threshold: ${heartbeatTimeoutMs}ms). Marking connection as lost.`);
|
|
145
197
|
isConnected = false;
|
|
@@ -169,10 +221,11 @@ export function platformConnection(connection, options) {
|
|
|
169
221
|
if (processorStatusTimer)
|
|
170
222
|
clearInterval(processorStatusTimer);
|
|
171
223
|
// Initial delay before first report
|
|
172
|
-
setTimeout(() => {
|
|
173
|
-
if (!
|
|
224
|
+
processorStatusInitialTimer = setTimeout(() => {
|
|
225
|
+
if (!monitoringArmed)
|
|
174
226
|
return;
|
|
175
|
-
|
|
227
|
+
if (isConnected)
|
|
228
|
+
void reportProcessorStatus();
|
|
176
229
|
// Then report at the configured rate
|
|
177
230
|
processorStatusTimer = setInterval(() => {
|
|
178
231
|
if (!isConnected || !outbound)
|
|
@@ -218,6 +271,7 @@ export function platformConnection(connection, options) {
|
|
|
218
271
|
}
|
|
219
272
|
// Re-arm the ack latch so a stop/start cycle correctly re-waits.
|
|
220
273
|
acked = false;
|
|
274
|
+
serverBeats = false;
|
|
221
275
|
outbound = outboundStream();
|
|
222
276
|
// Register with Axon Server
|
|
223
277
|
outbound.send({
|
|
@@ -238,7 +292,7 @@ export function platformConnection(connection, options) {
|
|
|
238
292
|
// timeout, which is what the command/query buses hang their stream
|
|
239
293
|
// re-establishment off. It belongs to every service, administered or not.
|
|
240
294
|
startHeartbeat();
|
|
241
|
-
processInboundInstructions(inbound);
|
|
295
|
+
void processInboundInstructions(inbound, outbound);
|
|
242
296
|
// Axon Server's PlatformService does NOT proactively emit an inbound
|
|
243
297
|
// frame in response to `register` — the stream is held open silently
|
|
244
298
|
// until either (a) the server pushes a topology / instruction event,
|
|
@@ -260,13 +314,19 @@ export function platformConnection(connection, options) {
|
|
|
260
314
|
}
|
|
261
315
|
return {
|
|
262
316
|
async armConnectionMonitoring() {
|
|
317
|
+
monitoringArmed = true;
|
|
263
318
|
openPlatformStream();
|
|
264
319
|
},
|
|
265
320
|
async start() {
|
|
321
|
+
monitoringArmed = true;
|
|
266
322
|
openPlatformStream();
|
|
267
323
|
startProcessorStatusReporting();
|
|
268
324
|
},
|
|
269
325
|
stop() {
|
|
326
|
+
monitoringArmed = false;
|
|
327
|
+
clearTimeout(processorStatusInitialTimer);
|
|
328
|
+
clearTimeout(recoveryTimer);
|
|
329
|
+
recoveryTimer = undefined;
|
|
270
330
|
isConnected = false;
|
|
271
331
|
// A stopped stream's un-routed backlog is stale — do not replay it if a
|
|
272
332
|
// handler registers later.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-service.js","sourceRoot":"","sources":["../src/platform-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"platform-service.js","sourceRoot":"","sources":["../src/platform-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AA+HhE;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAChC,UAAgC,EACh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
|
2
|
+
* Connection resilience — PACKAGE-PRIVATE.
|
|
3
|
+
*
|
|
4
|
+
* Exponential backoff with full jitter, per-event attempt caps, terminal-error
|
|
5
|
+
* short-circuit, and a warn-then-continue health probe. Nothing here is
|
|
6
|
+
* exported from this package's barrel.
|
|
7
|
+
*
|
|
8
|
+
* It used to live in `@kronos-ts/core`, and it does not belong there. Core is
|
|
9
|
+
* only what cannot be a helper, and this is a helper by every test: it touches
|
|
10
|
+
* no core shape, no message, no unit of work — it is `setTimeout` and a loop
|
|
11
|
+
* over a function anybody could have written. Its only consumers were the
|
|
12
|
+
* transports and the pool, core's own `src/` never called it, and a helper
|
|
13
|
+
* lives with its users. Same reasoning that moved each persistence package's
|
|
14
|
+
* transaction glue out of core, applied one folder up.
|
|
15
|
+
*
|
|
16
|
+
* Each consuming package keeps its own copy, carrying only what it uses, so
|
|
17
|
+
* each can also state its own retry policy without negotiating with the others.
|
|
18
|
+
*/
|
|
19
|
+
/** Classified retry sites used by transport extensions (D-97). */
|
|
20
|
+
export type RetryEvent = "initial-connect" | "reconnect" | "per-operation" | "health-check";
|
|
21
|
+
export type ResilienceConfig = {
|
|
22
|
+
/** Initial backoff delay (ms). Default: 100. */
|
|
23
|
+
initialDelayMs: number;
|
|
24
|
+
/** Cap for backoff (ms). Default: 30_000. */
|
|
25
|
+
maxDelayMs: number;
|
|
26
|
+
/** Max retry attempts before giving up. Per-event defaults applied if not provided. */
|
|
27
|
+
maxAttempts: number;
|
|
28
|
+
/** Base for exponential growth. Default: 2. */
|
|
29
|
+
multiplier: number;
|
|
30
|
+
/** Health-check threshold (ms) before warn-then-continue. Default: 5000. */
|
|
31
|
+
healthCheckThresholdMs: number;
|
|
32
|
+
/** Optional logger. Defaults to console.warn. */
|
|
33
|
+
log?: (msg: string) => void;
|
|
34
|
+
/** Per-attempt classification: returns false to short-circuit (terminal error). */
|
|
35
|
+
isRetryable?: (err: unknown) => boolean;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Run `fn` with exponential-backoff full-jitter retries.
|
|
39
|
+
*
|
|
40
|
+
* Resolves with the first successful result, or rejects with the last error
|
|
41
|
+
* after `maxAttempts` exhausted. If `isRetryable(err)` returns false on any
|
|
42
|
+
* attempt, the error is rethrown immediately (terminal error short-circuit).
|
|
43
|
+
*
|
|
44
|
+
* D-101: opts may carry caller-supplied resilience overrides — this is the
|
|
45
|
+
* per-extension knob path (`kronosDbConnection({ resilience: { ... } })`).
|
|
46
|
+
*/
|
|
47
|
+
export declare function withRetry<T>(fn: () => Promise<T>, opts: {
|
|
48
|
+
event: RetryEvent;
|
|
49
|
+
} & Partial<ResilienceConfig>): Promise<T>;
|
|
50
|
+
/**
|
|
51
|
+
* Run a health-check probe with warn-then-continue semantics (D-100).
|
|
52
|
+
*
|
|
53
|
+
* Resolves WITHOUT throwing on success OR after `thresholdMs` elapses with
|
|
54
|
+
* the probe still pending — production loops should NEVER stall on a flaky
|
|
55
|
+
* health probe. Failures (rejection or threshold breach) emit a single warn
|
|
56
|
+
* via `log` and otherwise resolve normally.
|
|
57
|
+
*/
|
|
58
|
+
export declare function healthCheck(fn: () => Promise<void>, opts?: {
|
|
59
|
+
thresholdMs?: number;
|
|
60
|
+
log?: (msg: string) => void;
|
|
61
|
+
}): Promise<void>;
|
|
62
|
+
//# sourceMappingURL=resilience.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resilience.d.ts","sourceRoot":"","sources":["../src/resilience.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,kEAAkE;AAClE,MAAM,MAAM,UAAU,GAClB,iBAAiB,GACjB,WAAW,GACX,eAAe,GACf,cAAc,CAAA;AAElB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,gDAAgD;IAChD,cAAc,EAAE,MAAM,CAAA;IACtB,6CAA6C;IAC7C,UAAU,EAAE,MAAM,CAAA;IAClB,uFAAuF;IACvF,WAAW,EAAE,MAAM,CAAA;IACnB,+CAA+C;IAC/C,UAAU,EAAE,MAAM,CAAA;IAClB,4EAA4E;IAC5E,sBAAsB,EAAE,MAAM,CAAA;IAC9B,iDAAiD;IACjD,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;IAC3B,mFAAmF;IACnF,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAA;CACxC,CAAA;AAoCD;;;;;;;;;GASG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAC/B,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,IAAI,EAAE;IAAE,KAAK,EAAE,UAAU,CAAA;CAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,GACtD,OAAO,CAAC,CAAC,CAAC,CAqBZ;AAED;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAC/B,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EACvB,IAAI,GAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CAAO,GAC/D,OAAO,CAAC,IAAI,CAAC,CAwBf"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connection resilience — PACKAGE-PRIVATE.
|
|
3
|
+
*
|
|
4
|
+
* Exponential backoff with full jitter, per-event attempt caps, terminal-error
|
|
5
|
+
* short-circuit, and a warn-then-continue health probe. Nothing here is
|
|
6
|
+
* exported from this package's barrel.
|
|
7
|
+
*
|
|
8
|
+
* It used to live in `@kronos-ts/core`, and it does not belong there. Core is
|
|
9
|
+
* only what cannot be a helper, and this is a helper by every test: it touches
|
|
10
|
+
* no core shape, no message, no unit of work — it is `setTimeout` and a loop
|
|
11
|
+
* over a function anybody could have written. Its only consumers were the
|
|
12
|
+
* transports and the pool, core's own `src/` never called it, and a helper
|
|
13
|
+
* lives with its users. Same reasoning that moved each persistence package's
|
|
14
|
+
* transaction glue out of core, applied one folder up.
|
|
15
|
+
*
|
|
16
|
+
* Each consuming package keeps its own copy, carrying only what it uses, so
|
|
17
|
+
* each can also state its own retry policy without negotiating with the others.
|
|
18
|
+
*/
|
|
19
|
+
const DEFAULTS = {
|
|
20
|
+
initialDelayMs: 100,
|
|
21
|
+
maxDelayMs: 30_000,
|
|
22
|
+
maxAttempts: 10,
|
|
23
|
+
multiplier: 2,
|
|
24
|
+
healthCheckThresholdMs: 5_000,
|
|
25
|
+
};
|
|
26
|
+
const ATTEMPTS_BY_EVENT = {
|
|
27
|
+
"initial-connect": 10,
|
|
28
|
+
"reconnect": 30,
|
|
29
|
+
"per-operation": 5,
|
|
30
|
+
"health-check": 3,
|
|
31
|
+
};
|
|
32
|
+
function resolveConfig(event, partial) {
|
|
33
|
+
return {
|
|
34
|
+
...DEFAULTS,
|
|
35
|
+
maxAttempts: ATTEMPTS_BY_EVENT[event],
|
|
36
|
+
...partial,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function fullJitterDelay(attempt, cfg) {
|
|
40
|
+
const exponential = Math.min(cfg.initialDelayMs * Math.pow(cfg.multiplier, attempt), cfg.maxDelayMs);
|
|
41
|
+
return Math.random() * exponential;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Run `fn` with exponential-backoff full-jitter retries.
|
|
45
|
+
*
|
|
46
|
+
* Resolves with the first successful result, or rejects with the last error
|
|
47
|
+
* after `maxAttempts` exhausted. If `isRetryable(err)` returns false on any
|
|
48
|
+
* attempt, the error is rethrown immediately (terminal error short-circuit).
|
|
49
|
+
*
|
|
50
|
+
* D-101: opts may carry caller-supplied resilience overrides — this is the
|
|
51
|
+
* per-extension knob path (`kronosDbConnection({ resilience: { ... } })`).
|
|
52
|
+
*/
|
|
53
|
+
export async function withRetry(fn, opts) {
|
|
54
|
+
const cfg = resolveConfig(opts.event, opts);
|
|
55
|
+
let lastErr;
|
|
56
|
+
for (let attempt = 0; attempt < cfg.maxAttempts; attempt++) {
|
|
57
|
+
try {
|
|
58
|
+
return await fn();
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
lastErr = err;
|
|
62
|
+
if (cfg.isRetryable && !cfg.isRetryable(err))
|
|
63
|
+
throw err;
|
|
64
|
+
if (attempt === cfg.maxAttempts - 1)
|
|
65
|
+
break;
|
|
66
|
+
const delay = fullJitterDelay(attempt, cfg);
|
|
67
|
+
cfg.log?.(`[kronos:resilience] ${opts.event} attempt ${attempt + 1}/${cfg.maxAttempts} ` +
|
|
68
|
+
`failed; retrying in ${Math.round(delay)}ms — ${err?.message ?? String(err)}`);
|
|
69
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
throw lastErr;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Run a health-check probe with warn-then-continue semantics (D-100).
|
|
76
|
+
*
|
|
77
|
+
* Resolves WITHOUT throwing on success OR after `thresholdMs` elapses with
|
|
78
|
+
* the probe still pending — production loops should NEVER stall on a flaky
|
|
79
|
+
* health probe. Failures (rejection or threshold breach) emit a single warn
|
|
80
|
+
* via `log` and otherwise resolve normally.
|
|
81
|
+
*/
|
|
82
|
+
export async function healthCheck(fn, opts = {}) {
|
|
83
|
+
const threshold = opts.thresholdMs ?? DEFAULTS.healthCheckThresholdMs;
|
|
84
|
+
const log = opts.log ?? ((m) => console.warn(m));
|
|
85
|
+
let timer;
|
|
86
|
+
try {
|
|
87
|
+
await Promise.race([
|
|
88
|
+
fn(),
|
|
89
|
+
new Promise((_, reject) => {
|
|
90
|
+
timer = setTimeout(() => reject(new Error("health-check threshold exceeded")), threshold);
|
|
91
|
+
}),
|
|
92
|
+
]);
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
log(`[kronos:resilience] health-check soft-failed (${err?.message ?? String(err)}); continuing`);
|
|
96
|
+
// warn-then-continue: do NOT rethrow.
|
|
97
|
+
}
|
|
98
|
+
finally {
|
|
99
|
+
if (timer)
|
|
100
|
+
clearTimeout(timer);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=resilience.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resilience.js","sourceRoot":"","sources":["../src/resilience.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AA0BH,MAAM,QAAQ,GAAkD;IAC9D,cAAc,EAAE,GAAG;IACnB,UAAU,EAAE,MAAM;IAClB,WAAW,EAAE,EAAE;IACf,UAAU,EAAE,CAAC;IACb,sBAAsB,EAAE,KAAK;CAC9B,CAAA;AAED,MAAM,iBAAiB,GAA+B;IACpD,iBAAiB,EAAE,EAAE;IACrB,WAAW,EAAE,EAAE;IACf,eAAe,EAAE,CAAC;IAClB,cAAc,EAAE,CAAC;CAClB,CAAA;AAED,SAAS,aAAa,CACpB,KAAiB,EACjB,OAAmC;IAEnC,OAAO;QACL,GAAG,QAAQ;QACX,WAAW,EAAE,iBAAiB,CAAC,KAAK,CAAC;QACrC,GAAG,OAAO;KACX,CAAA;AACH,CAAC;AAED,SAAS,eAAe,CAAC,OAAe,EAAE,GAAqB;IAC7D,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAC1B,GAAG,CAAC,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,EACtD,GAAG,CAAC,UAAU,CACf,CAAA;IACD,OAAO,IAAI,CAAC,MAAM,EAAE,GAAG,WAAW,CAAA;AACpC,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,EAAoB,EACpB,IAAuD;IAEvD,MAAM,GAAG,GAAG,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IAC3C,IAAI,OAAgB,CAAA;IACpB,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,GAAG,CAAC,WAAW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,EAAE,MAAM,EAAE,EAAE;gBAC/B,KAAK,GAAG,UAAU,CAChB,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC,EAC1D,SAAS,CACV,CAAA;YACH,CAAC,CAAC;SACH,CAAC,CAAA;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,GAAG,CACD,iDACG,GAAa,EAAE,OAAO,IAAI,MAAM,CAAC,GAAG,CACvC,eAAe,CAChB,CAAA;QACD,sCAAsC;IACxC,CAAC;YAAS,CAAC;QACT,IAAI,KAAK;YAAE,YAAY,CAAC,KAAK,CAAC,CAAA;IAChC,CAAC;AACH,CAAC"}
|
package/dist/shutdown-latch.d.ts
CHANGED
|
@@ -10,11 +10,12 @@
|
|
|
10
10
|
*
|
|
11
11
|
* This is the TypeScript equivalent of AF5's ShutdownLatch pattern.
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export type ShutdownLatch = {
|
|
14
14
|
/**
|
|
15
15
|
* Register an in-flight activity. Throws if shutdown is in progress.
|
|
16
16
|
* Call `end()` on the returned handle when the activity completes.
|
|
17
17
|
*/
|
|
18
|
+
onShutdown(callback: () => void): () => void;
|
|
18
19
|
registerActivity(): ActivityHandle;
|
|
19
20
|
/**
|
|
20
21
|
* Begin graceful shutdown. Returns a promise that resolves when
|
|
@@ -26,11 +27,11 @@ export interface ShutdownLatch {
|
|
|
26
27
|
readonly shuttingDown: boolean;
|
|
27
28
|
/** Number of currently in-flight activities. */
|
|
28
29
|
readonly activeCount: number;
|
|
29
|
-
}
|
|
30
|
-
export
|
|
30
|
+
};
|
|
31
|
+
export type ActivityHandle = {
|
|
31
32
|
/** Mark this activity as complete. */
|
|
32
33
|
end(): void;
|
|
33
|
-
}
|
|
34
|
+
};
|
|
34
35
|
export declare class ShutdownInProgressError extends Error {
|
|
35
36
|
constructor(message?: string);
|
|
36
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shutdown-latch.d.ts","sourceRoot":"","sources":["../src/shutdown-latch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,
|
|
1
|
+
{"version":3,"file":"shutdown-latch.d.ts","sourceRoot":"","sources":["../src/shutdown-latch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;;OAGG;IACH,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAA;IAC5C,gBAAgB,IAAI,cAAc,CAAA;IAElC;;;;OAIG;IACH,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IAEjC,2CAA2C;IAC3C,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAA;IAE9B,gDAAgD;IAChD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,sCAAsC;IACtC,GAAG,IAAI,IAAI,CAAA;CACZ,CAAA;AAED,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,YAAY,OAAO,GAAE,MAA+B,EAGnD;CACF;AAED,wBAAgB,aAAa,IAAI,aAAa,CA+D7C"}
|
package/dist/shutdown-latch.js
CHANGED
|
@@ -5,8 +5,10 @@ export class ShutdownInProgressError extends Error {
|
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
7
|
export function shutdownLatch() {
|
|
8
|
+
const callbacks = new Set();
|
|
8
9
|
let activeCount = 0;
|
|
9
10
|
let shuttingDown = false;
|
|
11
|
+
let drainPromise;
|
|
10
12
|
let drainResolve = null;
|
|
11
13
|
function checkDrained() {
|
|
12
14
|
if (shuttingDown && activeCount === 0 && drainResolve) {
|
|
@@ -15,6 +17,13 @@ export function shutdownLatch() {
|
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
19
|
return {
|
|
20
|
+
onShutdown(callback) {
|
|
21
|
+
if (shuttingDown)
|
|
22
|
+
callback();
|
|
23
|
+
else
|
|
24
|
+
callbacks.add(callback);
|
|
25
|
+
return () => { callbacks.delete(callback); };
|
|
26
|
+
},
|
|
18
27
|
registerActivity() {
|
|
19
28
|
if (shuttingDown) {
|
|
20
29
|
throw new ShutdownInProgressError();
|
|
@@ -33,12 +42,22 @@ export function shutdownLatch() {
|
|
|
33
42
|
},
|
|
34
43
|
initiateShutdown() {
|
|
35
44
|
shuttingDown = true;
|
|
45
|
+
for (const callback of callbacks) {
|
|
46
|
+
try {
|
|
47
|
+
callback();
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
console.error("Messaging shutdown callback failed", error);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
callbacks.clear();
|
|
36
54
|
if (activeCount === 0) {
|
|
37
55
|
return Promise.resolve();
|
|
38
56
|
}
|
|
39
|
-
|
|
57
|
+
drainPromise ??= new Promise((resolve) => {
|
|
40
58
|
drainResolve = resolve;
|
|
41
59
|
});
|
|
60
|
+
return drainPromise;
|
|
42
61
|
},
|
|
43
62
|
get shuttingDown() {
|
|
44
63
|
return shuttingDown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shutdown-latch.js","sourceRoot":"","sources":["../src/shutdown-latch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shutdown-latch.js","sourceRoot":"","sources":["../src/shutdown-latch.ts"],"names":[],"mappings":"AAuCA,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAChD,YAAY,OAAO,GAAW,sBAAsB;QAClD,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAA;IACvC,CAAC;CACF;AAED,MAAM,UAAU,aAAa;IAC3B,MAAM,SAAS,GAAG,IAAI,GAAG,EAAc,CAAA;IACvC,IAAI,WAAW,GAAG,CAAC,CAAA;IACnB,IAAI,YAAY,GAAG,KAAK,CAAA;IACxB,IAAI,YAAuC,CAAA;IAC3C,IAAI,YAAY,GAAw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YACxB,CAAC,CAAC,CAAA;YACF,OAAO,YAAY,CAAA;QACrB,CAAC;QAED,IAAI,YAAY;YACd,OAAO,YAAY,CAAA;QACrB,CAAC;QAED,IAAI,WAAW;YACb,OAAO,WAAW,CAAA;QACpB,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ResilienceConfig } from "./resilience.js";
|
|
2
|
+
/** Retry failures of the async stream, not just synchronous stream creation. */
|
|
3
|
+
export declare function streamRecovery(reopen: () => void, canReconnect: () => boolean, config?: Partial<ResilienceConfig>): {
|
|
4
|
+
failed: (error: unknown) => void;
|
|
5
|
+
received(): void;
|
|
6
|
+
restart(): void;
|
|
7
|
+
stop(): void;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=stream-recovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream-recovery.d.ts","sourceRoot":"","sources":["../src/stream-recovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAEvD,gFAAgF;AAChF,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,IAAI,EAClB,YAAY,EAAE,MAAM,OAAO,EAC3B,MAAM,GAAE,OAAO,CAAC,gBAAgB,CAAM;oBAcf,OAAO;;;;EAmD/B"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/** Retry failures of the async stream, not just synchronous stream creation. */
|
|
2
|
+
export function streamRecovery(reopen, canReconnect, config = {}) {
|
|
3
|
+
const log = (message) => {
|
|
4
|
+
try {
|
|
5
|
+
;
|
|
6
|
+
(config.log ?? console.warn)(message);
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
/* Diagnostics cannot prevent recovery. */
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
let timer;
|
|
13
|
+
let stopped = false;
|
|
14
|
+
let attempts = 0;
|
|
15
|
+
let openedAt = Date.now();
|
|
16
|
+
function failed(error) {
|
|
17
|
+
if (stopped || timer || !canReconnect())
|
|
18
|
+
return;
|
|
19
|
+
if (config.isRetryable?.(error) === false || attempts >= (config.maxAttempts ?? 30)) {
|
|
20
|
+
log(`Provider stream recovery exhausted: ${String(error)}`);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
// Keep a positive floor even when jitter is zero. An immediately-ended
|
|
24
|
+
// async generator must never create a microtask reconnect loop.
|
|
25
|
+
const cap = Math.min((config.initialDelayMs ?? 100) * (config.multiplier ?? 2) ** attempts++, config.maxDelayMs ?? 30000);
|
|
26
|
+
const delay = Math.max(1, cap * (0.5 + Math.random() * 0.5));
|
|
27
|
+
log(`Provider stream failed; reconnecting in ${Math.round(delay)}ms: ${String(error)}`);
|
|
28
|
+
timer = setTimeout(() => {
|
|
29
|
+
timer = undefined;
|
|
30
|
+
if (stopped || !canReconnect())
|
|
31
|
+
return;
|
|
32
|
+
openedAt = Date.now();
|
|
33
|
+
try {
|
|
34
|
+
reopen();
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
failed(error);
|
|
38
|
+
}
|
|
39
|
+
}, delay);
|
|
40
|
+
timer.unref?.();
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
failed,
|
|
44
|
+
received() {
|
|
45
|
+
// Subscription acknowledgements alone do not prove a stable connection.
|
|
46
|
+
if (Date.now() - openedAt >= 30000)
|
|
47
|
+
attempts = 0;
|
|
48
|
+
},
|
|
49
|
+
restart() {
|
|
50
|
+
if (stopped || !canReconnect())
|
|
51
|
+
return;
|
|
52
|
+
clearTimeout(timer);
|
|
53
|
+
timer = undefined;
|
|
54
|
+
attempts = 0;
|
|
55
|
+
openedAt = Date.now();
|
|
56
|
+
try {
|
|
57
|
+
reopen();
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
failed(error);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
stop() {
|
|
64
|
+
stopped = true;
|
|
65
|
+
clearTimeout(timer);
|
|
66
|
+
timer = undefined;
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=stream-recovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream-recovery.js","sourceRoot":"","sources":["../src/stream-recovery.ts"],"names":[],"mappings":"AAEA,gFAAgF;AAChF,MAAM,UAAU,cAAc,CAC5B,MAAkB,EAClB,YAA2B,EAC3B,MAAM,GAA8B,EAAE;IAEtC,MAAM,GAAG,GAAG,CAAC,OAAe,EAAE,EAAE;QAC9B,IAAI,CAAC;YACH,CAAC;YAAA,CAAC,MAAM,CAAC,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAA;QACxC,CAAC;QAAC,MAAM,CAAC;YACP,0CAA0C;QAC5C,CAAC;IACH,CAAC,CAAA;IACD,IAAI,KAAgD,CAAA;IACpD,IAAI,OAAO,GAAG,KAAK,CAAA;IACnB,IAAI,QAAQ,GAAG,CAAC,CAAA;IAChB,IAAI,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;IAEzB,SAAS,MAAM,CAAC,KAAc;QAC5B,IAAI,OAAO,IAAI,KAAK,IAAI,CAAC,YAAY,EAAE;YAAE,OAAM;QAC/C,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,QAAQ,IAAI,CAAC,MAAM,CAAC,WAAW,IAAI,EAAE,CAAC,EAAE,CAAC;YACpF,GAAG,CAAC,uCAAuC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;YAC3D,OAAM;QACR,CAAC;QACD,uEAAuE;QACvE,gEAAgE;QAChE,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAClB,CAAC,MAAM,CAAC,cAAc,IAAI,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,IAAI,CAAC,CAAC,IAAI,QAAQ,EAAE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,IAAI,CAAA;YACd,YAAY,CAAC,KAAK,CAAC,CAAA;YACnB,KAAK,GAAG,SAAS,CAAA;QACnB,CAAC;KACF,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kronos-ts/axon-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Axon Server extension for Kronos — event store and command bus over Axon Server.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"!src/**/*.bench.ts"
|
|
34
34
|
],
|
|
35
35
|
"scripts": {
|
|
36
|
-
"generate-proto": "grpc_tools_node_protoc --ts_proto_out=./src/generated --ts_proto_opt=outputServices=nice-grpc,outputServices=generic-definitions,useExactTypes=false,esModuleInterop=true --proto_path=./proto ./proto/*.proto",
|
|
36
|
+
"generate-proto": "grpc_tools_node_protoc --ts_proto_out=./src/generated --ts_proto_opt=outputServices=nice-grpc,outputServices=generic-definitions,useExactTypes=false,esModuleInterop=true --proto_path=./proto ./proto/*.proto && bun ../../scripts/interface-to-type/convert.ts ./src/generated",
|
|
37
37
|
"build": "tsc -p tsconfig.json",
|
|
38
38
|
"clean": "rm -rf dist *.tsbuildinfo"
|
|
39
39
|
},
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@kronos-ts/core": "0.
|
|
52
|
+
"@kronos-ts/core": "0.4.0",
|
|
53
53
|
"@bufbuild/protobuf": "^2.3",
|
|
54
54
|
"@grpc/grpc-js": "^1.12",
|
|
55
55
|
"nice-grpc": "^2.1",
|