@databricks/sql 1.13.0 → 1.15.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/README.md +12 -0
- package/dist/DBSQLClient.d.ts +107 -0
- package/dist/DBSQLClient.js +470 -0
- package/dist/DBSQLClient.js.map +1 -1
- package/dist/DBSQLOperation.d.ts +32 -1
- package/dist/DBSQLOperation.js +138 -29
- package/dist/DBSQLOperation.js.map +1 -1
- package/dist/DBSQLSession.d.ts +1 -0
- package/dist/DBSQLSession.js +43 -12
- package/dist/DBSQLSession.js.map +1 -1
- package/dist/connection/auth/DatabricksOAuth/OAuthManager.js +10 -6
- package/dist/connection/auth/DatabricksOAuth/OAuthManager.js.map +1 -1
- package/dist/contracts/IClientContext.d.ts +36 -0
- package/dist/contracts/IDBSQLClient.d.ts +90 -0
- package/dist/contracts/IDBSQLSession.d.ts +6 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/result/CloudFetchResultHandler.d.ts +8 -1
- package/dist/result/CloudFetchResultHandler.js +28 -2
- package/dist/result/CloudFetchResultHandler.js.map +1 -1
- package/dist/result/RowSetProvider.d.ts +8 -1
- package/dist/result/RowSetProvider.js +110 -1
- package/dist/result/RowSetProvider.js.map +1 -1
- package/dist/telemetry/CircuitBreaker.d.ts +73 -0
- package/dist/telemetry/CircuitBreaker.js +176 -0
- package/dist/telemetry/CircuitBreaker.js.map +1 -0
- package/dist/telemetry/DatabricksTelemetryExporter.d.ts +76 -0
- package/dist/telemetry/DatabricksTelemetryExporter.js +358 -0
- package/dist/telemetry/DatabricksTelemetryExporter.js.map +1 -0
- package/dist/telemetry/ExceptionClassifier.js +12 -0
- package/dist/telemetry/ExceptionClassifier.js.map +1 -1
- package/dist/telemetry/FeatureFlagCache.d.ts +61 -0
- package/dist/telemetry/FeatureFlagCache.js +214 -0
- package/dist/telemetry/FeatureFlagCache.js.map +1 -0
- package/dist/telemetry/MetricsAggregator.d.ts +110 -0
- package/dist/telemetry/MetricsAggregator.js +610 -0
- package/dist/telemetry/MetricsAggregator.js.map +1 -0
- package/dist/telemetry/TelemetryClient.d.ts +121 -0
- package/dist/telemetry/TelemetryClient.js +296 -0
- package/dist/telemetry/TelemetryClient.js.map +1 -0
- package/dist/telemetry/TelemetryClientProvider.d.ts +62 -0
- package/dist/telemetry/TelemetryClientProvider.js +154 -0
- package/dist/telemetry/TelemetryClientProvider.js.map +1 -0
- package/dist/telemetry/TelemetryEventEmitter.d.ts +119 -0
- package/dist/telemetry/TelemetryEventEmitter.js +151 -0
- package/dist/telemetry/TelemetryEventEmitter.js.map +1 -0
- package/dist/telemetry/telemetryTypeMappers.d.ts +25 -0
- package/dist/telemetry/telemetryTypeMappers.js +72 -0
- package/dist/telemetry/telemetryTypeMappers.js.map +1 -0
- package/dist/telemetry/telemetryUtils.d.ts +70 -0
- package/dist/telemetry/telemetryUtils.js +273 -0
- package/dist/telemetry/telemetryUtils.js.map +1 -0
- package/dist/telemetry/types.d.ts +70 -5
- package/dist/telemetry/types.js +19 -6
- package/dist/telemetry/types.js.map +1 -1
- package/dist/utils/agentDetector.d.ts +20 -0
- package/dist/utils/agentDetector.js +39 -0
- package/dist/utils/agentDetector.js.map +1 -0
- package/dist/utils/buildUserAgentString.js +7 -1
- package/dist/utils/buildUserAgentString.js.map +1 -1
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.js +3 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/queryTags.d.ts +12 -0
- package/dist/utils/queryTags.js +35 -0
- package/dist/utils/queryTags.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
|
@@ -2,6 +2,9 @@ import IDBSQLLogger from './IDBSQLLogger';
|
|
|
2
2
|
import IDriver from './IDriver';
|
|
3
3
|
import IConnectionProvider from '../connection/contracts/IConnectionProvider';
|
|
4
4
|
import IThriftClient from './IThriftClient';
|
|
5
|
+
import IAuthentication from '../connection/contracts/IAuthentication';
|
|
6
|
+
import type TelemetryEventEmitter from '../telemetry/TelemetryEventEmitter';
|
|
7
|
+
import type MetricsAggregator from '../telemetry/MetricsAggregator';
|
|
5
8
|
export interface ClientConfig {
|
|
6
9
|
directResultsDefaultMaxRows: number;
|
|
7
10
|
fetchChunkDefaultMaxRows: number;
|
|
@@ -21,9 +24,37 @@ export interface ClientConfig {
|
|
|
21
24
|
telemetryBatchSize?: number;
|
|
22
25
|
telemetryFlushIntervalMs?: number;
|
|
23
26
|
telemetryMaxRetries?: number;
|
|
27
|
+
telemetryBackoffBaseMs?: number;
|
|
28
|
+
telemetryBackoffMaxMs?: number;
|
|
29
|
+
telemetryBackoffJitterMs?: number;
|
|
24
30
|
telemetryAuthenticatedExport?: boolean;
|
|
25
31
|
telemetryCircuitBreakerThreshold?: number;
|
|
26
32
|
telemetryCircuitBreakerTimeout?: number;
|
|
33
|
+
telemetryMaxPendingMetrics?: number;
|
|
34
|
+
telemetryMaxErrorsPerStatement?: number;
|
|
35
|
+
telemetryStatementTtlMs?: number;
|
|
36
|
+
telemetryCloseTimeoutMs?: number;
|
|
37
|
+
telemetryMaxStatementMetrics?: number;
|
|
38
|
+
/**
|
|
39
|
+
* If `true`, MetricsAggregator installs a `process.on('beforeExit')` hook
|
|
40
|
+
* that triggers a synchronous-as-possible flush before Node.js shuts down.
|
|
41
|
+
* Mitigates data loss when application code calls `process.exit(0)` without
|
|
42
|
+
* awaiting `client.close()`. Default `false` because adding a `beforeExit`
|
|
43
|
+
* listener changes process-exit semantics for hosts that monkey-patch
|
|
44
|
+
* `process.exit` (e.g. some test runners).
|
|
45
|
+
*/
|
|
46
|
+
telemetryFlushOnExit?: boolean;
|
|
47
|
+
userAgentEntry?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Extra HTTP headers attached to driver-owned out-of-band requests
|
|
50
|
+
* (telemetry, feature flags). Populated by `DBSQLClient.connect()` from
|
|
51
|
+
* `ConnectionOptions.customHeaders` plus an `x-databricks-org-id` header
|
|
52
|
+
* derived from the `?o=` query parameter on `httpPath` when present, to
|
|
53
|
+
* support SPOG (Single Panel of Glass) account-level routing on endpoints
|
|
54
|
+
* that don't carry `?o=` in their URL path. NOT applied to Thrift or
|
|
55
|
+
* OAuth/OIDC requests.
|
|
56
|
+
*/
|
|
57
|
+
customHeaders?: Record<string, string>;
|
|
27
58
|
}
|
|
28
59
|
export default interface IClientContext {
|
|
29
60
|
getConfig(): ClientConfig;
|
|
@@ -31,4 +62,9 @@ export default interface IClientContext {
|
|
|
31
62
|
getConnectionProvider(): Promise<IConnectionProvider>;
|
|
32
63
|
getClient(): Promise<IThriftClient>;
|
|
33
64
|
getDriver(): Promise<IDriver>;
|
|
65
|
+
getAuthProvider?(): IAuthentication | undefined;
|
|
66
|
+
/** @internal Telemetry event emitter, undefined when telemetry is disabled. */
|
|
67
|
+
getTelemetryEmitter?(): TelemetryEventEmitter | undefined;
|
|
68
|
+
/** @internal Telemetry aggregator, undefined when telemetry is disabled. */
|
|
69
|
+
getTelemetryAggregator?(): MetricsAggregator | undefined;
|
|
34
70
|
}
|
|
@@ -45,6 +45,90 @@ export type ConnectionOptions = {
|
|
|
45
45
|
socketTimeout?: number;
|
|
46
46
|
proxy?: ProxyOptions;
|
|
47
47
|
enableMetricViewMetadata?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Extra HTTP headers attached to driver-owned out-of-band requests
|
|
50
|
+
* (telemetry POSTs and feature-flag GETs). Not applied to the primary
|
|
51
|
+
* Thrift transport or to OAuth/OIDC token requests.
|
|
52
|
+
*
|
|
53
|
+
* When `path` contains `?o=<workspaceId>` (SPOG account-level routing),
|
|
54
|
+
* the driver automatically injects an `x-databricks-org-id` header unless
|
|
55
|
+
* one is already present in this map.
|
|
56
|
+
*/
|
|
57
|
+
customHeaders?: Record<string, string>;
|
|
58
|
+
/**
|
|
59
|
+
* Whether the driver emits telemetry events (connection / statement /
|
|
60
|
+
* cloud-fetch / error). Defaults to `true`.
|
|
61
|
+
*
|
|
62
|
+
* Activation is gated by **two** conditions:
|
|
63
|
+
* 1. This flag is `true` **and**
|
|
64
|
+
* 2. The remote feature flag for the workspace allows telemetry.
|
|
65
|
+
*
|
|
66
|
+
* Setting this to `false` is a hard, unconditional opt-out. Setting to
|
|
67
|
+
* `true` only requests telemetry; the workspace must also allow it.
|
|
68
|
+
*
|
|
69
|
+
* The environment variable `DATABRICKS_TELEMETRY_DISABLED` set to one of
|
|
70
|
+
* `1`, `true`, `yes`, or `on` (case-insensitive) overrides this flag and
|
|
71
|
+
* disables telemetry entirely.
|
|
72
|
+
*/
|
|
73
|
+
telemetryEnabled?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Maximum number of metrics to batch before flushing to the telemetry
|
|
76
|
+
* endpoint. Default 100.
|
|
77
|
+
*/
|
|
78
|
+
telemetryBatchSize?: number;
|
|
79
|
+
/**
|
|
80
|
+
* How often to flush buffered telemetry metrics, in milliseconds.
|
|
81
|
+
* The flush timer is `unref()`'d so it cannot keep the Node.js process
|
|
82
|
+
* alive on its own. Default 5000ms.
|
|
83
|
+
*/
|
|
84
|
+
telemetryFlushIntervalMs?: number;
|
|
85
|
+
/**
|
|
86
|
+
* Maximum retry attempts for a telemetry export *after* the initial call.
|
|
87
|
+
* Default 3.
|
|
88
|
+
*/
|
|
89
|
+
telemetryMaxRetries?: number;
|
|
90
|
+
/**
|
|
91
|
+
* When `true`, telemetry is sent to the authenticated `/telemetry-ext`
|
|
92
|
+
* endpoint with workspace + session + statement IDs and a system
|
|
93
|
+
* configuration block. When `false`, only error names are emitted via the
|
|
94
|
+
* unauthenticated endpoint. Default `true`.
|
|
95
|
+
*
|
|
96
|
+
* Privacy-relevant: setting `false` minimizes the data surface at the
|
|
97
|
+
* cost of losing most observability.
|
|
98
|
+
*/
|
|
99
|
+
telemetryAuthenticatedExport?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Number of consecutive telemetry export failures before the per-host
|
|
102
|
+
* circuit breaker trips and pauses exports. Default 5.
|
|
103
|
+
*/
|
|
104
|
+
telemetryCircuitBreakerThreshold?: number;
|
|
105
|
+
/**
|
|
106
|
+
* How long the circuit breaker stays open before re-probing the
|
|
107
|
+
* telemetry endpoint, in milliseconds. Default 60000ms (1 minute).
|
|
108
|
+
*/
|
|
109
|
+
telemetryCircuitBreakerTimeout?: number;
|
|
110
|
+
/**
|
|
111
|
+
* Maximum wall-clock time `client.close()` will wait for the final
|
|
112
|
+
* telemetry flush HTTP POST. Bounds shutdown latency so callers
|
|
113
|
+
* doing `await client.close(); process.exit(0)` are not held up by a
|
|
114
|
+
* misbehaving telemetry endpoint. Default 2000ms.
|
|
115
|
+
*/
|
|
116
|
+
telemetryCloseTimeoutMs?: number;
|
|
117
|
+
/**
|
|
118
|
+
* Hard cap on the per-statement aggregation map size. When the cap is
|
|
119
|
+
* reached, the oldest entry is evicted (its buffered errors are emitted
|
|
120
|
+
* as standalone metrics first so the first-failure signal survives).
|
|
121
|
+
* Default 5000.
|
|
122
|
+
*/
|
|
123
|
+
telemetryMaxStatementMetrics?: number;
|
|
124
|
+
/**
|
|
125
|
+
* Maximum number of telemetry metrics buffered in memory before the
|
|
126
|
+
* oldest non-error entry is dropped. Raise this when
|
|
127
|
+
* `getTelemetryStats().droppedMetrics` increases between observations,
|
|
128
|
+
* which indicates the buffer is filling faster than the flush interval
|
|
129
|
+
* can drain it. Default 500.
|
|
130
|
+
*/
|
|
131
|
+
telemetryMaxPendingMetrics?: number;
|
|
48
132
|
} & AuthOptions;
|
|
49
133
|
export interface OpenSessionRequest {
|
|
50
134
|
initialCatalog?: string;
|
|
@@ -52,6 +136,12 @@ export interface OpenSessionRequest {
|
|
|
52
136
|
configuration?: {
|
|
53
137
|
[key: string]: string;
|
|
54
138
|
};
|
|
139
|
+
/**
|
|
140
|
+
* Session-level query tags as key-value pairs. Serialized and passed via session configuration
|
|
141
|
+
* as "QUERY_TAGS". Values may be null/undefined to include a key without a value.
|
|
142
|
+
* If both queryTags and configuration.QUERY_TAGS are specified, queryTags takes precedence.
|
|
143
|
+
*/
|
|
144
|
+
queryTags?: Record<string, string | null | undefined>;
|
|
55
145
|
}
|
|
56
146
|
export default interface IDBSQLClient {
|
|
57
147
|
connect(options: ConnectionOptions): Promise<IDBSQLClient>;
|
|
@@ -20,6 +20,12 @@ export type ExecuteStatementOptions = {
|
|
|
20
20
|
stagingAllowedLocalPath?: string | string[];
|
|
21
21
|
namedParameters?: Record<string, DBSQLParameter | DBSQLParameterValue>;
|
|
22
22
|
ordinalParameters?: Array<DBSQLParameter | DBSQLParameterValue>;
|
|
23
|
+
/**
|
|
24
|
+
* Per-statement query tags as key-value pairs. Serialized and passed via confOverlay
|
|
25
|
+
* as "query_tags". Values may be null/undefined to include a key without a value.
|
|
26
|
+
* These tags apply only to this statement and do not persist across queries.
|
|
27
|
+
*/
|
|
28
|
+
queryTags?: Record<string, string | null | undefined>;
|
|
23
29
|
};
|
|
24
30
|
export type TypeInfoRequest = {
|
|
25
31
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,10 @@ import HttpConnection from './connection/connections/HttpConnection';
|
|
|
12
12
|
import { formatProgress } from './utils';
|
|
13
13
|
import { LogLevel } from './contracts/IDBSQLLogger';
|
|
14
14
|
export type { default as ITokenProvider } from './connection/auth/tokenProvider/ITokenProvider';
|
|
15
|
+
export { CircuitBreakerOpenError, CIRCUIT_BREAKER_OPEN_CODE } from './telemetry/CircuitBreaker';
|
|
16
|
+
export { TelemetryTerminalError } from './telemetry/DatabricksTelemetryExporter';
|
|
17
|
+
export { TelemetryEventType, DEFAULT_TELEMETRY_CONFIG } from './telemetry/types';
|
|
18
|
+
export type { TelemetryEvent, TelemetryMetric, TelemetryConfiguration, StatementMetrics, DriverConfiguration, } from './telemetry/types';
|
|
15
19
|
export declare const auth: {
|
|
16
20
|
PlainHttpAuthentication: typeof PlainHttpAuthentication;
|
|
17
21
|
Token: typeof Token;
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.LogLevel = exports.DBSQLLogger = exports.DBSQLParameterType = exports.DBSQLParameter = exports.DBSQLSession = exports.DBSQLClient = exports.utils = exports.thrift = exports.connections = exports.TProtocolExceptionType = exports.TProtocolException = exports.TApplicationExceptionType = exports.TApplicationException = exports.TException = exports.auth = void 0;
|
|
6
|
+
exports.LogLevel = exports.DBSQLLogger = exports.DBSQLParameterType = exports.DBSQLParameter = exports.DBSQLSession = exports.DBSQLClient = exports.utils = exports.thrift = exports.connections = exports.TProtocolExceptionType = exports.TProtocolException = exports.TApplicationExceptionType = exports.TApplicationException = exports.TException = exports.auth = exports.DEFAULT_TELEMETRY_CONFIG = exports.TelemetryEventType = exports.TelemetryTerminalError = exports.CIRCUIT_BREAKER_OPEN_CODE = exports.CircuitBreakerOpenError = void 0;
|
|
7
7
|
// Don't move this import - it should be placed before any other
|
|
8
8
|
require("./polyfills");
|
|
9
9
|
const thrift_1 = require("thrift");
|
|
@@ -24,6 +24,17 @@ const HttpConnection_1 = __importDefault(require("./connection/connections/HttpC
|
|
|
24
24
|
const utils_1 = require("./utils");
|
|
25
25
|
const IDBSQLLogger_1 = require("./contracts/IDBSQLLogger");
|
|
26
26
|
Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function () { return IDBSQLLogger_1.LogLevel; } });
|
|
27
|
+
var CircuitBreaker_1 = require("./telemetry/CircuitBreaker");
|
|
28
|
+
Object.defineProperty(exports, "CircuitBreakerOpenError", { enumerable: true, get: function () { return CircuitBreaker_1.CircuitBreakerOpenError; } });
|
|
29
|
+
Object.defineProperty(exports, "CIRCUIT_BREAKER_OPEN_CODE", { enumerable: true, get: function () { return CircuitBreaker_1.CIRCUIT_BREAKER_OPEN_CODE; } });
|
|
30
|
+
var DatabricksTelemetryExporter_1 = require("./telemetry/DatabricksTelemetryExporter");
|
|
31
|
+
Object.defineProperty(exports, "TelemetryTerminalError", { enumerable: true, get: function () { return DatabricksTelemetryExporter_1.TelemetryTerminalError; } });
|
|
32
|
+
// Telemetry event/metric/config shapes for consumers that want to inspect
|
|
33
|
+
// telemetry payloads or pre-validate config. The emitter, aggregator, and
|
|
34
|
+
// per-host client are deliberately not re-exported — they are internal.
|
|
35
|
+
var types_1 = require("./telemetry/types");
|
|
36
|
+
Object.defineProperty(exports, "TelemetryEventType", { enumerable: true, get: function () { return types_1.TelemetryEventType; } });
|
|
37
|
+
Object.defineProperty(exports, "DEFAULT_TELEMETRY_CONFIG", { enumerable: true, get: function () { return types_1.DEFAULT_TELEMETRY_CONFIG; } });
|
|
27
38
|
exports.auth = {
|
|
28
39
|
PlainHttpAuthentication: PlainHttpAuthentication_1.default,
|
|
29
40
|
// Token provider classes for custom authentication
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAgE;AAChE,uBAAqB;AAErB,mCAAgC;AAChC,wEAAgD;AAChD,oFAA4D;AAC5D,gEAAwC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAgE;AAChE,uBAAqB;AAErB,mCAAgC;AAChC,wEAAgD;AAChD,oFAA4D;AAC5D,gEAAwC;AA8D/B,sBA9DF,qBAAW,CA8DE;AA7DpB,kEAA0C;AA6DpB,uBA7Df,sBAAY,CA6De;AA5DlC,qDAAsE;AA4DlC,+FA5D3B,+BAAc,OA4D2B;AAAE,mGA5D3B,mCAAkB,OA4D2B;AA3DtE,gEAAwC;AA2DgC,sBA3DjE,qBAAW,CA2DiE;AA1DnF,wGAAgF;AAChF,mEAMyC;AACzC,6FAAqE;AACrE,mCAAyC;AACzC,2DAAoD;AAgDiC,yFAhD5E,uBAAQ,OAgD4E;AA3C7F,6DAAgG;AAAvF,yHAAA,uBAAuB,OAAA;AAAE,2HAAA,yBAAyB,OAAA;AAC3D,uFAAiF;AAAxE,qIAAA,sBAAsB,OAAA;AAE/B,0EAA0E;AAC1E,0EAA0E;AAC1E,wEAAwE;AACxE,2CAAiF;AAAxE,2GAAA,kBAAkB,OAAA;AAAE,iHAAA,wBAAwB,OAAA;AASxC,QAAA,IAAI,GAAG;IAClB,uBAAuB,EAAvB,iCAAuB;IACvB,mDAAmD;IACnD,KAAK,EAAL,qBAAK;IACL,mBAAmB,EAAnB,mCAAmB;IACnB,qBAAqB,EAArB,qCAAqB;IACrB,mBAAmB,EAAnB,mCAAmB;IACnB,kBAAkB,EAAlB,kCAAkB;CACnB,CAAC;AAEF,MAAM,EAAE,UAAU,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,GAChH,eAAM,CAAC;AAEA,gCAAU;AAAE,sDAAqB;AAAE,8DAAyB;AAAE,gDAAkB;AAAE,wDAAsB;AAEpG,QAAA,WAAW,GAAG;IACzB,cAAc,EAAd,wBAAc;CACf,CAAC;AAEW,QAAA,MAAM,GAAG;IACpB,WAAW,EAAX,qBAAW;IACX,iBAAiB,EAAjB,2BAAiB;CAClB,CAAC;AAEW,QAAA,KAAK,GAAG;IACnB,cAAc,EAAd,sBAAc;CACf,CAAC"}
|
|
@@ -6,12 +6,19 @@ export default class CloudFetchResultHandler implements IResultsProvider<ArrowBa
|
|
|
6
6
|
private readonly context;
|
|
7
7
|
private readonly source;
|
|
8
8
|
private readonly isLZ4Compressed;
|
|
9
|
+
private readonly statementId?;
|
|
9
10
|
private pendingLinks;
|
|
10
11
|
private downloadTasks;
|
|
11
|
-
|
|
12
|
+
private chunkIndex;
|
|
13
|
+
constructor(context: IClientContext, source: IResultsProvider<TRowSet | undefined>, metadata: TGetResultSetMetadataResp, statementId?: string);
|
|
12
14
|
hasMore(): Promise<boolean>;
|
|
13
15
|
fetchNext(options: ResultsProviderFetchNextOptions): Promise<ArrowBatch>;
|
|
14
16
|
private logDownloadMetrics;
|
|
15
17
|
private downloadLink;
|
|
16
18
|
private fetch;
|
|
19
|
+
/**
|
|
20
|
+
* Emit cloudfetch.chunk telemetry event.
|
|
21
|
+
* CRITICAL: All exceptions swallowed and logged at LogLevel.debug ONLY.
|
|
22
|
+
*/
|
|
23
|
+
private emitCloudFetchChunk;
|
|
17
24
|
}
|
|
@@ -30,13 +30,17 @@ const node_fetch_1 = __importStar(require("node-fetch"));
|
|
|
30
30
|
const HiveDriverError_1 = __importDefault(require("../errors/HiveDriverError"));
|
|
31
31
|
const utils_1 = require("../utils");
|
|
32
32
|
const IDBSQLLogger_1 = require("../contracts/IDBSQLLogger");
|
|
33
|
+
const telemetryUtils_1 = require("../telemetry/telemetryUtils");
|
|
33
34
|
class CloudFetchResultHandler {
|
|
34
|
-
constructor(context, source,
|
|
35
|
+
constructor(context, source, metadata, statementId) {
|
|
36
|
+
var _a;
|
|
35
37
|
this.pendingLinks = [];
|
|
36
38
|
this.downloadTasks = [];
|
|
39
|
+
this.chunkIndex = 0;
|
|
37
40
|
this.context = context;
|
|
38
41
|
this.source = source;
|
|
39
|
-
this.isLZ4Compressed = lz4Compressed !== null &&
|
|
42
|
+
this.isLZ4Compressed = (_a = metadata.lz4Compressed) !== null && _a !== void 0 ? _a : false;
|
|
43
|
+
this.statementId = statementId;
|
|
40
44
|
if (this.isLZ4Compressed && !(0, utils_1.LZ4)()) {
|
|
41
45
|
throw new HiveDriverError_1.default('Cannot handle LZ4 compressed result: module `lz4` not installed');
|
|
42
46
|
}
|
|
@@ -97,6 +101,9 @@ class CloudFetchResultHandler {
|
|
|
97
101
|
const result = await response.arrayBuffer();
|
|
98
102
|
const downloadTimeMs = Date.now() - startTime;
|
|
99
103
|
this.logDownloadMetrics(link.fileLink, result.byteLength, downloadTimeMs);
|
|
104
|
+
// Emit cloudfetch.chunk telemetry event
|
|
105
|
+
this.emitCloudFetchChunk(this.chunkIndex, downloadTimeMs, result.byteLength);
|
|
106
|
+
this.chunkIndex += 1;
|
|
100
107
|
return {
|
|
101
108
|
batches: [Buffer.from(result)],
|
|
102
109
|
rowCount: link.rowCount.toNumber(true),
|
|
@@ -113,6 +120,25 @@ class CloudFetchResultHandler {
|
|
|
113
120
|
});
|
|
114
121
|
return result.response;
|
|
115
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Emit cloudfetch.chunk telemetry event.
|
|
125
|
+
* CRITICAL: All exceptions swallowed and logged at LogLevel.debug ONLY.
|
|
126
|
+
*/
|
|
127
|
+
emitCloudFetchChunk(chunkIndex, latencyMs, bytes) {
|
|
128
|
+
const { statementId } = this;
|
|
129
|
+
if (!statementId) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
(0, telemetryUtils_1.safeEmit)(this.context, (emitter) => {
|
|
133
|
+
emitter.emitCloudFetchChunk({
|
|
134
|
+
statementId,
|
|
135
|
+
chunkIndex,
|
|
136
|
+
latencyMs,
|
|
137
|
+
bytes,
|
|
138
|
+
compressed: this.isLZ4Compressed,
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
}
|
|
116
142
|
}
|
|
117
143
|
exports.default = CloudFetchResultHandler;
|
|
118
144
|
//# sourceMappingURL=CloudFetchResultHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudFetchResultHandler.js","sourceRoot":"","sources":["../../lib/result/CloudFetchResultHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAAsE;AAEtE,gFAAwD;AAIxD,oCAA+B;AAC/B,4DAAqD;
|
|
1
|
+
{"version":3,"file":"CloudFetchResultHandler.js","sourceRoot":"","sources":["../../lib/result/CloudFetchResultHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAAsE;AAEtE,gFAAwD;AAIxD,oCAA+B;AAC/B,4DAAqD;AACrD,gEAA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
|
|
|
8
8
|
export default class RowSetProvider implements IResultsProvider<TRowSet | undefined> {
|
|
9
9
|
private readonly context;
|
|
10
10
|
private readonly operationHandle;
|
|
11
|
+
private readonly statementId?;
|
|
12
|
+
private chunkIndex;
|
|
11
13
|
private fetchOrientation;
|
|
12
14
|
private prefetchedResults;
|
|
13
15
|
private readonly returnOnlyPrefetchedResults;
|
|
14
16
|
private hasMoreRowsFlag?;
|
|
15
17
|
private get hasMoreRows();
|
|
16
|
-
constructor(context: IClientContext, operationHandle: TOperationHandle, prefetchedResults: Array<TFetchResultsResp | undefined>, returnOnlyPrefetchedResults: boolean);
|
|
18
|
+
constructor(context: IClientContext, operationHandle: TOperationHandle, prefetchedResults: Array<TFetchResultsResp | undefined>, returnOnlyPrefetchedResults: boolean, statementId?: string);
|
|
17
19
|
private processFetchResponse;
|
|
18
20
|
fetchNext({ limit }: ResultsProviderFetchNextOptions): Promise<TRowSet | undefined>;
|
|
21
|
+
/**
|
|
22
|
+
* Emit a chunk telemetry event for one FetchResults page.
|
|
23
|
+
* CRITICAL: All exceptions swallowed and logged at LogLevel.debug ONLY.
|
|
24
|
+
*/
|
|
25
|
+
private emitChunkEvent;
|
|
19
26
|
hasMore(): Promise<boolean>;
|
|
20
27
|
}
|
|
@@ -7,12 +7,66 @@ exports.FetchType = void 0;
|
|
|
7
7
|
const node_int64_1 = __importDefault(require("node-int64"));
|
|
8
8
|
const TCLIService_types_1 = require("../../thrift/TCLIService_types");
|
|
9
9
|
const Status_1 = __importDefault(require("../dto/Status"));
|
|
10
|
+
const telemetryUtils_1 = require("../telemetry/telemetryUtils");
|
|
10
11
|
const utils_1 = require("./utils");
|
|
11
12
|
var FetchType;
|
|
12
13
|
(function (FetchType) {
|
|
13
14
|
FetchType[FetchType["Data"] = 0] = "Data";
|
|
14
15
|
FetchType[FetchType["Logs"] = 1] = "Logs";
|
|
15
16
|
})(FetchType = exports.FetchType || (exports.FetchType = {}));
|
|
17
|
+
/**
|
|
18
|
+
* Rough byte count for a single `TColumn`. Used only for telemetry — exact
|
|
19
|
+
* wire size isn't worth a deserialization pass. Fixed-width values are
|
|
20
|
+
* estimated by their TypeScript-side footprint; strings count their UTF-16
|
|
21
|
+
* length (close enough proxy for UTF-8 payload in most cases). The `nulls`
|
|
22
|
+
* bitmap buffer is included verbatim.
|
|
23
|
+
*
|
|
24
|
+
* Wire-side payload will be slightly different (Thrift's varint encodings,
|
|
25
|
+
* UTF-8 vs the JS engine's UTF-16) but dashboards aggregating
|
|
26
|
+
* `bytesDownloaded` for non-arrow result sets care about scale, not byte-
|
|
27
|
+
* perfect accuracy.
|
|
28
|
+
*/
|
|
29
|
+
function estimateColumnBytes(column) {
|
|
30
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
|
|
31
|
+
let bytes = 0;
|
|
32
|
+
if (column.boolVal) {
|
|
33
|
+
bytes += (_b = (_a = column.boolVal.values) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
34
|
+
bytes += (_d = (_c = column.boolVal.nulls) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0;
|
|
35
|
+
}
|
|
36
|
+
if (column.byteVal) {
|
|
37
|
+
bytes += (_f = (_e = column.byteVal.values) === null || _e === void 0 ? void 0 : _e.length) !== null && _f !== void 0 ? _f : 0;
|
|
38
|
+
bytes += (_h = (_g = column.byteVal.nulls) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 0;
|
|
39
|
+
}
|
|
40
|
+
if (column.i16Val) {
|
|
41
|
+
bytes += ((_k = (_j = column.i16Val.values) === null || _j === void 0 ? void 0 : _j.length) !== null && _k !== void 0 ? _k : 0) * 2;
|
|
42
|
+
bytes += (_m = (_l = column.i16Val.nulls) === null || _l === void 0 ? void 0 : _l.length) !== null && _m !== void 0 ? _m : 0;
|
|
43
|
+
}
|
|
44
|
+
if (column.i32Val) {
|
|
45
|
+
bytes += ((_p = (_o = column.i32Val.values) === null || _o === void 0 ? void 0 : _o.length) !== null && _p !== void 0 ? _p : 0) * 4;
|
|
46
|
+
bytes += (_r = (_q = column.i32Val.nulls) === null || _q === void 0 ? void 0 : _q.length) !== null && _r !== void 0 ? _r : 0;
|
|
47
|
+
}
|
|
48
|
+
if (column.i64Val) {
|
|
49
|
+
bytes += ((_t = (_s = column.i64Val.values) === null || _s === void 0 ? void 0 : _s.length) !== null && _t !== void 0 ? _t : 0) * 8;
|
|
50
|
+
bytes += (_v = (_u = column.i64Val.nulls) === null || _u === void 0 ? void 0 : _u.length) !== null && _v !== void 0 ? _v : 0;
|
|
51
|
+
}
|
|
52
|
+
if (column.doubleVal) {
|
|
53
|
+
bytes += ((_x = (_w = column.doubleVal.values) === null || _w === void 0 ? void 0 : _w.length) !== null && _x !== void 0 ? _x : 0) * 8;
|
|
54
|
+
bytes += (_z = (_y = column.doubleVal.nulls) === null || _y === void 0 ? void 0 : _y.length) !== null && _z !== void 0 ? _z : 0;
|
|
55
|
+
}
|
|
56
|
+
if (column.stringVal) {
|
|
57
|
+
for (const value of (_0 = column.stringVal.values) !== null && _0 !== void 0 ? _0 : []) {
|
|
58
|
+
bytes += (_1 = value === null || value === void 0 ? void 0 : value.length) !== null && _1 !== void 0 ? _1 : 0;
|
|
59
|
+
}
|
|
60
|
+
bytes += (_3 = (_2 = column.stringVal.nulls) === null || _2 === void 0 ? void 0 : _2.length) !== null && _3 !== void 0 ? _3 : 0;
|
|
61
|
+
}
|
|
62
|
+
if (column.binaryVal) {
|
|
63
|
+
for (const value of (_4 = column.binaryVal.values) !== null && _4 !== void 0 ? _4 : []) {
|
|
64
|
+
bytes += (_5 = value === null || value === void 0 ? void 0 : value.length) !== null && _5 !== void 0 ? _5 : 0;
|
|
65
|
+
}
|
|
66
|
+
bytes += (_7 = (_6 = column.binaryVal.nulls) === null || _6 === void 0 ? void 0 : _6.length) !== null && _7 !== void 0 ? _7 : 0;
|
|
67
|
+
}
|
|
68
|
+
return bytes;
|
|
69
|
+
}
|
|
16
70
|
function checkIfOperationHasMoreRows(response) {
|
|
17
71
|
var _a, _b, _c;
|
|
18
72
|
if (response.hasMoreRows) {
|
|
@@ -32,12 +86,14 @@ class RowSetProvider {
|
|
|
32
86
|
// may change between this getter calls
|
|
33
87
|
return (_a = this.hasMoreRowsFlag) !== null && _a !== void 0 ? _a : this.operationHandle.hasResultSet;
|
|
34
88
|
}
|
|
35
|
-
constructor(context, operationHandle, prefetchedResults, returnOnlyPrefetchedResults) {
|
|
89
|
+
constructor(context, operationHandle, prefetchedResults, returnOnlyPrefetchedResults, statementId) {
|
|
90
|
+
this.chunkIndex = 0;
|
|
36
91
|
this.fetchOrientation = TCLIService_types_1.TFetchOrientation.FETCH_FIRST;
|
|
37
92
|
this.prefetchedResults = [];
|
|
38
93
|
this.hasMoreRowsFlag = undefined;
|
|
39
94
|
this.context = context;
|
|
40
95
|
this.operationHandle = operationHandle;
|
|
96
|
+
this.statementId = statementId;
|
|
41
97
|
prefetchedResults.forEach((item) => {
|
|
42
98
|
if (item) {
|
|
43
99
|
this.prefetchedResults.push(item);
|
|
@@ -65,14 +121,67 @@ class RowSetProvider {
|
|
|
65
121
|
return undefined;
|
|
66
122
|
}
|
|
67
123
|
const driver = await this.context.getDriver();
|
|
124
|
+
const startTime = Date.now();
|
|
68
125
|
const response = await driver.fetchResults({
|
|
69
126
|
operationHandle: this.operationHandle,
|
|
70
127
|
orientation: this.fetchOrientation,
|
|
71
128
|
maxRows: new node_int64_1.default(limit),
|
|
72
129
|
fetchType: FetchType.Data,
|
|
73
130
|
});
|
|
131
|
+
const latencyMs = Date.now() - startTime;
|
|
132
|
+
this.emitChunkEvent(latencyMs, response);
|
|
74
133
|
return this.processFetchResponse(response);
|
|
75
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Emit a chunk telemetry event for one FetchResults page.
|
|
137
|
+
* CRITICAL: All exceptions swallowed and logged at LogLevel.debug ONLY.
|
|
138
|
+
*/
|
|
139
|
+
emitChunkEvent(latencyMs, response) {
|
|
140
|
+
const { statementId } = this;
|
|
141
|
+
if (!statementId) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
(0, telemetryUtils_1.safeEmit)(this.context, (emitter) => {
|
|
145
|
+
var _a, _b;
|
|
146
|
+
// Aggregate byte counts across all wire shapes a `TFetchResultsResp`
|
|
147
|
+
// can carry. URL-based result sets (`resultLinks`) bypass this site
|
|
148
|
+
// entirely — they emit from `CloudFetchResultHandler.emitCloudFetchChunk`
|
|
149
|
+
// with the post-download byte count from the cloud-storage GET.
|
|
150
|
+
//
|
|
151
|
+
// Shapes counted here:
|
|
152
|
+
// - `arrowBatches[i].batch` — Arrow inline payload
|
|
153
|
+
// - `binaryColumns` — packed columnar binary blob
|
|
154
|
+
// - `columns[i].*Val.values` — COLUMN_BASED_SET, sum across columns
|
|
155
|
+
// - `rows[i]` — legacy row-based set (rare; estimate)
|
|
156
|
+
let bytes = 0;
|
|
157
|
+
const { results } = response;
|
|
158
|
+
if (results) {
|
|
159
|
+
const { arrowBatches } = results;
|
|
160
|
+
if (arrowBatches) {
|
|
161
|
+
for (const batch of arrowBatches) {
|
|
162
|
+
bytes += (_b = (_a = batch.batch) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
const { binaryColumns } = results;
|
|
166
|
+
if (binaryColumns) {
|
|
167
|
+
bytes += binaryColumns.length;
|
|
168
|
+
}
|
|
169
|
+
const { columns } = results;
|
|
170
|
+
if (columns) {
|
|
171
|
+
for (const column of columns) {
|
|
172
|
+
bytes += estimateColumnBytes(column);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
emitter.emitCloudFetchChunk({
|
|
177
|
+
statementId,
|
|
178
|
+
chunkIndex: this.chunkIndex,
|
|
179
|
+
latencyMs,
|
|
180
|
+
bytes,
|
|
181
|
+
});
|
|
182
|
+
this.chunkIndex += 1;
|
|
183
|
+
});
|
|
184
|
+
}
|
|
76
185
|
async hasMore() {
|
|
77
186
|
// If there are prefetched results available - return `true` regardless of
|
|
78
187
|
// the actual state of `hasMoreRows` flag (because we actually have some data)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RowSetProvider.js","sourceRoot":"","sources":["../../lib/result/RowSetProvider.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA+B;AAC/B,
|
|
1
|
+
{"version":3,"file":"RowSetProvider.js","sourceRoot":"","sources":["../../lib/result/RowSetProvider.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA+B;AAC/B,sEAMwC;AACxC,2DAAmC;AAEnC,gEAAuD;AAEvD,mCAAyC;AAEzC,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,yCAAQ,CAAA;IACR,yCAAQ,CAAA;AACV,CAAC,EAHW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAGpB;AAED;;;;;;;;;;;GAWG;AACH,SAAS,mBAAmB,CAAC,MAAe;;IAC1C,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,MAAM,CAAC,OAAO,EAAE;QAClB,KAAK,IAAI,MAAA,MAAA,MAAM,CAAC,OAAO,CAAC,MAAM,0CAAE,MAAM,mCAAI,CAAC,CAAC;QAC5C,KAAK,IAAI,MAAA,MAAA,MAAM,CAAC,OAAO,CAAC,KAAK,0CAAE,MAAM,mCAAI,CAAC,CAAC;KAC5C;IACD,IAAI,MAAM,CAAC,OAAO,EAAE;QAClB,KAAK,IAAI,MAAA,MAAA,MAAM,CAAC,OAAO,CAAC,MAAM,0CAAE,MAAM,mCAAI,CAAC,CAAC;QAC5C,KAAK,IAAI,MAAA,MAAA,MAAM,CAAC,OAAO,CAAC,KAAK,0CAAE,MAAM,mCAAI,CAAC,CAAC;KAC5C;IACD,IAAI,MAAM,CAAC,MAAM,EAAE;QACjB,KAAK,IAA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,OAAO,EAAE;wBAC5B,KAAK,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC;qBACtC;iBACF;aACF;YAED,OAAO,CAAC,mBAAmB,CAAC;gBAC1B,WAAW;gBACX,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,SAAS;gBACT,KAAK;aACN,CAAC,CAAC;YACH,IAAI,CAAC,UAAU,IAAI,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,0EAA0E;QAC1E,8EAA8E;QAC9E,IAAI,IAAI,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE;YACrC,OAAO,IAAI,CAAC;SACb;QACD,yEAAyE;QACzE,IAAI,IAAI,CAAC,2BAA2B,EAAE;YACpC,OAAO,KAAK,CAAC;SACd;QAED,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF;AAlJD,iCAkJC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Databricks Contributors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import IClientContext from '../contracts/IClientContext';
|
|
17
|
+
export declare enum CircuitBreakerState {
|
|
18
|
+
CLOSED = "CLOSED",
|
|
19
|
+
OPEN = "OPEN",
|
|
20
|
+
HALF_OPEN = "HALF_OPEN"
|
|
21
|
+
}
|
|
22
|
+
export interface CircuitBreakerConfig {
|
|
23
|
+
failureThreshold: number;
|
|
24
|
+
timeout: number;
|
|
25
|
+
successThreshold: number;
|
|
26
|
+
}
|
|
27
|
+
export declare const DEFAULT_CIRCUIT_BREAKER_CONFIG: Readonly<CircuitBreakerConfig>;
|
|
28
|
+
export declare const CIRCUIT_BREAKER_OPEN_CODE: "CIRCUIT_BREAKER_OPEN";
|
|
29
|
+
/**
|
|
30
|
+
* Thrown when execute() is called while the breaker is OPEN or a HALF_OPEN
|
|
31
|
+
* probe is already in flight. Callers identify the condition via
|
|
32
|
+
* `instanceof CircuitBreakerOpenError` or `err.code === CIRCUIT_BREAKER_OPEN_CODE`
|
|
33
|
+
* rather than string-matching the message.
|
|
34
|
+
*/
|
|
35
|
+
export declare class CircuitBreakerOpenError extends Error {
|
|
36
|
+
readonly code: "CIRCUIT_BREAKER_OPEN";
|
|
37
|
+
constructor(message?: string);
|
|
38
|
+
}
|
|
39
|
+
export declare class CircuitBreaker {
|
|
40
|
+
private context;
|
|
41
|
+
private state;
|
|
42
|
+
private failureCount;
|
|
43
|
+
private successCount;
|
|
44
|
+
private nextAttempt?;
|
|
45
|
+
private halfOpenInflight;
|
|
46
|
+
private readonly config;
|
|
47
|
+
constructor(context: IClientContext, config?: Partial<CircuitBreakerConfig>);
|
|
48
|
+
execute<T>(operation: () => Promise<T>): Promise<T>;
|
|
49
|
+
/**
|
|
50
|
+
* Synchronous admission check. Returning `null` means "reject". Returning
|
|
51
|
+
* an object means the caller is admitted; `wasHalfOpenProbe` indicates
|
|
52
|
+
* whether this admission consumed the single HALF_OPEN probe slot so the
|
|
53
|
+
* caller can decrement it in `finally`.
|
|
54
|
+
*
|
|
55
|
+
* Running this as a single synchronous block is what prevents the
|
|
56
|
+
* concurrent-probe race that existed in the previous implementation.
|
|
57
|
+
*/
|
|
58
|
+
private tryAdmit;
|
|
59
|
+
getState(): CircuitBreakerState;
|
|
60
|
+
getFailureCount(): number;
|
|
61
|
+
getSuccessCount(): number;
|
|
62
|
+
private onSuccess;
|
|
63
|
+
private onFailure;
|
|
64
|
+
}
|
|
65
|
+
export declare class CircuitBreakerRegistry {
|
|
66
|
+
private context;
|
|
67
|
+
private breakers;
|
|
68
|
+
constructor(context: IClientContext);
|
|
69
|
+
getCircuitBreaker(host: string, config?: Partial<CircuitBreakerConfig>): CircuitBreaker;
|
|
70
|
+
getAllBreakers(): Map<string, CircuitBreaker>;
|
|
71
|
+
removeCircuitBreaker(host: string): void;
|
|
72
|
+
clear(): void;
|
|
73
|
+
}
|