UNPKG

2.87 kBTypeScriptView Raw
1import { OperationType, ResourceType } from "./common";
2import { CosmosClientOptions } from "./CosmosClientOptions";
3import { DatabaseAccount } from "./documents";
4import { RequestOptions } from "./index";
5import { ResourceResponse } from "./request";
6/**
7 * @hidden
8 * This internal class implements the logic for endpoint management for geo-replicated database accounts.
9 */
10export declare class GlobalEndpointManager {
11 private readDatabaseAccount;
12 /**
13 * The endpoint used to create the client instance.
14 */
15 private defaultEndpoint;
16 /**
17 * Flag to enable/disable automatic redirecting of requests based on read/write operations.
18 */
19 enableEndpointDiscovery: boolean;
20 private isRefreshing;
21 private options;
22 /**
23 * List of azure regions to be used as preferred locations for read requests.
24 */
25 private preferredLocations;
26 private writeableLocations;
27 private readableLocations;
28 /**
29 * @param options - The document client instance.
30 */
31 constructor(options: CosmosClientOptions, readDatabaseAccount: (opts: RequestOptions) => Promise<ResourceResponse<DatabaseAccount>>);
32 /**
33 * Gets the current read endpoint from the endpoint cache.
34 */
35 getReadEndpoint(): Promise<string>;
36 /**
37 * Gets the current write endpoint from the endpoint cache.
38 */
39 getWriteEndpoint(): Promise<string>;
40 getReadEndpoints(): Promise<ReadonlyArray<string>>;
41 getWriteEndpoints(): Promise<ReadonlyArray<string>>;
42 markCurrentLocationUnavailableForRead(endpoint: string): Promise<void>;
43 markCurrentLocationUnavailableForWrite(endpoint: string): Promise<void>;
44 canUseMultipleWriteLocations(resourceType?: ResourceType, operationType?: OperationType): boolean;
45 resolveServiceEndpoint(resourceType: ResourceType, operationType: OperationType): Promise<string>;
46 /**
47 * Refreshes the endpoint list by retrieving the writable and readable locations
48 * from the geo-replicated database account and then updating the locations cache.
49 * We skip the refreshing if enableEndpointDiscovery is set to False
50 */
51 refreshEndpointList(): Promise<void>;
52 private refreshEndpoints;
53 /**
54 * Gets the database account first by using the default endpoint, and if that doesn't returns
55 * use the endpoints for the preferred locations in the order they are specified to get
56 * the database account.
57 */
58 private getDatabaseAccountFromAnyEndpoint;
59 /**
60 * Gets the locational endpoint using the location name passed to it using the default endpoint.
61 *
62 * @param defaultEndpoint - The default endpoint to use for the endpoint.
63 * @param locationName - The location name for the azure region like "East US".
64 */
65 private static getLocationalEndpoint;
66}
67//# sourceMappingURL=globalEndpointManager.d.ts.map
\No newline at end of file