UNPKG

6.11 kBTypeScriptView Raw
1import { ServerNode } from "./ServerNode";
2import { RavenCommand } from "./RavenCommand";
3import { Topology } from "./Topology";
4import { NodeSelector } from "./NodeSelector";
5import { IDisposable } from "../Types/Contracts";
6import { IRequestAuthOptions, IAuthOptions } from "../Auth/AuthOptions";
7import { ICertificate } from "../Auth/Certificate";
8import { ReadBalanceBehavior } from "./ReadBalanceBehavior";
9import { HttpCache } from "./HttpCache";
10import { AggressiveCacheOptions } from "./AggressiveCacheOptions";
11import CurrentIndexAndNode from "./CurrentIndexAndNode";
12import { HttpRequestParameters, HttpRequestParametersWithoutUri } from "../Primitives/Http";
13import { DocumentConventions } from "../Documents/Conventions/DocumentConventions";
14import { SessionInfo } from "../Documents/Session/IDocumentSession";
15import { PromiseStatusTracker } from "../Utility/PromiseUtil";
16export interface ExecuteOptions<TResult> {
17 chosenNode: ServerNode;
18 nodeIndex: number;
19 shouldRetry: boolean;
20}
21export interface ITopologyUpdateEvent {
22 topologyJson: object;
23 serverNodeUrl: string;
24 requestedDatabase?: string;
25 forceUpdate?: boolean;
26 wasUpdated?: boolean;
27}
28export interface IRequestExecutorOptions {
29 authOptions?: IRequestAuthOptions;
30 documentConventions?: DocumentConventions;
31}
32export declare class NodeStatus implements IDisposable {
33 private _nodeStatusCallback;
34 private _timerPeriodInMs;
35 readonly nodeIndex: number;
36 readonly node: ServerNode;
37 private _timer;
38 constructor(nodeIndex: number, node: ServerNode, nodeStatusCallback: (nodeStatus: NodeStatus) => Promise<void>);
39 private _nextTimerPeriod;
40 startTimer(): void;
41 updateTimer(): void;
42 dispose(): void;
43}
44export declare class RequestExecutor implements IDisposable {
45 private _log;
46 static readonly CLIENT_VERSION = "4.1.0";
47 private _updateDatabaseTopologySemaphore;
48 private _updateClientConfigurationSemaphore;
49 private static _failureCheckOperation;
50 private _failedNodesTimers;
51 protected _databaseName: string;
52 protected _certificate: ICertificate;
53 private _lastReturnedResponse;
54 protected _readBalanceBehavior: ReadBalanceBehavior;
55 private readonly _cache;
56 private _topologyTakenFromNode;
57 aggressiveCaching: AggressiveCacheOptions;
58 private _updateTopologyTimer;
59 protected _nodeSelector: NodeSelector;
60 numberOfServerRequests: number;
61 protected _disposed: boolean;
62 private _firstTopologyUpdatePromiseInternal;
63 protected _firstTopologyUpdatePromise: Promise<void>;
64 protected _firstTopologyUpdateStatus: PromiseStatusTracker<void>;
65 protected _lastKnownUrls: string[];
66 protected _clientConfigurationEtag: number;
67 protected _topologyEtag: number;
68 private readonly _conventions;
69 private readonly _authOptions;
70 protected _disableTopologyUpdates: boolean;
71 protected _disableClientConfigurationUpdates: boolean;
72 protected _customHttpRequestOptions: HttpRequestParametersWithoutUri;
73 protected _defaultRequestOptions: HttpRequestParametersWithoutUri;
74 static requestPostProcessor: (req: HttpRequestParameters) => void;
75 customHttpRequestOptions: HttpRequestParametersWithoutUri;
76 getAuthOptions(): IAuthOptions;
77 getTopologyEtag(): number;
78 readonly conventions: DocumentConventions;
79 getClientConfigurationEtag(): number;
80 readonly cache: HttpCache;
81 readonly disposed: boolean;
82 getUrl(): string;
83 getTopology(): Topology;
84 getTopologyNodes(): ServerNode[];
85 protected constructor(database: string, authOptions: IRequestAuthOptions, conventions: DocumentConventions);
86 static create(initialUrls: string[], database: string): RequestExecutor;
87 static create(initialUrls: string[], database: string, opts?: IRequestExecutorOptions): RequestExecutor;
88 static createForSingleNodeWithConfigurationUpdates(url: string, database: string, opts: IRequestExecutorOptions): RequestExecutor;
89 static createForSingleNodeWithoutConfigurationUpdates(url: string, database: string, opts: IRequestExecutorOptions): RequestExecutor;
90 private _ensureNodeSelector;
91 getPreferredNode(): Promise<CurrentIndexAndNode>;
92 getNodeBySessionId(sessionId: number): Promise<CurrentIndexAndNode>;
93 getFastestNode(): Promise<CurrentIndexAndNode>;
94 private _updateClientConfigurationInternal;
95 protected _updateClientConfiguration(): Promise<void>;
96 updateTopology(node: ServerNode, timeout: number, forceUpdate?: boolean): Promise<boolean>;
97 protected static _validateUrls(initialUrls: string[], authOptions: IAuthOptions): any[];
98 private _initializeUpdateTopologyTimer;
99 private _updateTopologyCallback;
100 protected _firstTopologyUpdate(inputUrls: string[]): Promise<void>;
101 protected _throwExceptions(details: string): void;
102 protected _disposeAllFailedNodesTimers(): void;
103 chooseNodeForRequest<TResult>(cmd: RavenCommand<TResult>, sessionInfo: SessionInfo): CurrentIndexAndNode;
104 execute<TResult>(command: RavenCommand<TResult>): Promise<void>;
105 execute<TResult>(command: RavenCommand<TResult>, sessionInfo?: SessionInfo): Promise<void>;
106 execute<TResult>(command: RavenCommand<TResult>, sessionInfo?: SessionInfo, options?: ExecuteOptions<TResult>): Promise<void>;
107 private _unlikelyExecute;
108 private _getFromCache;
109 private _executeOnSpecificNode;
110 private _throwFailedToContactAllNodes;
111 inSpeedTestPhase(): boolean;
112 private _handleUnsuccessfulResponse;
113 private _executeOnAllToFigureOutTheFastest;
114 private _shouldExecuteOnAll;
115 private _nodeSelectorHasMultipleNodes;
116 private _handleServerDown;
117 private static _addFailedResponseToCommand;
118 private _createRequest;
119 private static _handleConflict;
120 private _spawnHealthChecks;
121 private _checkNodeStatusCallback;
122 protected _performHealthCheck(serverNode: ServerNode, nodeIndex: number): Promise<void>;
123 private _setDefaultRequestOptions;
124 dispose(): void;
125}