@cratis/chronicle 6.51.0 → 6.51.1
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/ChronicleClient.ts +127 -99
- package/ChronicleOptions.ts +23 -0
- package/dist/ChronicleClient.d.ts +7 -0
- package/dist/ChronicleClient.d.ts.map +1 -1
- package/dist/ChronicleClient.js +115 -95
- package/dist/ChronicleClient.js.map +1 -1
- package/dist/ChronicleOptions.d.ts +14 -0
- package/dist/ChronicleOptions.d.ts.map +1 -1
- package/dist/ChronicleOptions.js +16 -0
- package/dist/ChronicleOptions.js.map +1 -1
- package/dist/eventSequences/EventSequence.d.ts +12 -0
- package/dist/eventSequences/EventSequence.d.ts.map +1 -1
- package/dist/eventSequences/EventSequence.js +202 -175
- package/dist/eventSequences/EventSequence.js.map +1 -1
- package/dist/eventSequences/PreparedBatchAppend.d.ts +4 -0
- package/dist/eventSequences/PreparedBatchAppend.d.ts.map +1 -0
- package/dist/eventSequences/PreparedBatchAppend.js +4 -0
- package/dist/eventSequences/PreparedBatchAppend.js.map +1 -0
- package/dist/eventSequences/PreparedSingleAppend.d.ts +4 -0
- package/dist/eventSequences/PreparedSingleAppend.d.ts.map +1 -0
- package/dist/eventSequences/PreparedSingleAppend.js +4 -0
- package/dist/eventSequences/PreparedSingleAppend.js.map +1 -0
- package/dist/eventSequences/WireBatchEvent.d.ts +6 -0
- package/dist/eventSequences/WireBatchEvent.d.ts.map +1 -0
- package/dist/eventSequences/WireBatchEvent.js +4 -0
- package/dist/eventSequences/WireBatchEvent.js.map +1 -0
- package/dist/eventSequences/toContractsCausation.d.ts +16 -0
- package/dist/eventSequences/toContractsCausation.d.ts.map +1 -0
- package/dist/eventSequences/toContractsCausation.js +15 -0
- package/dist/eventSequences/toContractsCausation.js.map +1 -0
- package/dist/reducers/ReducerObservation.d.ts +18 -0
- package/dist/reducers/ReducerObservation.d.ts.map +1 -0
- package/dist/reducers/ReducerObservation.js +4 -0
- package/dist/reducers/ReducerObservation.js.map +1 -0
- package/dist/reducers/ReducerObservationSession.d.ts +11 -0
- package/dist/reducers/ReducerObservationSession.d.ts.map +1 -0
- package/dist/reducers/ReducerObservationSession.js +4 -0
- package/dist/reducers/ReducerObservationSession.js.map +1 -0
- package/dist/reducers/Reducers.d.ts +9 -0
- package/dist/reducers/Reducers.d.ts.map +1 -1
- package/dist/reducers/Reducers.js +149 -154
- package/dist/reducers/Reducers.js.map +1 -1
- package/dist/reducers/ReductionOutcome.d.ts +25 -0
- package/dist/reducers/ReductionOutcome.d.ts.map +1 -0
- package/dist/reducers/ReductionOutcome.js +66 -0
- package/dist/reducers/ReductionOutcome.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/eventSequences/EventSequence.ts +265 -186
- package/eventSequences/PreparedBatchAppend.ts +7 -0
- package/eventSequences/PreparedSingleAppend.ts +7 -0
- package/eventSequences/WireBatchEvent.ts +7 -0
- package/eventSequences/toContractsCausation.ts +17 -0
- package/for_ChronicleClient/messageSizes.spec.ts +37 -0
- package/for_ChronicleOptions/when_configuring_message_sizes/with_message_sizes.spec.ts +29 -0
- package/package.json +1 -1
- package/reducers/ReducerObservation.ts +25 -0
- package/reducers/ReducerObservationSession.ts +15 -0
- package/reducers/Reducers.ts +185 -171
- package/reducers/ReductionOutcome.ts +75 -0
package/ChronicleClient.ts
CHANGED
|
@@ -27,6 +27,25 @@ import { TypeDiscoverer } from './types/index.js';
|
|
|
27
27
|
import { takeUnregisteredModelBoundMappings } from './types/modelBoundPropertyMetadata.js';
|
|
28
28
|
import { reachableReadModelTypes } from './readModels/rootReadModelTypes.js';
|
|
29
29
|
|
|
30
|
+
const connectionIndicators = [
|
|
31
|
+
'deadline exceeded',
|
|
32
|
+
'unavailable',
|
|
33
|
+
'connection',
|
|
34
|
+
'connectivity',
|
|
35
|
+
'channel',
|
|
36
|
+
'socket',
|
|
37
|
+
'econnrefused',
|
|
38
|
+
'etimedout'
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
const errorCodeOf = (error: unknown): number | undefined => (error as { code?: number })?.code;
|
|
42
|
+
|
|
43
|
+
const isTerminalServerError = (error: unknown): error is IncompatibleChronicleServer | RejectedChronicleCredentials =>
|
|
44
|
+
error instanceof IncompatibleChronicleServer || error instanceof RejectedChronicleCredentials;
|
|
45
|
+
|
|
46
|
+
/** gRPC status codes DEADLINE_EXCEEDED (4), INTERNAL (13) and UNAVAILABLE (14) are worth a reconnect. */
|
|
47
|
+
const hasReconnectableStatusCode = (error: unknown): boolean => [4, 13, 14].includes(Number(errorCodeOf(error) ?? -1));
|
|
48
|
+
|
|
30
49
|
/**
|
|
31
50
|
* Implements {@link IChronicleClient} by managing a gRPC connection to the
|
|
32
51
|
* Chronicle Kernel via {@link ChronicleConnection}.
|
|
@@ -74,7 +93,12 @@ export class ChronicleClient implements IChronicleClient {
|
|
|
74
93
|
const connectionOptions = options.connectionString.disableTls
|
|
75
94
|
? { connectionString: options.connectionString, credentials: options.connectionString.createCredentials() }
|
|
76
95
|
: { connectionString: options.connectionString };
|
|
77
|
-
this._connection = new ChronicleConnection({
|
|
96
|
+
this._connection = new ChronicleConnection({
|
|
97
|
+
...connectionOptions,
|
|
98
|
+
logger: options.logger,
|
|
99
|
+
maxReceiveMessageSize: options.maxReceiveMessageSize ?? undefined,
|
|
100
|
+
maxSendMessageSize: options.maxSendMessageSize ?? undefined
|
|
101
|
+
});
|
|
78
102
|
|
|
79
103
|
this._logger.info('Created Chronicle client', {
|
|
80
104
|
serverAddress: `${options.connectionString.serverAddress.host}:${options.connectionString.serverAddress.port}`,
|
|
@@ -118,46 +142,13 @@ export class ChronicleClient implements IChronicleClient {
|
|
|
118
142
|
/** @inheritdoc */
|
|
119
143
|
async getEventStore(name: string | EventStoreName, namespace?: string | EventStoreNamespaceName): Promise<IEventStore> {
|
|
120
144
|
const storeName = typeof name === 'string' ? new EventStoreName(name) : name;
|
|
121
|
-
const namespaceName = namespace
|
|
122
|
-
? EventStoreNamespaceName.default
|
|
123
|
-
: typeof namespace === 'string'
|
|
124
|
-
? new EventStoreNamespaceName(namespace)
|
|
125
|
-
: namespace;
|
|
145
|
+
const namespaceName = this.toNamespaceName(namespace);
|
|
126
146
|
|
|
127
147
|
return observeOperation('getEventStore', async span => {
|
|
128
148
|
setTelemetryAttribute(span, 'eventStore', storeName.value);
|
|
129
149
|
setTelemetryAttribute(span, 'namespace', namespaceName.value);
|
|
130
150
|
try {
|
|
131
|
-
const store = await this.withReconnect('get_event_store',
|
|
132
|
-
await this.ensureConnected();
|
|
133
|
-
|
|
134
|
-
const key = `${storeName.value}/${namespaceName.value}`;
|
|
135
|
-
const existing = this._stores.get(key);
|
|
136
|
-
if (existing) {
|
|
137
|
-
this._logger.verbose('Returning cached event store', {
|
|
138
|
-
eventStore: storeName.value,
|
|
139
|
-
namespace: namespaceName.value
|
|
140
|
-
});
|
|
141
|
-
return existing;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
this._logger.debug('Ensuring event store exists in kernel', {
|
|
145
|
-
eventStore: storeName.value
|
|
146
|
-
});
|
|
147
|
-
ensureCommandSuccess('ensure event store', await this._connection.eventStores.ensureEventStore({ Name: storeName.value }));
|
|
148
|
-
|
|
149
|
-
const created = new EventStore(storeName, namespaceName, this._connection, this._lifecycle, this.options.defaultSinkTypeId, this.options.clientArtifactsProvider, this.options.reactorResultHandler, this.options.artifactActivator, this.options.readModelNamingPolicy, this.options.telemetry);
|
|
150
|
-
this._stores.set(key, created);
|
|
151
|
-
|
|
152
|
-
try {
|
|
153
|
-
await this.registerArtifactsForStore(created, 'new-store');
|
|
154
|
-
return created;
|
|
155
|
-
} catch (error) {
|
|
156
|
-
if (this._stores.get(key) === created) this._stores.delete(key);
|
|
157
|
-
created.disposeObservations();
|
|
158
|
-
throw error;
|
|
159
|
-
}
|
|
160
|
-
});
|
|
151
|
+
const store = await this.withReconnect('get_event_store', () => this.getOrCreateEventStore(storeName, namespaceName));
|
|
161
152
|
|
|
162
153
|
ChronicleConventionMetrics.eventStoreRetrievals.add(1, {
|
|
163
154
|
[names.attributes.eventStore]: storeName.value,
|
|
@@ -179,6 +170,42 @@ export class ChronicleClient implements IChronicleClient {
|
|
|
179
170
|
});
|
|
180
171
|
}
|
|
181
172
|
|
|
173
|
+
private toNamespaceName(namespace: string | EventStoreNamespaceName | undefined): EventStoreNamespaceName {
|
|
174
|
+
if (namespace === undefined) return EventStoreNamespaceName.default;
|
|
175
|
+
return typeof namespace === 'string' ? new EventStoreNamespaceName(namespace) : namespace;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
private async getOrCreateEventStore(storeName: EventStoreName, namespaceName: EventStoreNamespaceName): Promise<EventStore> {
|
|
179
|
+
await this.ensureConnected();
|
|
180
|
+
|
|
181
|
+
const key = `${storeName.value}/${namespaceName.value}`;
|
|
182
|
+
const existing = this._stores.get(key);
|
|
183
|
+
if (existing) {
|
|
184
|
+
this._logger.verbose('Returning cached event store', {
|
|
185
|
+
eventStore: storeName.value,
|
|
186
|
+
namespace: namespaceName.value
|
|
187
|
+
});
|
|
188
|
+
return existing;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
this._logger.debug('Ensuring event store exists in kernel', {
|
|
192
|
+
eventStore: storeName.value
|
|
193
|
+
});
|
|
194
|
+
ensureCommandSuccess('ensure event store', await this._connection.eventStores.ensureEventStore({ Name: storeName.value }));
|
|
195
|
+
|
|
196
|
+
const created = new EventStore(storeName, namespaceName, this._connection, this._lifecycle, this.options.defaultSinkTypeId, this.options.clientArtifactsProvider, this.options.reactorResultHandler, this.options.artifactActivator, this.options.readModelNamingPolicy, this.options.telemetry);
|
|
197
|
+
this._stores.set(key, created);
|
|
198
|
+
|
|
199
|
+
try {
|
|
200
|
+
await this.registerArtifactsForStore(created, 'new-store');
|
|
201
|
+
return created;
|
|
202
|
+
} catch (error) {
|
|
203
|
+
if (this._stores.get(key) === created) this._stores.delete(key);
|
|
204
|
+
created.disposeObservations();
|
|
205
|
+
throw error;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
182
209
|
/** @inheritdoc */
|
|
183
210
|
async getEventStores(): Promise<EventStoreName[]> {
|
|
184
211
|
return observeOperation('getEventStores', async span => {
|
|
@@ -300,46 +327,7 @@ export class ChronicleClient implements IChronicleClient {
|
|
|
300
327
|
if (this._connectionFailure) throw this._connectionFailure;
|
|
301
328
|
|
|
302
329
|
if (!this._reconnectOperation) {
|
|
303
|
-
this._reconnectOperation = runInBackgroundContext(
|
|
304
|
-
this._logger.warn('Reconnecting to Chronicle kernel', {
|
|
305
|
-
reason,
|
|
306
|
-
error
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
if (this._lifecycle.isConnected) {
|
|
310
|
-
await this._lifecycle.disconnected(disconnectError => {
|
|
311
|
-
this._logger.error('Disconnected lifecycle callback failed', {
|
|
312
|
-
error: disconnectError
|
|
313
|
-
});
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
let attempt = 0;
|
|
318
|
-
while (!this._isDisposed) {
|
|
319
|
-
try {
|
|
320
|
-
await this._connection.resetChannel();
|
|
321
|
-
await this._connection.connect();
|
|
322
|
-
await this._connection.server.getVersionInfo({}, { signal: AbortSignal.timeout(10_000) });
|
|
323
|
-
this._consecutiveCredentialRejections = 0;
|
|
324
|
-
this._logger.info('Reconnected to Chronicle kernel', { attempt: attempt + 1 });
|
|
325
|
-
await this.startKernelKeepAlive();
|
|
326
|
-
await this._lifecycle.connected(connectedError => {
|
|
327
|
-
this._logger.error('Connected lifecycle callback failed after reconnect', {
|
|
328
|
-
error: connectedError
|
|
329
|
-
});
|
|
330
|
-
});
|
|
331
|
-
return;
|
|
332
|
-
} catch (reconnectError) {
|
|
333
|
-
const terminal = this.terminalConnectionError(reconnectError);
|
|
334
|
-
if (terminal) {
|
|
335
|
-
this.failConnection(terminal);
|
|
336
|
-
throw terminal;
|
|
337
|
-
}
|
|
338
|
-
attempt++;
|
|
339
|
-
await this.backOff(attempt, 'Reconnect attempt failed, retrying', reconnectError);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
}).finally(() => {
|
|
330
|
+
this._reconnectOperation = runInBackgroundContext(() => this.recoverConnection(reason, error)).finally(() => {
|
|
343
331
|
this._reconnectOperation = undefined;
|
|
344
332
|
});
|
|
345
333
|
}
|
|
@@ -347,6 +335,51 @@ export class ChronicleClient implements IChronicleClient {
|
|
|
347
335
|
await this._reconnectOperation;
|
|
348
336
|
}
|
|
349
337
|
|
|
338
|
+
private async recoverConnection(reason: string, error: unknown): Promise<void> {
|
|
339
|
+
this._logger.warn('Reconnecting to Chronicle kernel', {
|
|
340
|
+
reason,
|
|
341
|
+
error
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
if (this._lifecycle.isConnected) {
|
|
345
|
+
await this._lifecycle.disconnected(disconnectError => {
|
|
346
|
+
this._logger.error('Disconnected lifecycle callback failed', {
|
|
347
|
+
error: disconnectError
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
await this.reconnectWithRetry();
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
private async reconnectWithRetry(): Promise<void> {
|
|
356
|
+
let attempt = 0;
|
|
357
|
+
while (!this._isDisposed) {
|
|
358
|
+
try {
|
|
359
|
+
await this._connection.resetChannel();
|
|
360
|
+
await this._connection.connect();
|
|
361
|
+
await this._connection.server.getVersionInfo({}, { signal: AbortSignal.timeout(10_000) });
|
|
362
|
+
this._consecutiveCredentialRejections = 0;
|
|
363
|
+
this._logger.info('Reconnected to Chronicle kernel', { attempt: attempt + 1 });
|
|
364
|
+
await this.startKernelKeepAlive();
|
|
365
|
+
await this._lifecycle.connected(connectedError => {
|
|
366
|
+
this._logger.error('Connected lifecycle callback failed after reconnect', {
|
|
367
|
+
error: connectedError
|
|
368
|
+
});
|
|
369
|
+
});
|
|
370
|
+
return;
|
|
371
|
+
} catch (reconnectError) {
|
|
372
|
+
const terminal = this.terminalConnectionError(reconnectError);
|
|
373
|
+
if (terminal) {
|
|
374
|
+
this.failConnection(terminal);
|
|
375
|
+
throw terminal;
|
|
376
|
+
}
|
|
377
|
+
attempt++;
|
|
378
|
+
await this.backOff(attempt, 'Reconnect attempt failed, retrying', reconnectError);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
350
383
|
/**
|
|
351
384
|
* Waits out the exponential backoff for a failed attempt and reports why.
|
|
352
385
|
* The delay is jittered so a fleet of clients that lost the same kernel does
|
|
@@ -392,7 +425,7 @@ export class ChronicleClient implements IChronicleClient {
|
|
|
392
425
|
}
|
|
393
426
|
|
|
394
427
|
private terminalConnectionError(error: unknown): Error | undefined {
|
|
395
|
-
if (error
|
|
428
|
+
if (isTerminalServerError(error)) return error;
|
|
396
429
|
const rejection = (error as { code?: number })?.code === 16 &&
|
|
397
430
|
(this.options.connectionString.apiKey || this.hasOAuthCredentialRejection(error));
|
|
398
431
|
this._consecutiveCredentialRejections = rejection ? this._consecutiveCredentialRejections + 1 : 0;
|
|
@@ -410,29 +443,20 @@ export class ChronicleClient implements IChronicleClient {
|
|
|
410
443
|
}
|
|
411
444
|
|
|
412
445
|
private shouldReconnect(error: unknown): boolean {
|
|
413
|
-
if (error
|
|
414
|
-
|
|
415
|
-
(
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
const message = this.toErrorMessage(error);
|
|
446
|
+
if (isTerminalServerError(error)) return false;
|
|
447
|
+
return this.isRejectedAuthentication(error) ||
|
|
448
|
+
hasReconnectableStatusCode(error) ||
|
|
449
|
+
this.mentionsConnectionProblem(error);
|
|
450
|
+
}
|
|
419
451
|
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
}
|
|
452
|
+
private isRejectedAuthentication(error: unknown): boolean {
|
|
453
|
+
if (errorCodeOf(error) !== 16) return false;
|
|
454
|
+
return !!this.options.connectionString.apiKey || !!(error as { tokenFailure?: Error })?.tokenFailure;
|
|
455
|
+
}
|
|
423
456
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
'connection',
|
|
428
|
-
'connectivity',
|
|
429
|
-
'channel',
|
|
430
|
-
'socket',
|
|
431
|
-
'econnrefused',
|
|
432
|
-
'etimedout'
|
|
433
|
-
];
|
|
434
|
-
|
|
435
|
-
const combined = `${details} ${message}`.toLowerCase();
|
|
457
|
+
private mentionsConnectionProblem(error: unknown): boolean {
|
|
458
|
+
const details = String((error as { details?: string })?.details ?? '');
|
|
459
|
+
const combined = `${details} ${this.toErrorMessage(error)}`.toLowerCase();
|
|
436
460
|
return connectionIndicators.some(indicator => combined.includes(indicator));
|
|
437
461
|
}
|
|
438
462
|
|
|
@@ -452,10 +476,14 @@ export class ChronicleClient implements IChronicleClient {
|
|
|
452
476
|
this._watchdogHandle.unref?.();
|
|
453
477
|
}
|
|
454
478
|
|
|
479
|
+
private get cannotRunHealthCheck(): boolean {
|
|
480
|
+
return this._isDisposed || !this._lifecycle.isConnected || this._healthCheckInFlight;
|
|
481
|
+
}
|
|
482
|
+
|
|
455
483
|
private async runHealthCheck(): Promise<void> {
|
|
456
484
|
// A black-holed connection makes the probe itself hang, so without the
|
|
457
485
|
// in-flight guard every tick would stack another one that never returns.
|
|
458
|
-
if (this.
|
|
486
|
+
if (this.cannotRunHealthCheck) {
|
|
459
487
|
return;
|
|
460
488
|
}
|
|
461
489
|
|
package/ChronicleOptions.ts
CHANGED
|
@@ -24,6 +24,8 @@ type ChronicleOptionsConstructorParams = {
|
|
|
24
24
|
reactorResultHandler?: ReactorResultHandler;
|
|
25
25
|
artifactActivator?: ClientArtifactsActivator;
|
|
26
26
|
readModelNamingPolicy?: ReadModelNamingPolicy;
|
|
27
|
+
maxReceiveMessageSize?: number | null;
|
|
28
|
+
maxSendMessageSize?: number | null;
|
|
27
29
|
};
|
|
28
30
|
|
|
29
31
|
type ChronicleOptionsFactoryParams = {
|
|
@@ -35,6 +37,8 @@ type ChronicleOptionsFactoryParams = {
|
|
|
35
37
|
reactorResultHandler?: ReactorResultHandler;
|
|
36
38
|
artifactActivator?: ClientArtifactsActivator;
|
|
37
39
|
readModelNamingPolicy?: ReadModelNamingPolicy;
|
|
40
|
+
maxReceiveMessageSize?: number | null;
|
|
41
|
+
maxSendMessageSize?: number | null;
|
|
38
42
|
};
|
|
39
43
|
|
|
40
44
|
/**
|
|
@@ -103,6 +107,18 @@ export class ChronicleOptions {
|
|
|
103
107
|
*/
|
|
104
108
|
readonly readModelNamingPolicy?: ReadModelNamingPolicy;
|
|
105
109
|
|
|
110
|
+
/**
|
|
111
|
+
* The largest gRPC message, in bytes, the client accepts from the kernel. Defaults to 100 MB, matching the
|
|
112
|
+
* other Chronicle clients. `null` leaves it at gRPC's own default of 4 MB, which is not recommended.
|
|
113
|
+
*/
|
|
114
|
+
readonly maxReceiveMessageSize: number | null;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* The largest gRPC message, in bytes, the client sends to the kernel. Defaults to 100 MB, matching the
|
|
118
|
+
* other Chronicle clients. `null` leaves it at gRPC's own default.
|
|
119
|
+
*/
|
|
120
|
+
readonly maxSendMessageSize: number | null;
|
|
121
|
+
|
|
106
122
|
private constructor(options: ChronicleOptionsConstructorParams) {
|
|
107
123
|
this.connectionString = options.connectionString;
|
|
108
124
|
this.programIdentifier = options.programIdentifier ?? 'Unknown';
|
|
@@ -114,6 +130,8 @@ export class ChronicleOptions {
|
|
|
114
130
|
this.reactorResultHandler = options.reactorResultHandler;
|
|
115
131
|
this.artifactActivator = options.artifactActivator;
|
|
116
132
|
this.readModelNamingPolicy = options.readModelNamingPolicy;
|
|
133
|
+
this.maxReceiveMessageSize = options.maxReceiveMessageSize === undefined ? ChronicleOptions.defaultMaxMessageSize : options.maxReceiveMessageSize;
|
|
134
|
+
this.maxSendMessageSize = options.maxSendMessageSize === undefined ? ChronicleOptions.defaultMaxMessageSize : options.maxSendMessageSize;
|
|
117
135
|
const spanNames = options.telemetry?.spanNames;
|
|
118
136
|
if (spanNames !== undefined && spanNames !== 'legacy' && spanNames !== 'convention') {
|
|
119
137
|
throw new TypeError('telemetry.spanNames must be legacy or convention.');
|
|
@@ -131,6 +149,9 @@ export class ChronicleOptions {
|
|
|
131
149
|
this.logger = options.logger;
|
|
132
150
|
}
|
|
133
151
|
|
|
152
|
+
/** The default maximum gRPC message size in bytes: 100 MB. */
|
|
153
|
+
static readonly defaultMaxMessageSize = 100 * 1024 * 1024;
|
|
154
|
+
|
|
134
155
|
private static defaultDiscoveryPatterns(): string[] {
|
|
135
156
|
const typescriptEntry = /\.(?:ts|tsx|mts|cts)$/i.test(process.argv[1] ?? '');
|
|
136
157
|
const typescriptLoader = process.execArgv.some(arg => /(?:tsx|ts-node|--experimental-strip-types|--experimental-transform-types)/i.test(arg));
|
|
@@ -173,6 +194,8 @@ export class ChronicleOptions {
|
|
|
173
194
|
reactorResultHandler: options?.reactorResultHandler,
|
|
174
195
|
artifactActivator: options?.artifactActivator,
|
|
175
196
|
readModelNamingPolicy: options?.readModelNamingPolicy,
|
|
197
|
+
maxReceiveMessageSize: options?.maxReceiveMessageSize,
|
|
198
|
+
maxSendMessageSize: options?.maxSendMessageSize,
|
|
176
199
|
telemetry: options?.telemetry,
|
|
177
200
|
logger: options?.logger
|
|
178
201
|
});
|
|
@@ -40,6 +40,8 @@ export declare class ChronicleClient implements IChronicleClient {
|
|
|
40
40
|
constructor(options: ChronicleOptions);
|
|
41
41
|
/** @inheritdoc */
|
|
42
42
|
getEventStore(name: string | EventStoreName, namespace?: string | EventStoreNamespaceName): Promise<IEventStore>;
|
|
43
|
+
private toNamespaceName;
|
|
44
|
+
private getOrCreateEventStore;
|
|
43
45
|
/** @inheritdoc */
|
|
44
46
|
getEventStores(): Promise<EventStoreName[]>;
|
|
45
47
|
/** @inheritdoc */
|
|
@@ -47,6 +49,8 @@ export declare class ChronicleClient implements IChronicleClient {
|
|
|
47
49
|
private connectWithRetry;
|
|
48
50
|
private ensureConnected;
|
|
49
51
|
private reconnect;
|
|
52
|
+
private recoverConnection;
|
|
53
|
+
private reconnectWithRetry;
|
|
50
54
|
/**
|
|
51
55
|
* Waits out the exponential backoff for a failed attempt and reports why.
|
|
52
56
|
* The delay is jittered so a fleet of clients that lost the same kernel does
|
|
@@ -57,8 +61,11 @@ export declare class ChronicleClient implements IChronicleClient {
|
|
|
57
61
|
private terminalConnectionError;
|
|
58
62
|
private hasOAuthCredentialRejection;
|
|
59
63
|
private shouldReconnect;
|
|
64
|
+
private isRejectedAuthentication;
|
|
65
|
+
private mentionsConnectionProblem;
|
|
60
66
|
private toErrorMessage;
|
|
61
67
|
private startConnectionWatchdog;
|
|
68
|
+
private get cannotRunHealthCheck();
|
|
62
69
|
private runHealthCheck;
|
|
63
70
|
private startKernelKeepAlive;
|
|
64
71
|
private failConnection;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChronicleClient.d.ts","sourceRoot":"","sources":["../ChronicleClient.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAUzD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"ChronicleClient.d.ts","sourceRoot":"","sources":["../ChronicleClient.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAUzD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AA4B/C;;;;;;;;;;;;GAYG;AACH,qBAAa,eAAgB,YAAW,gBAAgB;IAwBxC,QAAQ,CAAC,OAAO,EAAE,gBAAgB;IAvB9C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,sBAAsB,CAAQ;IACtD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAU;IAE/C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAsB;IAClD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAsC;IAC9D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA6B;IAExD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkC;IAE1D,OAAO,CAAC,eAAe,CAAC,CAAiC;IACzD,OAAO,CAAC,iBAAiB,CAAC,CAAgB;IAC1C,OAAO,CAAC,mBAAmB,CAAC,CAAgB;IAC5C,OAAO,CAAC,mBAAmB,CAAC,CAAgB;IAC5C,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,yBAAyB,CAAC,CAAkB;IACpD,OAAO,CAAC,oBAAoB,CAAS;IACrC,OAAO,CAAC,kBAAkB,CAAC,CAAQ;IACnC,OAAO,CAAC,gCAAgC,CAAK;IAE7C;;;OAGG;IACH,YAAqB,OAAO,EAAE,gBAAgB,EAsD7C;IAED,kBAAkB;IACZ,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,uBAAuB,GAAG,OAAO,CAAC,WAAW,CAAC,CA4BrH;IAED,OAAO,CAAC,eAAe;YAKT,qBAAqB;IA+BnC,kBAAkB;IACZ,cAAc,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAuBhD;IAED,kBAAkB;IAClB,OAAO,IAAI,IAAI,CAqBd;YAEa,gBAAgB;YA4ChB,eAAe;YAuBf,SAAS;YAYT,iBAAiB;YAiBjB,kBAAkB;IA4BhC;;;;OAIG;YACW,OAAO;YAcP,aAAa;IAyB3B,OAAO,CAAC,uBAAuB;IAW/B,OAAO,CAAC,2BAA2B;IAOnC,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,wBAAwB;IAKhC,OAAO,CAAC,yBAAyB;IAMjC,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,uBAAuB;IAQ/B,OAAO,KAAK,oBAAoB,GAE/B;YAEa,cAAc;YAkBd,oBAAoB;IAmClC,OAAO,CAAC,cAAc;IAatB,OAAO,CAAC,0BAA0B;YAQpB,yBAAyB;CA4B1C"}
|