import { ChronicleOptions } from './ChronicleOptions.js'; import { EventStoreName } from './EventStoreName.js'; import { EventStoreNamespaceName } from './EventStoreNamespaceName.js'; import { IChronicleClient } from './IChronicleClient.js'; import { IEventStore } from './IEventStore.js'; /** * Where a {@link ChronicleClient} reads the time and the jitter of its reconnect waits from. * @internal Lets specifications make the waits deterministic. */ export interface ChronicleClientTiming { /** Returns the current time in milliseconds. */ now: () => number; /** Returns a value in [0, 1) choosing where in the upper half of a wait this one lands. */ nextJitter: () => number; } /** * Implements {@link IChronicleClient} by managing a gRPC connection to the * Chronicle Kernel via {@link ChronicleConnection}. * * Create a client by providing {@link ChronicleOptions} configured with a connection string: * * ```typescript * const client = new ChronicleClient(ChronicleOptions.fromConnectionString('chronicle://localhost:35000')); * const store = await client.getEventStore('MyStore'); * await store.eventLog.append('my-entity-id', new MyEvent('data')); * client.dispose(); * ``` */ export declare class ChronicleClient implements IChronicleClient { readonly options: ChronicleOptions; private readonly _timing; private static readonly _healthCheckIntervalMs; private static readonly _maxBackoffMs; /** How long a session must stay up before losing it starts the wait between session reconnects over. */ private static readonly _healthySessionMs; private readonly _connection; private readonly _stores; private readonly _lifecycle; private readonly _logger; private _watchdogHandle?; private _connectOperation?; private _reconnectOperation?; private _discoveryOperation?; private _isDisposed; private _keepAliveAbortController?; private _healthCheckInFlight; private _connectionFailure?; private _consecutiveCredentialRejections; private readonly _disposeController; private _recoveringFrom?; private _sessionLostCount; private _sessionEstablishedAt?; /** * Creates a new {@link ChronicleClient} using the provided options. * @param options - The options to configure the client, including the connection string. * @param _timing - Internal: where the client reads the time and the jitter of its reconnect waits from. */ constructor(options: ChronicleOptions, _timing?: ChronicleClientTiming); /** @inheritdoc */ getEventStore(name: string | EventStoreName, namespace?: string | EventStoreNamespaceName): Promise; private toNamespaceName; private getOrCreateEventStore; /** @inheritdoc */ getEventStores(): Promise; /** @inheritdoc */ dispose(): void; private connectWithRetry; private validateClientObservers; private ensureConnected; private reconnect; private recoverConnection; private static isSessionLost; /** * Keeps a kernel that accepts connections but keeps losing the session right after from causing a hot loop * across the whole fleet: every session lost soon after the last one was established waits longer, with jitter, * and the wait starts over once a session has stayed up long enough to count as healthy. */ private waitBeforeSessionReconnect; private reconnectWithRetry; /** * Waits out the exponential backoff for a failed attempt and reports why. * The delay is jittered so a fleet of clients that lost the same kernel does * not come back in lockstep and knock it over again. */ private backOff; /** Waits for the given time, or until the client is disposed, so a pending wait never outlives the client. */ private delay; private withReconnect; private terminalConnectionError; private hasOAuthCredentialRejection; private shouldReconnect; private isRejectedAuthentication; private mentionsConnectionProblem; private toErrorMessage; private startConnectionWatchdog; private get cannotRunHealthCheck(); private runHealthCheck; private startKernelKeepAlive; private failConnection; private backgroundConnectionFailed; private registerArtifactsForStore; } //# sourceMappingURL=ChronicleClient.d.ts.map