@databricks/sql 1.12.0 → 1.14.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/dist/DBSQLClient.d.ts +13 -0
- package/dist/DBSQLClient.js +58 -1
- package/dist/DBSQLClient.js.map +1 -1
- package/dist/DBSQLOperation.d.ts +1 -0
- package/dist/DBSQLOperation.js +23 -2
- package/dist/DBSQLOperation.js.map +1 -1
- package/dist/DBSQLSession.js +5 -1
- package/dist/DBSQLSession.js.map +1 -1
- package/dist/connection/auth/tokenProvider/CachedTokenProvider.d.ts +37 -0
- package/dist/connection/auth/tokenProvider/CachedTokenProvider.js +79 -0
- package/dist/connection/auth/tokenProvider/CachedTokenProvider.js.map +1 -0
- package/dist/connection/auth/tokenProvider/ExternalTokenProvider.d.ts +28 -0
- package/dist/connection/auth/tokenProvider/ExternalTokenProvider.js +37 -0
- package/dist/connection/auth/tokenProvider/ExternalTokenProvider.js.map +1 -0
- package/dist/connection/auth/tokenProvider/FederationProvider.d.ts +57 -0
- package/dist/connection/auth/tokenProvider/FederationProvider.js +218 -0
- package/dist/connection/auth/tokenProvider/FederationProvider.js.map +1 -0
- package/dist/connection/auth/tokenProvider/ITokenProvider.d.ts +17 -0
- package/dist/connection/auth/tokenProvider/ITokenProvider.js +3 -0
- package/dist/connection/auth/tokenProvider/ITokenProvider.js.map +1 -0
- package/dist/connection/auth/tokenProvider/StaticTokenProvider.d.ts +24 -0
- package/dist/connection/auth/tokenProvider/StaticTokenProvider.js +43 -0
- package/dist/connection/auth/tokenProvider/StaticTokenProvider.js.map +1 -0
- package/dist/connection/auth/tokenProvider/Token.d.ts +75 -0
- package/dist/connection/auth/tokenProvider/Token.js +120 -0
- package/dist/connection/auth/tokenProvider/Token.js.map +1 -0
- package/dist/connection/auth/tokenProvider/TokenProviderAuthenticator.d.ts +21 -0
- package/dist/connection/auth/tokenProvider/TokenProviderAuthenticator.js +38 -0
- package/dist/connection/auth/tokenProvider/TokenProviderAuthenticator.js.map +1 -0
- package/dist/connection/auth/tokenProvider/index.d.ts +8 -0
- package/dist/connection/auth/tokenProvider/index.js +23 -0
- package/dist/connection/auth/tokenProvider/index.js.map +1 -0
- package/dist/connection/auth/tokenProvider/utils.d.ts +24 -0
- package/dist/connection/auth/tokenProvider/utils.js +83 -0
- package/dist/connection/auth/tokenProvider/utils.js.map +1 -0
- package/dist/contracts/IClientContext.d.ts +15 -0
- package/dist/contracts/IDBSQLClient.d.ts +24 -0
- package/dist/contracts/IDBSQLSession.d.ts +6 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +15 -1
- package/dist/index.js.map +1 -1
- package/dist/result/ArrowResultHandler.js +2 -2
- package/dist/result/ArrowResultHandler.js.map +1 -1
- package/dist/result/CloudFetchResultHandler.js +2 -2
- package/dist/result/CloudFetchResultHandler.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 +324 -0
- package/dist/telemetry/DatabricksTelemetryExporter.js.map +1 -0
- package/dist/telemetry/ExceptionClassifier.d.ts +48 -0
- package/dist/telemetry/ExceptionClassifier.js +112 -0
- package/dist/telemetry/ExceptionClassifier.js.map +1 -0
- package/dist/telemetry/FeatureFlagCache.d.ts +61 -0
- package/dist/telemetry/FeatureFlagCache.js +208 -0
- package/dist/telemetry/FeatureFlagCache.js.map +1 -0
- package/dist/telemetry/MetricsAggregator.d.ts +72 -0
- package/dist/telemetry/MetricsAggregator.js +375 -0
- package/dist/telemetry/MetricsAggregator.js.map +1 -0
- package/dist/telemetry/TelemetryClient.d.ts +41 -0
- package/dist/telemetry/TelemetryClient.js +64 -0
- package/dist/telemetry/TelemetryClient.js.map +1 -0
- package/dist/telemetry/TelemetryClientProvider.d.ts +67 -0
- package/dist/telemetry/TelemetryClientProvider.js +148 -0
- package/dist/telemetry/TelemetryClientProvider.js.map +1 -0
- package/dist/telemetry/TelemetryEventEmitter.d.ts +93 -0
- package/dist/telemetry/TelemetryEventEmitter.js +172 -0
- package/dist/telemetry/TelemetryEventEmitter.js.map +1 -0
- package/dist/telemetry/telemetryUtils.d.ts +56 -0
- package/dist/telemetry/telemetryUtils.js +222 -0
- package/dist/telemetry/telemetryUtils.js.map +1 -0
- package/dist/telemetry/types.d.ts +209 -0
- package/dist/telemetry/types.js +52 -0
- package/dist/telemetry/types.js.map +1 -0
- package/dist/telemetry/urlUtils.d.ts +22 -0
- package/dist/telemetry/urlUtils.js +35 -0
- package/dist/telemetry/urlUtils.js.map +1 -0
- 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/lz4.d.ts +2 -2
- package/dist/utils/lz4.js +13 -1
- package/dist/utils/lz4.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 +1 -1
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isSameHost = exports.getJWTIssuer = exports.decodeJWT = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Decodes a JWT token without verifying the signature.
|
|
6
|
+
* This is safe because the server will validate the token anyway.
|
|
7
|
+
*
|
|
8
|
+
* @param token - The JWT token string
|
|
9
|
+
* @returns The decoded payload as a record, or null if decoding fails
|
|
10
|
+
*/
|
|
11
|
+
function decodeJWT(token) {
|
|
12
|
+
try {
|
|
13
|
+
const parts = token.split('.');
|
|
14
|
+
if (parts.length < 2) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const payload = Buffer.from(parts[1], 'base64').toString('utf8');
|
|
18
|
+
return JSON.parse(payload);
|
|
19
|
+
}
|
|
20
|
+
catch (_a) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.decodeJWT = decodeJWT;
|
|
25
|
+
/**
|
|
26
|
+
* Extracts the issuer from a JWT token.
|
|
27
|
+
*
|
|
28
|
+
* @param token - The JWT token string
|
|
29
|
+
* @returns The issuer string, or null if not found
|
|
30
|
+
*/
|
|
31
|
+
function getJWTIssuer(token) {
|
|
32
|
+
const payload = decodeJWT(token);
|
|
33
|
+
if (!payload || typeof payload.iss !== 'string') {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
return payload.iss;
|
|
37
|
+
}
|
|
38
|
+
exports.getJWTIssuer = getJWTIssuer;
|
|
39
|
+
/**
|
|
40
|
+
* Extracts the hostname from a URL or hostname string.
|
|
41
|
+
* Handles both full URLs and bare hostnames.
|
|
42
|
+
*
|
|
43
|
+
* @param urlOrHostname - A URL or hostname string
|
|
44
|
+
* @returns The extracted hostname
|
|
45
|
+
*/
|
|
46
|
+
function extractHostname(urlOrHostname) {
|
|
47
|
+
// If it looks like a URL, parse it
|
|
48
|
+
if (urlOrHostname.includes('://')) {
|
|
49
|
+
const url = new URL(urlOrHostname);
|
|
50
|
+
return url.hostname;
|
|
51
|
+
}
|
|
52
|
+
// Handle hostname with port (e.g., "databricks.com:443")
|
|
53
|
+
const colonIndex = urlOrHostname.indexOf(':');
|
|
54
|
+
if (colonIndex !== -1) {
|
|
55
|
+
return urlOrHostname.substring(0, colonIndex);
|
|
56
|
+
}
|
|
57
|
+
// Bare hostname
|
|
58
|
+
return urlOrHostname;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Compares two host URLs, ignoring ports.
|
|
62
|
+
* Treats "databricks.com" and "databricks.com:443" as equivalent.
|
|
63
|
+
*
|
|
64
|
+
* @param url1 - First URL or hostname
|
|
65
|
+
* @param url2 - Second URL or hostname
|
|
66
|
+
* @returns true if the hosts are the same
|
|
67
|
+
*/
|
|
68
|
+
function isSameHost(url1, url2) {
|
|
69
|
+
try {
|
|
70
|
+
const host1 = extractHostname(url1);
|
|
71
|
+
const host2 = extractHostname(url2);
|
|
72
|
+
// Empty hostnames are not valid
|
|
73
|
+
if (!host1 || !host2) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
return host1.toLowerCase() === host2.toLowerCase();
|
|
77
|
+
}
|
|
78
|
+
catch (_a) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.isSameHost = isSameHost;
|
|
83
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../lib/connection/auth/tokenProvider/utils.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,SAAgB,SAAS,CAAC,KAAa;IACrC,IAAI;QACF,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;YACpB,OAAO,IAAI,CAAC;SACb;QACD,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACjE,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;KAC5B;IAAC,WAAM;QACN,OAAO,IAAI,CAAC;KACb;AACH,CAAC;AAXD,8BAWC;AAED;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,KAAa;IACxC,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IACjC,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ,EAAE;QAC/C,OAAO,IAAI,CAAC;KACb;IACD,OAAO,OAAO,CAAC,GAAG,CAAC;AACrB,CAAC;AAND,oCAMC;AAED;;;;;;GAMG;AACH,SAAS,eAAe,CAAC,aAAqB;IAC5C,mCAAmC;IACnC,IAAI,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QACjC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,CAAC;QACnC,OAAO,GAAG,CAAC,QAAQ,CAAC;KACrB;IAED,yDAAyD;IACzD,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC9C,IAAI,UAAU,KAAK,CAAC,CAAC,EAAE;QACrB,OAAO,aAAa,CAAC,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;KAC/C;IAED,gBAAgB;IAChB,OAAO,aAAa,CAAC;AACvB,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,UAAU,CAAC,IAAY,EAAE,IAAY;IACnD,IAAI;QACF,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;QACpC,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;QACpC,gCAAgC;QAChC,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,EAAE;YACpB,OAAO,KAAK,CAAC;SACd;QACD,OAAO,KAAK,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,WAAW,EAAE,CAAC;KACpD;IAAC,WAAM;QACN,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAZD,gCAYC"}
|
|
@@ -16,6 +16,21 @@ export interface ClientConfig {
|
|
|
16
16
|
cloudFetchConcurrentDownloads: number;
|
|
17
17
|
cloudFetchSpeedThresholdMBps: number;
|
|
18
18
|
useLZ4Compression: boolean;
|
|
19
|
+
enableMetricViewMetadata?: boolean;
|
|
20
|
+
telemetryEnabled?: boolean;
|
|
21
|
+
telemetryBatchSize?: number;
|
|
22
|
+
telemetryFlushIntervalMs?: number;
|
|
23
|
+
telemetryMaxRetries?: number;
|
|
24
|
+
telemetryBackoffBaseMs?: number;
|
|
25
|
+
telemetryBackoffMaxMs?: number;
|
|
26
|
+
telemetryBackoffJitterMs?: number;
|
|
27
|
+
telemetryAuthenticatedExport?: boolean;
|
|
28
|
+
telemetryCircuitBreakerThreshold?: number;
|
|
29
|
+
telemetryCircuitBreakerTimeout?: number;
|
|
30
|
+
telemetryMaxPendingMetrics?: number;
|
|
31
|
+
telemetryMaxErrorsPerStatement?: number;
|
|
32
|
+
telemetryStatementTtlMs?: number;
|
|
33
|
+
userAgentEntry?: string;
|
|
19
34
|
}
|
|
20
35
|
export default interface IClientContext {
|
|
21
36
|
getConfig(): ClientConfig;
|
|
@@ -3,6 +3,8 @@ import IDBSQLSession from './IDBSQLSession';
|
|
|
3
3
|
import IAuthentication from '../connection/contracts/IAuthentication';
|
|
4
4
|
import { ProxyOptions } from '../connection/contracts/IConnectionOptions';
|
|
5
5
|
import OAuthPersistence from '../connection/auth/DatabricksOAuth/OAuthPersistence';
|
|
6
|
+
import ITokenProvider from '../connection/auth/tokenProvider/ITokenProvider';
|
|
7
|
+
import { TokenCallback } from '../connection/auth/tokenProvider/ExternalTokenProvider';
|
|
6
8
|
export interface ClientOptions {
|
|
7
9
|
logger?: IDBSQLLogger;
|
|
8
10
|
}
|
|
@@ -19,6 +21,21 @@ type AuthOptions = {
|
|
|
19
21
|
} | {
|
|
20
22
|
authType: 'custom';
|
|
21
23
|
provider: IAuthentication;
|
|
24
|
+
} | {
|
|
25
|
+
authType: 'token-provider';
|
|
26
|
+
tokenProvider: ITokenProvider;
|
|
27
|
+
enableTokenFederation?: boolean;
|
|
28
|
+
federationClientId?: string;
|
|
29
|
+
} | {
|
|
30
|
+
authType: 'external-token';
|
|
31
|
+
getToken: TokenCallback;
|
|
32
|
+
enableTokenFederation?: boolean;
|
|
33
|
+
federationClientId?: string;
|
|
34
|
+
} | {
|
|
35
|
+
authType: 'static-token';
|
|
36
|
+
staticToken: string;
|
|
37
|
+
enableTokenFederation?: boolean;
|
|
38
|
+
federationClientId?: string;
|
|
22
39
|
};
|
|
23
40
|
export type ConnectionOptions = {
|
|
24
41
|
host: string;
|
|
@@ -27,6 +44,7 @@ export type ConnectionOptions = {
|
|
|
27
44
|
userAgentEntry?: string;
|
|
28
45
|
socketTimeout?: number;
|
|
29
46
|
proxy?: ProxyOptions;
|
|
47
|
+
enableMetricViewMetadata?: boolean;
|
|
30
48
|
} & AuthOptions;
|
|
31
49
|
export interface OpenSessionRequest {
|
|
32
50
|
initialCatalog?: string;
|
|
@@ -34,6 +52,12 @@ export interface OpenSessionRequest {
|
|
|
34
52
|
configuration?: {
|
|
35
53
|
[key: string]: string;
|
|
36
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* Session-level query tags as key-value pairs. Serialized and passed via session configuration
|
|
57
|
+
* as "QUERY_TAGS". Values may be null/undefined to include a key without a value.
|
|
58
|
+
* If both queryTags and configuration.QUERY_TAGS are specified, queryTags takes precedence.
|
|
59
|
+
*/
|
|
60
|
+
queryTags?: Record<string, string | null | undefined>;
|
|
37
61
|
}
|
|
38
62
|
export default interface IDBSQLClient {
|
|
39
63
|
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
|
@@ -7,11 +7,20 @@ import DBSQLSession from './DBSQLSession';
|
|
|
7
7
|
import { DBSQLParameter, DBSQLParameterType } from './DBSQLParameter';
|
|
8
8
|
import DBSQLLogger from './DBSQLLogger';
|
|
9
9
|
import PlainHttpAuthentication from './connection/auth/PlainHttpAuthentication';
|
|
10
|
+
import { Token, StaticTokenProvider, ExternalTokenProvider, CachedTokenProvider, FederationProvider } from './connection/auth/tokenProvider';
|
|
10
11
|
import HttpConnection from './connection/connections/HttpConnection';
|
|
11
12
|
import { formatProgress } from './utils';
|
|
12
13
|
import { LogLevel } from './contracts/IDBSQLLogger';
|
|
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';
|
|
13
17
|
export declare const auth: {
|
|
14
18
|
PlainHttpAuthentication: typeof PlainHttpAuthentication;
|
|
19
|
+
Token: typeof Token;
|
|
20
|
+
StaticTokenProvider: typeof StaticTokenProvider;
|
|
21
|
+
ExternalTokenProvider: typeof ExternalTokenProvider;
|
|
22
|
+
CachedTokenProvider: typeof CachedTokenProvider;
|
|
23
|
+
FederationProvider: typeof FederationProvider;
|
|
15
24
|
};
|
|
16
25
|
declare const TException: typeof Thrift.TException, TApplicationException: typeof Thrift.TApplicationException, TApplicationExceptionType: typeof Thrift.TApplicationExceptionType, TProtocolException: typeof Thrift.TProtocolException, TProtocolExceptionType: typeof Thrift.TProtocolExceptionType;
|
|
17
26
|
export { TException, TApplicationException, TApplicationExceptionType, TProtocolException, TProtocolExceptionType };
|
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.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");
|
|
@@ -19,12 +19,26 @@ Object.defineProperty(exports, "DBSQLParameterType", { enumerable: true, get: fu
|
|
|
19
19
|
const DBSQLLogger_1 = __importDefault(require("./DBSQLLogger"));
|
|
20
20
|
exports.DBSQLLogger = DBSQLLogger_1.default;
|
|
21
21
|
const PlainHttpAuthentication_1 = __importDefault(require("./connection/auth/PlainHttpAuthentication"));
|
|
22
|
+
const tokenProvider_1 = require("./connection/auth/tokenProvider");
|
|
22
23
|
const HttpConnection_1 = __importDefault(require("./connection/connections/HttpConnection"));
|
|
23
24
|
const utils_1 = require("./utils");
|
|
24
25
|
const IDBSQLLogger_1 = require("./contracts/IDBSQLLogger");
|
|
25
26
|
Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function () { return IDBSQLLogger_1.LogLevel; } });
|
|
27
|
+
// Re-export telemetry error classes so consumers can instanceof-check rather
|
|
28
|
+
// than string-matching error messages.
|
|
29
|
+
var CircuitBreaker_1 = require("./telemetry/CircuitBreaker");
|
|
30
|
+
Object.defineProperty(exports, "CircuitBreakerOpenError", { enumerable: true, get: function () { return CircuitBreaker_1.CircuitBreakerOpenError; } });
|
|
31
|
+
Object.defineProperty(exports, "CIRCUIT_BREAKER_OPEN_CODE", { enumerable: true, get: function () { return CircuitBreaker_1.CIRCUIT_BREAKER_OPEN_CODE; } });
|
|
32
|
+
var DatabricksTelemetryExporter_1 = require("./telemetry/DatabricksTelemetryExporter");
|
|
33
|
+
Object.defineProperty(exports, "TelemetryTerminalError", { enumerable: true, get: function () { return DatabricksTelemetryExporter_1.TelemetryTerminalError; } });
|
|
26
34
|
exports.auth = {
|
|
27
35
|
PlainHttpAuthentication: PlainHttpAuthentication_1.default,
|
|
36
|
+
// Token provider classes for custom authentication
|
|
37
|
+
Token: tokenProvider_1.Token,
|
|
38
|
+
StaticTokenProvider: tokenProvider_1.StaticTokenProvider,
|
|
39
|
+
ExternalTokenProvider: tokenProvider_1.ExternalTokenProvider,
|
|
40
|
+
CachedTokenProvider: tokenProvider_1.CachedTokenProvider,
|
|
41
|
+
FederationProvider: tokenProvider_1.FederationProvider,
|
|
28
42
|
};
|
|
29
43
|
const { TException, TApplicationException, TApplicationExceptionType, TProtocolException, TProtocolExceptionType } = thrift_1.Thrift;
|
|
30
44
|
exports.TException = TException;
|
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;AAoD/B,sBApDF,qBAAW,CAoDE;AAnDpB,kEAA0C;AAmDpB,uBAnDf,sBAAY,CAmDe;AAlDlC,qDAAsE;AAkDlC,+FAlD3B,+BAAc,OAkD2B;AAAE,mGAlD3B,mCAAkB,OAkD2B;AAjDtE,gEAAwC;AAiDgC,sBAjDjE,qBAAW,CAiDiE;AAhDnF,wGAAgF;AAChF,mEAMyC;AACzC,6FAAqE;AACrE,mCAAyC;AACzC,2DAAoD;AAsCiC,yFAtC5E,uBAAQ,OAsC4E;AAjC7F,6EAA6E;AAC7E,uCAAuC;AACvC,6DAAgG;AAAvF,yHAAA,uBAAuB,OAAA;AAAE,2HAAA,yBAAyB,OAAA;AAC3D,uFAAiF;AAAxE,qIAAA,sBAAsB,OAAA;AAElB,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"}
|
|
@@ -14,7 +14,7 @@ class ArrowResultHandler {
|
|
|
14
14
|
// so it's possible to infer Arrow schema from Hive schema ignoring `useArrowNativeTypes` option
|
|
15
15
|
this.arrowSchema = arrowSchema !== null && arrowSchema !== void 0 ? arrowSchema : (0, utils_1.hiveSchemaToArrowSchema)(schema);
|
|
16
16
|
this.isLZ4Compressed = lz4Compressed !== null && lz4Compressed !== void 0 ? lz4Compressed : false;
|
|
17
|
-
if (this.isLZ4Compressed && !utils_2.LZ4) {
|
|
17
|
+
if (this.isLZ4Compressed && !(0, utils_2.LZ4)()) {
|
|
18
18
|
throw new HiveDriverError_1.default('Cannot handle LZ4 compressed result: module `lz4` not installed');
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -37,7 +37,7 @@ class ArrowResultHandler {
|
|
|
37
37
|
let totalRowCount = 0;
|
|
38
38
|
(_a = rowSet === null || rowSet === void 0 ? void 0 : rowSet.arrowBatches) === null || _a === void 0 ? void 0 : _a.forEach(({ batch, rowCount }) => {
|
|
39
39
|
if (batch) {
|
|
40
|
-
batches.push(this.isLZ4Compressed ? utils_2.LZ4.decode(batch) : batch);
|
|
40
|
+
batches.push(this.isLZ4Compressed ? (0, utils_2.LZ4)().decode(batch) : batch);
|
|
41
41
|
totalRowCount += rowCount.toNumber(true);
|
|
42
42
|
}
|
|
43
43
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArrowResultHandler.js","sourceRoot":"","sources":["../../lib/result/ArrowResultHandler.ts"],"names":[],"mappings":";;;;;AACA,gFAAwD;AAGxD,mCAA8D;AAC9D,oCAA+B;AAE/B,MAAqB,kBAAkB;IASrC,YACE,OAAuB,EACvB,MAA6C,EAC7C,EAAE,MAAM,EAAE,WAAW,EAAE,aAAa,EAA6B;QAEjE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,kGAAkG;QAClG,gGAAgG;QAChG,IAAI,CAAC,WAAW,GAAG,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,IAAA,+BAAuB,EAAC,MAAM,CAAC,CAAC;QAClE,IAAI,CAAC,eAAe,GAAG,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,KAAK,CAAC;QAE9C,IAAI,IAAI,CAAC,eAAe,IAAI,CAAC,WAAG,EAAE;
|
|
1
|
+
{"version":3,"file":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AE,QAAQ,EAAE,EAAE,EAAE;YACpD,IAAI,KAAK,EAAE;gBACT,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,IAAA,WAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;gBAClE,aAAa,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;aAC1C;QACH,CAAC,CAAC,CAAC;QAEH,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;YACxB,OAAO;gBACL,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,CAAC;aACZ,CAAC;SACH;QAED,OAAO;YACL,OAAO,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,OAAO,CAAC;YACvC,QAAQ,EAAE,aAAa;SACxB,CAAC;IACJ,CAAC;CACF;AAhED,qCAgEC"}
|
|
@@ -37,7 +37,7 @@ class CloudFetchResultHandler {
|
|
|
37
37
|
this.context = context;
|
|
38
38
|
this.source = source;
|
|
39
39
|
this.isLZ4Compressed = lz4Compressed !== null && lz4Compressed !== void 0 ? lz4Compressed : false;
|
|
40
|
-
if (this.isLZ4Compressed && !utils_1.LZ4) {
|
|
40
|
+
if (this.isLZ4Compressed && !(0, utils_1.LZ4)()) {
|
|
41
41
|
throw new HiveDriverError_1.default('Cannot handle LZ4 compressed result: module `lz4` not installed');
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -68,7 +68,7 @@ class CloudFetchResultHandler {
|
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
if (this.isLZ4Compressed) {
|
|
71
|
-
batch.batches = batch.batches.map((buffer) => utils_1.LZ4.decode(buffer));
|
|
71
|
+
batch.batches = batch.batches.map((buffer) => (0, utils_1.LZ4)().decode(buffer));
|
|
72
72
|
}
|
|
73
73
|
return batch;
|
|
74
74
|
}
|
|
@@ -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;AAErD,MAAqB,uBAAuB;IAW1C,YACE,OAAuB,EACvB,MAA6C,EAC7C,EAAE,aAAa,EAA6B;QAPtC,iBAAY,GAAiC,EAAE,CAAC;QAEhD,kBAAa,GAA+B,EAAE,CAAC;QAOrD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,eAAe,GAAG,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,KAAK,CAAC;QAE9C,IAAI,IAAI,CAAC,eAAe,IAAI,CAAC,WAAG,EAAE;
|
|
1
|
+
{"version":3,"file":"CloudFetchResultHandler.js","sourceRoot":"","sources":["../../lib/result/CloudFetchResultHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAAsE;AAEtE,gFAAwD;AAIxD,oCAA+B;AAC/B,4DAAqD;AAErD,MAAqB,uBAAuB;IAW1C,YACE,OAAuB,EACvB,MAA6C,EAC7C,EAAE,aAAa,EAA6B;QAPtC,iBAAY,GAAiC,EAAE,CAAC;QAEhD,kBAAa,GAA+B,EAAE,CAAC;QAOrD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,eAAe,GAAG,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,KAAK,CAAC;QAE9C,IAAI,IAAI,CAAC,eAAe,IAAI,CAAC,IAAA,WAAG,GAAE,EAAE;YAClC,MAAM,IAAI,yBAAe,CAAC,iEAAiE,CAAC,CAAC;SAC9F;IACH,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,IAAI,IAAI,CAAC,YAAY,CAAC,MA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Q,CAAC;IACzB,CAAC;CACF;AArHD,0CAqHC"}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2025 Databricks Contributors
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.CircuitBreakerRegistry = exports.CircuitBreaker = exports.CircuitBreakerOpenError = exports.CIRCUIT_BREAKER_OPEN_CODE = exports.DEFAULT_CIRCUIT_BREAKER_CONFIG = exports.CircuitBreakerState = void 0;
|
|
19
|
+
const IDBSQLLogger_1 = require("../contracts/IDBSQLLogger");
|
|
20
|
+
var CircuitBreakerState;
|
|
21
|
+
(function (CircuitBreakerState) {
|
|
22
|
+
CircuitBreakerState["CLOSED"] = "CLOSED";
|
|
23
|
+
CircuitBreakerState["OPEN"] = "OPEN";
|
|
24
|
+
CircuitBreakerState["HALF_OPEN"] = "HALF_OPEN";
|
|
25
|
+
})(CircuitBreakerState = exports.CircuitBreakerState || (exports.CircuitBreakerState = {}));
|
|
26
|
+
exports.DEFAULT_CIRCUIT_BREAKER_CONFIG = Object.freeze({
|
|
27
|
+
failureThreshold: 5,
|
|
28
|
+
timeout: 60000,
|
|
29
|
+
successThreshold: 2,
|
|
30
|
+
});
|
|
31
|
+
exports.CIRCUIT_BREAKER_OPEN_CODE = 'CIRCUIT_BREAKER_OPEN';
|
|
32
|
+
/**
|
|
33
|
+
* Thrown when execute() is called while the breaker is OPEN or a HALF_OPEN
|
|
34
|
+
* probe is already in flight. Callers identify the condition via
|
|
35
|
+
* `instanceof CircuitBreakerOpenError` or `err.code === CIRCUIT_BREAKER_OPEN_CODE`
|
|
36
|
+
* rather than string-matching the message.
|
|
37
|
+
*/
|
|
38
|
+
class CircuitBreakerOpenError extends Error {
|
|
39
|
+
constructor(message = 'Circuit breaker OPEN') {
|
|
40
|
+
super(message);
|
|
41
|
+
this.code = exports.CIRCUIT_BREAKER_OPEN_CODE;
|
|
42
|
+
this.name = 'CircuitBreakerOpenError';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.CircuitBreakerOpenError = CircuitBreakerOpenError;
|
|
46
|
+
class CircuitBreaker {
|
|
47
|
+
constructor(context, config) {
|
|
48
|
+
this.context = context;
|
|
49
|
+
this.state = CircuitBreakerState.CLOSED;
|
|
50
|
+
this.failureCount = 0;
|
|
51
|
+
this.successCount = 0;
|
|
52
|
+
this.halfOpenInflight = 0;
|
|
53
|
+
this.config = {
|
|
54
|
+
...exports.DEFAULT_CIRCUIT_BREAKER_CONFIG,
|
|
55
|
+
...config,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
async execute(operation) {
|
|
59
|
+
const admitted = this.tryAdmit();
|
|
60
|
+
if (!admitted) {
|
|
61
|
+
throw new CircuitBreakerOpenError();
|
|
62
|
+
}
|
|
63
|
+
const { wasHalfOpenProbe } = admitted;
|
|
64
|
+
try {
|
|
65
|
+
const result = await operation();
|
|
66
|
+
this.onSuccess();
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
this.onFailure();
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
if (wasHalfOpenProbe && this.halfOpenInflight > 0) {
|
|
75
|
+
this.halfOpenInflight -= 1;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Synchronous admission check. Returning `null` means "reject". Returning
|
|
81
|
+
* an object means the caller is admitted; `wasHalfOpenProbe` indicates
|
|
82
|
+
* whether this admission consumed the single HALF_OPEN probe slot so the
|
|
83
|
+
* caller can decrement it in `finally`.
|
|
84
|
+
*
|
|
85
|
+
* Running this as a single synchronous block is what prevents the
|
|
86
|
+
* concurrent-probe race that existed in the previous implementation.
|
|
87
|
+
*/
|
|
88
|
+
tryAdmit() {
|
|
89
|
+
const logger = this.context.getLogger();
|
|
90
|
+
if (this.state === CircuitBreakerState.OPEN) {
|
|
91
|
+
if (this.nextAttempt && Date.now() < this.nextAttempt.getTime()) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
this.state = CircuitBreakerState.HALF_OPEN;
|
|
95
|
+
this.successCount = 0;
|
|
96
|
+
this.halfOpenInflight = 0;
|
|
97
|
+
logger.log(IDBSQLLogger_1.LogLevel.debug, 'Circuit breaker transitioned to HALF_OPEN');
|
|
98
|
+
}
|
|
99
|
+
if (this.state === CircuitBreakerState.HALF_OPEN) {
|
|
100
|
+
if (this.halfOpenInflight > 0) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
this.halfOpenInflight += 1;
|
|
104
|
+
return { wasHalfOpenProbe: true };
|
|
105
|
+
}
|
|
106
|
+
return { wasHalfOpenProbe: false };
|
|
107
|
+
}
|
|
108
|
+
getState() {
|
|
109
|
+
return this.state;
|
|
110
|
+
}
|
|
111
|
+
getFailureCount() {
|
|
112
|
+
return this.failureCount;
|
|
113
|
+
}
|
|
114
|
+
getSuccessCount() {
|
|
115
|
+
return this.successCount;
|
|
116
|
+
}
|
|
117
|
+
onSuccess() {
|
|
118
|
+
const logger = this.context.getLogger();
|
|
119
|
+
this.failureCount = 0;
|
|
120
|
+
if (this.state === CircuitBreakerState.HALF_OPEN) {
|
|
121
|
+
this.successCount += 1;
|
|
122
|
+
logger.log(IDBSQLLogger_1.LogLevel.debug, `Circuit breaker success in HALF_OPEN (${this.successCount}/${this.config.successThreshold})`);
|
|
123
|
+
if (this.successCount >= this.config.successThreshold) {
|
|
124
|
+
this.state = CircuitBreakerState.CLOSED;
|
|
125
|
+
this.successCount = 0;
|
|
126
|
+
this.nextAttempt = undefined;
|
|
127
|
+
logger.log(IDBSQLLogger_1.LogLevel.debug, 'Circuit breaker transitioned to CLOSED');
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
onFailure() {
|
|
132
|
+
const logger = this.context.getLogger();
|
|
133
|
+
this.failureCount += 1;
|
|
134
|
+
this.successCount = 0;
|
|
135
|
+
logger.log(IDBSQLLogger_1.LogLevel.debug, `Circuit breaker failure (${this.failureCount}/${this.config.failureThreshold})`);
|
|
136
|
+
if (this.state === CircuitBreakerState.HALF_OPEN || this.failureCount >= this.config.failureThreshold) {
|
|
137
|
+
this.state = CircuitBreakerState.OPEN;
|
|
138
|
+
this.nextAttempt = new Date(Date.now() + this.config.timeout);
|
|
139
|
+
logger.log(IDBSQLLogger_1.LogLevel.warn, `Telemetry circuit breaker OPEN after ${this.failureCount} failures (will retry after ${this.config.timeout}ms)`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
exports.CircuitBreaker = CircuitBreaker;
|
|
144
|
+
class CircuitBreakerRegistry {
|
|
145
|
+
constructor(context) {
|
|
146
|
+
this.context = context;
|
|
147
|
+
this.breakers = new Map();
|
|
148
|
+
}
|
|
149
|
+
getCircuitBreaker(host, config) {
|
|
150
|
+
let breaker = this.breakers.get(host);
|
|
151
|
+
if (!breaker) {
|
|
152
|
+
breaker = new CircuitBreaker(this.context, config);
|
|
153
|
+
this.breakers.set(host, breaker);
|
|
154
|
+
const logger = this.context.getLogger();
|
|
155
|
+
logger.log(IDBSQLLogger_1.LogLevel.debug, `Created circuit breaker for host: ${host}`);
|
|
156
|
+
}
|
|
157
|
+
else if (config) {
|
|
158
|
+
const logger = this.context.getLogger();
|
|
159
|
+
logger.log(IDBSQLLogger_1.LogLevel.debug, `Circuit breaker for host ${host} already exists; provided config will be ignored`);
|
|
160
|
+
}
|
|
161
|
+
return breaker;
|
|
162
|
+
}
|
|
163
|
+
getAllBreakers() {
|
|
164
|
+
return new Map(this.breakers);
|
|
165
|
+
}
|
|
166
|
+
removeCircuitBreaker(host) {
|
|
167
|
+
this.breakers.delete(host);
|
|
168
|
+
const logger = this.context.getLogger();
|
|
169
|
+
logger.log(IDBSQLLogger_1.LogLevel.debug, `Removed circuit breaker for host: ${host}`);
|
|
170
|
+
}
|
|
171
|
+
clear() {
|
|
172
|
+
this.breakers.clear();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
exports.CircuitBreakerRegistry = CircuitBreakerRegistry;
|
|
176
|
+
//# sourceMappingURL=CircuitBreaker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CircuitBreaker.js","sourceRoot":"","sources":["../../lib/telemetry/CircuitBreaker.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAGH,4DAAqD;AAErD,IAAY,mBAIX;AAJD,WAAY,mBAAmB;IAC7B,wCAAiB,CAAA;IACjB,oCAAa,CAAA;IACb,8CAAuB,CAAA;AACzB,CAAC,EAJW,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAI9B;AAQY,QAAA,8BAA8B,GAAmC,MAAM,CAAC,MAAM,CAAC;IAC1F,gBAAgB,EAAE,CAAC;IACnB,OAAO,EAAE,KAAK;IACd,gBAAgB,EAAE,CAAC;CACpB,CAAC,CAAC;AAEU,QAAA,yBAAyB,GAAG,sBAA+B,CAAC;AAEzE;;;;;GAKG;AACH,MAAa,uBAAwB,SAAQ,KAAK;IAGhD,YAAY,OAAO,GAAG,sBAAsB;QAC1C,KAAK,CAAC,OAAO,CAAC,CAAC;QAHR,SAAI,GAAG,iCAAyB,CAAC;QAIxC,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxC,CAAC;CACF;AAPD,0DAOC;AAED,MAAa,cAAc;IAazB,YAAoB,OAAuB,EAAE,MAAsC;QAA/D,YAAO,GAAP,OAAO,CAAgB;QAZnC,UAAK,GAAwB,mBAAmB,CAAC,MAAM,CAAC;QAExD,iBAAY,GAAG,CAAC,CAAC;QAEjB,iBAAY,GAAG,CAAC,CAAC;Q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AAG,CAAC,uBAAQ,CAAC,KAAK,EAAE,qCAAqC,IAAI,EAAE,CAAC,CAAC;SACzE;aAAM,IAAI,MAAM,EAAE;YACjB,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;YACxC,MAAM,CAAC,GAAG,CAAC,uBAAQ,CAAC,KAAK,EAAE,4BAA4B,IAAI,kDAAkD,CAAC,CAAC;SAChH;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IAED,oBAAoB,CAAC,IAAY;QAC/B,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC3B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;QACxC,MAAM,CAAC,GAAG,CAAC,uBAAQ,CAAC,KAAK,EAAE,qCAAqC,IAAI,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,KAAK;QACH,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;CACF;AAlCD,wDAkCC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
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
|
+
import IAuthentication from '../connection/contracts/IAuthentication';
|
|
18
|
+
import HiveDriverError from '../errors/HiveDriverError';
|
|
19
|
+
import { TelemetryMetric } from './types';
|
|
20
|
+
import { CircuitBreakerRegistry } from './CircuitBreaker';
|
|
21
|
+
/**
|
|
22
|
+
* Thrown for non-credential terminal telemetry failures (e.g. refusal to
|
|
23
|
+
* export to an invalid host). Separate from `AuthenticationError` so the
|
|
24
|
+
* classifier can keep the "short-circuit, don't retry, count as breaker
|
|
25
|
+
* failure" contract without muddying the auth taxonomy used by the rest of
|
|
26
|
+
* the driver.
|
|
27
|
+
*/
|
|
28
|
+
export declare class TelemetryTerminalError extends HiveDriverError {
|
|
29
|
+
readonly terminal: true;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Exports telemetry metrics to the Databricks telemetry service.
|
|
33
|
+
*
|
|
34
|
+
* CRITICAL: export() never throws — all errors are swallowed and logged at
|
|
35
|
+
* LogLevel.debug (the one exception is a single warn on the first observed
|
|
36
|
+
* auth-missing, re-armed on recovery).
|
|
37
|
+
*/
|
|
38
|
+
export default class DatabricksTelemetryExporter {
|
|
39
|
+
private context;
|
|
40
|
+
private host;
|
|
41
|
+
private circuitBreakerRegistry;
|
|
42
|
+
private authProvider?;
|
|
43
|
+
private readonly circuitBreaker;
|
|
44
|
+
private readonly authenticatedUserAgent;
|
|
45
|
+
/** User-Agent used for the unauthenticated endpoint; strips any
|
|
46
|
+
* caller-supplied `userAgentEntry` that could identify the customer. */
|
|
47
|
+
private readonly unauthenticatedUserAgent;
|
|
48
|
+
private authMissingWarned;
|
|
49
|
+
constructor(context: IClientContext, host: string, circuitBreakerRegistry: CircuitBreakerRegistry, authProvider?: IAuthentication | undefined);
|
|
50
|
+
/**
|
|
51
|
+
* Release the per-host circuit breaker. Intended for the owning client's
|
|
52
|
+
* close() path.
|
|
53
|
+
*
|
|
54
|
+
* NOTE: `CircuitBreakerRegistry` currently shares one breaker per host
|
|
55
|
+
* across consumers; calling this while another consumer is active will
|
|
56
|
+
* reset their failure-count memory. The owning-client is expected to be
|
|
57
|
+
* the last consumer on its host; multi-consumer refcounting on the
|
|
58
|
+
* registry will land in the consumer-wiring PR.
|
|
59
|
+
*/
|
|
60
|
+
dispose(): void;
|
|
61
|
+
export(metrics: TelemetryMetric[]): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Retry wrapper shaped after HttpRetryPolicy: retries only on errors
|
|
64
|
+
* classified as retryable by ExceptionClassifier, stops on terminal ones,
|
|
65
|
+
* surfaces the last error to the circuit breaker.
|
|
66
|
+
*
|
|
67
|
+
* `maxRetries` is the number of retries *after* the first attempt (i.e.
|
|
68
|
+
* attempts = maxRetries + 1), matching HttpRetryPolicy's semantics.
|
|
69
|
+
*/
|
|
70
|
+
private exportWithRetry;
|
|
71
|
+
private exportInternal;
|
|
72
|
+
private getAuthHeaders;
|
|
73
|
+
private sendRequest;
|
|
74
|
+
private toTelemetryLog;
|
|
75
|
+
private sleep;
|
|
76
|
+
}
|