azure-kusto-ingest 5.2.3 → 6.0.1
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-esm/src/abstractKustoClient.js +33 -0
- package/dist-esm/src/abstractKustoClient.js.map +1 -1
- package/dist-esm/src/descriptors.js +5 -1
- package/dist-esm/src/descriptors.js.map +1 -1
- package/dist-esm/src/fileDescriptor.browser.js +5 -2
- package/dist-esm/src/fileDescriptor.browser.js.map +1 -1
- package/dist-esm/src/fileDescriptor.js +5 -2
- package/dist-esm/src/fileDescriptor.js.map +1 -1
- package/dist-esm/src/index.js +4 -1
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/ingestClient.browser.js +8 -11
- package/dist-esm/src/ingestClient.browser.js.map +1 -1
- package/dist-esm/src/ingestClient.js +8 -13
- package/dist-esm/src/ingestClient.js.map +1 -1
- package/dist-esm/src/ingestClientBase.js +93 -9
- package/dist-esm/src/ingestClientBase.js.map +1 -1
- package/dist-esm/src/ingestionBlobInfo.js +6 -1
- package/dist-esm/src/ingestionBlobInfo.js.map +1 -1
- package/dist-esm/src/ingestionProperties.js +15 -1
- package/dist-esm/src/ingestionProperties.js.map +1 -1
- package/dist-esm/src/ingestionResult.js +60 -0
- package/dist-esm/src/ingestionResult.js.map +1 -0
- package/dist-esm/src/managedStreamingIngestClient.js +4 -4
- package/dist-esm/src/managedStreamingIngestClient.js.map +1 -1
- package/dist-esm/src/rankedStorageAccount.js +73 -0
- package/dist-esm/src/rankedStorageAccount.js.map +1 -0
- package/dist-esm/src/rankedStorageAccountSet.js +61 -0
- package/dist-esm/src/rankedStorageAccountSet.js.map +1 -0
- package/dist-esm/src/resourceManager.js +108 -16
- package/dist-esm/src/resourceManager.js.map +1 -1
- package/dist-esm/src/streamingIngestClient.browser.js +2 -2
- package/dist-esm/src/streamingIngestClient.browser.js.map +1 -1
- package/dist-esm/src/streamingIngestClient.js +2 -2
- package/dist-esm/src/streamingIngestClient.js.map +1 -1
- package/dist-esm/src/streamingIngestClientBase.js +7 -1
- package/dist-esm/src/streamingIngestClientBase.js.map +1 -1
- package/package.json +7 -4
- package/types/src/abstractKustoClient.d.ts +3 -0
- package/types/src/descriptors.d.ts +1 -0
- package/types/src/fileDescriptor.browser.d.ts +3 -1
- package/types/src/fileDescriptor.d.ts +3 -1
- package/types/src/index.d.ts +2 -1
- package/types/src/ingestClient.browser.d.ts +4 -4
- package/types/src/ingestClient.d.ts +4 -4
- package/types/src/ingestClientBase.d.ts +10 -4
- package/types/src/ingestionBlobInfo.d.ts +5 -1
- package/types/src/ingestionProperties.d.ts +1 -0
- package/types/src/ingestionResult.d.ts +41 -0
- package/types/src/managedStreamingIngestClient.d.ts +5 -5
- package/types/src/rankedStorageAccount.d.ts +15 -0
- package/types/src/rankedStorageAccountSet.d.ts +18 -0
- package/types/src/resourceManager.d.ts +21 -4
- package/types/src/streamingIngestClient.browser.d.ts +1 -1
- package/types/src/streamingIngestClient.d.ts +1 -1
- package/types/src/streamingIngestClientBase.d.ts +1 -1
|
@@ -2,26 +2,38 @@
|
|
|
2
2
|
// Copyright (c) Microsoft Corporation.
|
|
3
3
|
// Licensed under the MIT License.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.ResourceManager = exports.IngestClientResources = exports.ResourceURI = void 0;
|
|
5
|
+
exports.createStatusTableClient = exports.ResourceManager = exports.IngestClientResources = exports.ResourceURI = exports.ResourceType = void 0;
|
|
6
6
|
const azure_kusto_data_1 = require("azure-kusto-data");
|
|
7
7
|
const retry_1 = require("./retry");
|
|
8
8
|
const storage_blob_1 = require("@azure/storage-blob");
|
|
9
|
+
const data_tables_1 = require("@azure/data-tables");
|
|
10
|
+
const rankedStorageAccountSet_1 = require("./rankedStorageAccountSet");
|
|
11
|
+
const storage_queue_1 = require("@azure/storage-queue");
|
|
9
12
|
const ATTEMPT_COUNT = 4;
|
|
13
|
+
var ResourceType;
|
|
14
|
+
(function (ResourceType) {
|
|
15
|
+
ResourceType[ResourceType["Queue"] = 0] = "Queue";
|
|
16
|
+
ResourceType[ResourceType["Container"] = 1] = "Container";
|
|
17
|
+
ResourceType[ResourceType["Table"] = 2] = "Table";
|
|
18
|
+
})(ResourceType || (exports.ResourceType = ResourceType = {}));
|
|
10
19
|
class ResourceURI {
|
|
11
|
-
constructor(uri) {
|
|
20
|
+
constructor(uri, accountName, resourceType) {
|
|
12
21
|
this.uri = uri;
|
|
22
|
+
this.accountName = accountName;
|
|
23
|
+
this.resourceType = resourceType;
|
|
13
24
|
}
|
|
14
25
|
}
|
|
15
26
|
exports.ResourceURI = ResourceURI;
|
|
16
27
|
class IngestClientResources {
|
|
17
|
-
constructor(securedReadyForAggregationQueues = null, failedIngestionsQueues = null, successfulIngestionsQueues = null, containers = null) {
|
|
28
|
+
constructor(securedReadyForAggregationQueues = null, failedIngestionsQueues = null, successfulIngestionsQueues = null, containers = null, statusTables = null) {
|
|
18
29
|
this.securedReadyForAggregationQueues = securedReadyForAggregationQueues;
|
|
19
30
|
this.failedIngestionsQueues = failedIngestionsQueues;
|
|
20
31
|
this.successfulIngestionsQueues = successfulIngestionsQueues;
|
|
21
32
|
this.containers = containers;
|
|
33
|
+
this.statusTables = statusTables;
|
|
22
34
|
}
|
|
23
35
|
valid() {
|
|
24
|
-
const resources = [this.securedReadyForAggregationQueues, this.failedIngestionsQueues, this.failedIngestionsQueues, this.containers];
|
|
36
|
+
const resources = [this.securedReadyForAggregationQueues, this.failedIngestionsQueues, this.failedIngestionsQueues, this.containers, this.statusTables];
|
|
25
37
|
return resources.reduce((prev, current) => !!(prev && current), true);
|
|
26
38
|
}
|
|
27
39
|
}
|
|
@@ -38,6 +50,7 @@ class ResourceManager {
|
|
|
38
50
|
this.ingestClientResourcesLastUpdate = null;
|
|
39
51
|
this.authorizationContext = null;
|
|
40
52
|
this.authorizationContextLastUpdate = null;
|
|
53
|
+
this.rankedStorageAccountSet = new rankedStorageAccountSet_1.RankedStorageAccountSet();
|
|
41
54
|
}
|
|
42
55
|
async refreshIngestClientResources() {
|
|
43
56
|
const error = await this.tryRefresh(false);
|
|
@@ -53,7 +66,7 @@ class ResourceManager {
|
|
|
53
66
|
const cmd = `.get ingestion resources ${this.isBrowser ? `with (EnableBlobCors='true', EnableQueueCors='true', EnableTableCors='true')` : ""}`;
|
|
54
67
|
const response = await this.kustoClient.execute("NetDefaultDB", cmd);
|
|
55
68
|
const table = response.primaryResults[0];
|
|
56
|
-
const resoures = new IngestClientResources(this.getResourceByName(table, "SecuredReadyForAggregationQueue"), this.getResourceByName(table, "FailedIngestionsQueue"), this.getResourceByName(table, "SuccessfulIngestionsQueue"), this.getResourceByName(table, "TempStorage"));
|
|
69
|
+
const resoures = new IngestClientResources(this.getResourceByName(table, "SecuredReadyForAggregationQueue", ResourceType.Queue), this.getResourceByName(table, "FailedIngestionsQueue", ResourceType.Queue), this.getResourceByName(table, "SuccessfulIngestionsQueue", ResourceType.Queue), this.getResourceByName(table, "TempStorage", ResourceType.Container), this.getResourceByName(table, "IngestionsStatusTable", ResourceType.Table));
|
|
57
70
|
if (!resoures.valid()) {
|
|
58
71
|
throw new Error("Unexpected error occured - fetched data returned missing resource");
|
|
59
72
|
}
|
|
@@ -68,16 +81,80 @@ class ResourceManager {
|
|
|
68
81
|
}
|
|
69
82
|
throw new Error(`Failed to get ingestion resources from server - the request was throttled ${ATTEMPT_COUNT} times.`);
|
|
70
83
|
}
|
|
71
|
-
getResourceByName(table, resourceName) {
|
|
84
|
+
getResourceByName(table, resourceName, resourceType) {
|
|
72
85
|
const result = [];
|
|
73
86
|
for (const row of table.rows()) {
|
|
74
87
|
const typedRow = row;
|
|
75
88
|
if (typedRow.ResourceTypeName === resourceName) {
|
|
76
|
-
|
|
89
|
+
let accountName = "";
|
|
90
|
+
if (resourceType === ResourceType.Queue) {
|
|
91
|
+
accountName = new storage_queue_1.QueueClient(typedRow.StorageRoot).accountName;
|
|
92
|
+
}
|
|
93
|
+
else if (resourceType === ResourceType.Container) {
|
|
94
|
+
accountName = new storage_blob_1.ContainerClient(typedRow.StorageRoot).accountName;
|
|
95
|
+
}
|
|
96
|
+
result.push(new ResourceURI(typedRow.StorageRoot, accountName, resourceType));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
pupulateStorageAccounts() {
|
|
102
|
+
if (this.ingestClientResources == null) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
// containers
|
|
106
|
+
const accounts = new Set();
|
|
107
|
+
if (this.ingestClientResources.containers != null) {
|
|
108
|
+
for (const container of this.ingestClientResources.containers) {
|
|
109
|
+
accounts.add(container.accountName);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// queues
|
|
113
|
+
if (this.ingestClientResources.securedReadyForAggregationQueues != null) {
|
|
114
|
+
for (const queue of this.ingestClientResources.securedReadyForAggregationQueues) {
|
|
115
|
+
accounts.add(queue.accountName);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
for (const account of accounts) {
|
|
119
|
+
this.rankedStorageAccountSet.registerStorageAccount(account);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
groupResourcesByStorageAccount(resources) {
|
|
123
|
+
var _a;
|
|
124
|
+
const result = new Map();
|
|
125
|
+
for (const resource of resources) {
|
|
126
|
+
if (!result.has(resource.accountName)) {
|
|
127
|
+
result.set(resource.accountName, []);
|
|
128
|
+
}
|
|
129
|
+
(_a = result.get(resource.accountName)) === null || _a === void 0 ? void 0 : _a.push(resource);
|
|
130
|
+
}
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
133
|
+
getRankedAndShuffledStorageAccounts(resources) {
|
|
134
|
+
const resourcesByAccount = this.groupResourcesByStorageAccount(resources);
|
|
135
|
+
const rankedStorageAccounts = this.rankedStorageAccountSet.getRankedShuffledAccounts();
|
|
136
|
+
const result = new Array();
|
|
137
|
+
for (const account of rankedStorageAccounts) {
|
|
138
|
+
const accountName = account.getAccountName();
|
|
139
|
+
if (resourcesByAccount.has(accountName)) {
|
|
140
|
+
result.push(resourcesByAccount.get(accountName));
|
|
77
141
|
}
|
|
78
142
|
}
|
|
79
143
|
return result;
|
|
80
144
|
}
|
|
145
|
+
getRoundRobinRankedAndShuffledResources(resources) {
|
|
146
|
+
const rankedAccounts = this.getRankedAndShuffledStorageAccounts(resources);
|
|
147
|
+
const result = new Array();
|
|
148
|
+
let index = 0;
|
|
149
|
+
while (result.length < resources.length) {
|
|
150
|
+
const account = rankedAccounts[index % rankedAccounts.length];
|
|
151
|
+
if (account.length > 0) {
|
|
152
|
+
result.push(account.shift());
|
|
153
|
+
}
|
|
154
|
+
index++;
|
|
155
|
+
}
|
|
156
|
+
return result;
|
|
157
|
+
}
|
|
81
158
|
async refreshAuthorizationContext() {
|
|
82
159
|
const error = await this.tryRefresh(true);
|
|
83
160
|
if (this.authorizationContext == null) {
|
|
@@ -100,6 +177,7 @@ class ResourceManager {
|
|
|
100
177
|
else {
|
|
101
178
|
this.ingestClientResources = await this.getIngestClientResourcesFromService();
|
|
102
179
|
this.ingestClientResourcesLastUpdate = now;
|
|
180
|
+
this.pupulateStorageAccounts();
|
|
103
181
|
}
|
|
104
182
|
}
|
|
105
183
|
catch (e) {
|
|
@@ -129,7 +207,8 @@ class ResourceManager {
|
|
|
129
207
|
throw new Error(`Failed to get identity token from server - the request was throttled ${ATTEMPT_COUNT} times.`);
|
|
130
208
|
}
|
|
131
209
|
async getIngestionQueues() {
|
|
132
|
-
|
|
210
|
+
const queues = (await this.refreshIngestClientResources()).securedReadyForAggregationQueues;
|
|
211
|
+
return queues ? this.getRoundRobinRankedAndShuffledResources(queues) : null;
|
|
133
212
|
}
|
|
134
213
|
async getFailedIngestionsQueues() {
|
|
135
214
|
return (await this.refreshIngestClientResources()).failedIngestionsQueues;
|
|
@@ -138,24 +217,37 @@ class ResourceManager {
|
|
|
138
217
|
return (await this.refreshIngestClientResources()).successfulIngestionsQueues;
|
|
139
218
|
}
|
|
140
219
|
async getContainers() {
|
|
141
|
-
|
|
220
|
+
const containers = (await this.refreshIngestClientResources()).containers;
|
|
221
|
+
return containers ? this.getRoundRobinRankedAndShuffledResources(containers) : null;
|
|
142
222
|
}
|
|
143
223
|
async getAuthorizationContext() {
|
|
144
224
|
return this.refreshAuthorizationContext();
|
|
145
225
|
}
|
|
146
|
-
async
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
226
|
+
async getStatusTables() {
|
|
227
|
+
return (await this.refreshIngestClientResources()).statusTables;
|
|
228
|
+
}
|
|
229
|
+
async createStatusTable() {
|
|
230
|
+
const statusTables = await this.getStatusTables();
|
|
231
|
+
if (!statusTables) {
|
|
232
|
+
throw new Error("Failed to get status table");
|
|
150
233
|
}
|
|
151
|
-
|
|
152
|
-
const containerClient = new storage_blob_1.ContainerClient(container.uri);
|
|
153
|
-
return containerClient.getBlockBlobClient(blobName);
|
|
234
|
+
return (0, exports.createStatusTableClient)(statusTables[0].uri);
|
|
154
235
|
}
|
|
155
236
|
close() {
|
|
156
237
|
this.kustoClient.close();
|
|
157
238
|
}
|
|
239
|
+
reportResourceUsageResult(accountName, success) {
|
|
240
|
+
this.rankedStorageAccountSet.logResultToAccount(accountName, success);
|
|
241
|
+
}
|
|
158
242
|
}
|
|
159
243
|
exports.ResourceManager = ResourceManager;
|
|
244
|
+
const createStatusTableClient = (uri) => {
|
|
245
|
+
const tableUrl = new URL(uri);
|
|
246
|
+
const origin = tableUrl.origin;
|
|
247
|
+
const sasToken = tableUrl.search;
|
|
248
|
+
const tableName = tableUrl.pathname.replace("/", "");
|
|
249
|
+
return new data_tables_1.TableClient(origin + sasToken, tableName);
|
|
250
|
+
};
|
|
251
|
+
exports.createStatusTableClient = createStatusTableClient;
|
|
160
252
|
exports.default = ResourceManager;
|
|
161
253
|
//# sourceMappingURL=resourceManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resourceManager.js","sourceRoot":"","sources":["../../src/resourceManager.ts"],"names":[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U,CAAC,MAAM,CAAC,CAAC,CAAC;QAC5E,MAAM,eAAe,GAAG,IAAI,8BAAe,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QAC3D,OAAO,eAAe,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IACxD,CAAC;IAED,KAAK;QACD,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;CACJ;AA/JD,0CA+JC;AAED,kBAAe,eAAe,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { Client, KustoDataErrors, TimeUtils } from \"azure-kusto-data\";\nimport { ExponentialRetry } from \"./retry\";\nimport { ContainerClient } from \"@azure/storage-blob\";\n\nconst ATTEMPT_COUNT = 4;\nexport class ResourceURI {\n constructor(readonly uri: string) {}\n}\n\nexport class IngestClientResources {\n constructor(\n readonly securedReadyForAggregationQueues: ResourceURI[] | null = null,\n readonly failedIngestionsQueues: ResourceURI[] | null = null,\n readonly successfulIngestionsQueues: ResourceURI[] | null = null,\n readonly containers: ResourceURI[] | null = null\n ) {}\n\n valid() {\n const resources = [this.securedReadyForAggregationQueues, this.failedIngestionsQueues, this.failedIngestionsQueues, this.containers];\n return resources.reduce((prev, current) => !!(prev && current), true);\n }\n}\n\nexport class ResourceManager {\n public readonly refreshPeriod: number;\n public refreshPeriodOnError: number;\n public ingestClientResources: IngestClientResources | null;\n public ingestClientResourcesLastUpdate: number | null;\n public authorizationContext: string | null;\n public authorizationContextLastUpdate: number | null;\n\n private baseSleepTimeSecs = 1;\n private baseJitterSecs = 1;\n\n constructor(readonly kustoClient: Client, readonly isBrowser: boolean = false) {\n this.refreshPeriod = TimeUtils.toMilliseconds(1, 0, 0);\n this.refreshPeriodOnError = TimeUtils.toMilliseconds(0, 10, 0);\n\n this.ingestClientResources = null;\n this.ingestClientResourcesLastUpdate = null;\n\n this.authorizationContext = null;\n this.authorizationContextLastUpdate = null;\n }\n\n async refreshIngestClientResources(): Promise<IngestClientResources> {\n const error = await this.tryRefresh(false);\n if (!this.ingestClientResources) {\n throw new Error(`Failed to fetch ingestion resources from service. ${error?.message}.\\n ${error?.stack}`);\n }\n\n return this.ingestClientResources;\n }\n\n async getIngestClientResourcesFromService(): Promise<IngestClientResources> {\n const retry = new ExponentialRetry(ATTEMPT_COUNT, this.baseSleepTimeSecs, this.baseJitterSecs);\n while (retry.shouldTry()) {\n try {\n const cmd = `.get ingestion resources ${this.isBrowser ? `with (EnableBlobCors='true', EnableQueueCors='true', EnableTableCors='true')` : \"\"}`;\n const response = await this.kustoClient.execute(\"NetDefaultDB\", cmd);\n const table = response.primaryResults[0];\n const resoures = new IngestClientResources(\n this.getResourceByName(table, \"SecuredReadyForAggregationQueue\"),\n this.getResourceByName(table, \"FailedIngestionsQueue\"),\n this.getResourceByName(table, \"SuccessfulIngestionsQueue\"),\n this.getResourceByName(table, \"TempStorage\")\n );\n\n if (!resoures.valid()) {\n throw new Error(\"Unexpected error occured - fetched data returned missing resource\");\n }\n\n return resoures;\n } catch (error: unknown) {\n if (!(error instanceof KustoDataErrors.ThrottlingError)) {\n throw error;\n }\n await retry.backoff();\n }\n }\n throw new Error(`Failed to get ingestion resources from server - the request was throttled ${ATTEMPT_COUNT} times.`);\n }\n\n getResourceByName(table: { rows: () => any }, resourceName: string): ResourceURI[] {\n const result: ResourceURI[] = [];\n for (const row of table.rows()) {\n const typedRow = row as {\n ResourceTypeName: string;\n StorageRoot: string;\n };\n if (typedRow.ResourceTypeName === resourceName) {\n result.push(new ResourceURI(typedRow.StorageRoot));\n }\n }\n return result;\n }\n\n async refreshAuthorizationContext(): Promise<string> {\n const error = await this.tryRefresh(true);\n\n if (this.authorizationContext == null) {\n throw new Error(`Failed to fetch Authorization context from service. ${error?.message}.\\n ${error?.stack}`);\n }\n\n return this.authorizationContext;\n }\n\n async tryRefresh(isAuthContextFetch: boolean): Promise<Error | null> {\n const resource = isAuthContextFetch ? this.authorizationContext?.trim() : this.ingestClientResources;\n const lastRefresh = isAuthContextFetch ? this.authorizationContextLastUpdate : this.ingestClientResourcesLastUpdate;\n const now = Date.now();\n let error: Error | null = null;\n if (!resource || !lastRefresh || lastRefresh + this.refreshPeriod <= now) {\n try {\n if (isAuthContextFetch) {\n this.authorizationContext = await this.getAuthorizationContextFromService();\n this.authorizationContextLastUpdate = now;\n } else {\n this.ingestClientResources = await this.getIngestClientResourcesFromService();\n this.ingestClientResourcesLastUpdate = now;\n }\n } catch (e) {\n error = e as Error;\n }\n }\n\n return error;\n }\n\n async getAuthorizationContextFromService() {\n const retry = new ExponentialRetry(ATTEMPT_COUNT, this.baseSleepTimeSecs, this.baseJitterSecs);\n while (retry.shouldTry()) {\n try {\n const response = await this.kustoClient.execute(\"NetDefaultDB\", \".get kusto identity token\");\n const next = response.primaryResults[0].rows().next();\n if (next.done) {\n throw new Error(\"Failed to get authorization context - got empty results\");\n }\n return next.value.toJSON<{ AuthorizationContext: string }>().AuthorizationContext;\n } catch (error: unknown) {\n if (!(error instanceof KustoDataErrors.ThrottlingError)) {\n throw error;\n }\n await retry.backoff();\n }\n }\n throw new Error(`Failed to get identity token from server - the request was throttled ${ATTEMPT_COUNT} times.`);\n }\n\n async getIngestionQueues() {\n return (await this.refreshIngestClientResources()).securedReadyForAggregationQueues;\n }\n\n async getFailedIngestionsQueues() {\n return (await this.refreshIngestClientResources()).failedIngestionsQueues;\n }\n\n async getSuccessfulIngestionsQueues() {\n return (await this.refreshIngestClientResources()).successfulIngestionsQueues;\n }\n\n async getContainers() {\n return (await this.refreshIngestClientResources()).containers;\n }\n\n async getAuthorizationContext(): Promise<string> {\n return this.refreshAuthorizationContext();\n }\n\n async getBlockBlobClient(blobName: string) {\n const containers = await this.getContainers();\n if (containers == null) {\n throw new Error(\"Failed to get containers\");\n }\n const container = containers[Math.floor(Math.random() * containers.length)];\n const containerClient = new ContainerClient(container.uri);\n return containerClient.getBlockBlobClient(blobName);\n }\n\n close() {\n this.kustoClient.close();\n }\n}\n\nexport default ResourceManager;\n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,CAAC;CACJ;AAjPD,0CAiPC;AAEM,MAAM,uBAAuB,GAAG,CAAC,GAAW,EAAe,EAAE;IAChE,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IAC9B,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;IAC/B,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC;IACjC,MAAM,SAAS,GAAG,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACrD,OAAO,IAAI,yBAAW,CAAC,MAAM,GAAG,QAAQ,EAAE,SAAS,CAAC,CAAC;AACzD,CAAC,CAAC;AANW,QAAA,uBAAuB,2BAMlC;AAEF,kBAAe,eAAe,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { Client, KustoDataErrors, TimeUtils } from \"azure-kusto-data\";\nimport { ExponentialRetry } from \"./retry\";\nimport { ContainerClient } from \"@azure/storage-blob\";\nimport { TableClient } from \"@azure/data-tables\";\nimport { RankedStorageAccountSet } from \"./rankedStorageAccountSet\";\nimport { QueueClient } from \"@azure/storage-queue\";\n\nconst ATTEMPT_COUNT = 4;\n\nexport enum ResourceType {\n Queue,\n Container,\n Table,\n}\n\nexport class ResourceURI {\n constructor(readonly uri: string, readonly accountName: string, readonly resourceType: ResourceType) {}\n}\n\nexport class IngestClientResources {\n constructor(\n readonly securedReadyForAggregationQueues: ResourceURI[] | null = null,\n readonly failedIngestionsQueues: ResourceURI[] | null = null,\n readonly successfulIngestionsQueues: ResourceURI[] | null = null,\n readonly containers: ResourceURI[] | null = null,\n readonly statusTables: ResourceURI[] | null = null\n ) {}\n\n valid() {\n const resources = [this.securedReadyForAggregationQueues, this.failedIngestionsQueues, this.failedIngestionsQueues, this.containers, this.statusTables];\n return resources.reduce((prev, current) => !!(prev && current), true);\n }\n}\n\nexport class ResourceManager {\n public readonly refreshPeriod: number;\n public refreshPeriodOnError: number;\n public ingestClientResources: IngestClientResources | null;\n public ingestClientResourcesLastUpdate: number | null;\n public authorizationContext: string | null;\n public authorizationContextLastUpdate: number | null;\n\n private baseSleepTimeSecs = 1;\n private baseJitterSecs = 1;\n private rankedStorageAccountSet: RankedStorageAccountSet;\n\n constructor(readonly kustoClient: Client, readonly isBrowser: boolean = false) {\n this.refreshPeriod = TimeUtils.toMilliseconds(1, 0, 0);\n this.refreshPeriodOnError = TimeUtils.toMilliseconds(0, 10, 0);\n\n this.ingestClientResources = null;\n this.ingestClientResourcesLastUpdate = null;\n\n this.authorizationContext = null;\n this.authorizationContextLastUpdate = null;\n\n this.rankedStorageAccountSet = new RankedStorageAccountSet();\n }\n\n async refreshIngestClientResources(): Promise<IngestClientResources> {\n const error = await this.tryRefresh(false);\n if (!this.ingestClientResources) {\n throw new Error(`Failed to fetch ingestion resources from service. ${error?.message}.\\n ${error?.stack}`);\n }\n\n return this.ingestClientResources;\n }\n\n async getIngestClientResourcesFromService(): Promise<IngestClientResources> {\n const retry = new ExponentialRetry(ATTEMPT_COUNT, this.baseSleepTimeSecs, this.baseJitterSecs);\n while (retry.shouldTry()) {\n try {\n const cmd = `.get ingestion resources ${this.isBrowser ? `with (EnableBlobCors='true', EnableQueueCors='true', EnableTableCors='true')` : \"\"}`;\n const response = await this.kustoClient.execute(\"NetDefaultDB\", cmd);\n const table = response.primaryResults[0];\n const resoures = new IngestClientResources(\n this.getResourceByName(table, \"SecuredReadyForAggregationQueue\", ResourceType.Queue),\n this.getResourceByName(table, \"FailedIngestionsQueue\", ResourceType.Queue),\n this.getResourceByName(table, \"SuccessfulIngestionsQueue\", ResourceType.Queue),\n this.getResourceByName(table, \"TempStorage\", ResourceType.Container),\n this.getResourceByName(table, \"IngestionsStatusTable\", ResourceType.Table)\n );\n\n if (!resoures.valid()) {\n throw new Error(\"Unexpected error occured - fetched data returned missing resource\");\n }\n\n return resoures;\n } catch (error: unknown) {\n if (!(error instanceof KustoDataErrors.ThrottlingError)) {\n throw error;\n }\n await retry.backoff();\n }\n }\n throw new Error(`Failed to get ingestion resources from server - the request was throttled ${ATTEMPT_COUNT} times.`);\n }\n\n getResourceByName(table: { rows: () => any }, resourceName: string, resourceType: ResourceType): ResourceURI[] {\n const result: ResourceURI[] = [];\n for (const row of table.rows()) {\n const typedRow = row as {\n ResourceTypeName: string;\n StorageRoot: string;\n };\n if (typedRow.ResourceTypeName === resourceName) {\n let accountName = \"\";\n if (resourceType === ResourceType.Queue) {\n accountName = new QueueClient(typedRow.StorageRoot).accountName;\n } else if (resourceType === ResourceType.Container) {\n accountName = new ContainerClient(typedRow.StorageRoot).accountName;\n }\n result.push(new ResourceURI(typedRow.StorageRoot, accountName, resourceType));\n }\n }\n return result;\n }\n\n pupulateStorageAccounts(): void {\n if (this.ingestClientResources == null) {\n return;\n }\n\n // containers\n const accounts = new Set<string>();\n if (this.ingestClientResources.containers != null) {\n for (const container of this.ingestClientResources.containers) {\n accounts.add(container.accountName);\n }\n }\n // queues\n if (this.ingestClientResources.securedReadyForAggregationQueues != null) {\n for (const queue of this.ingestClientResources.securedReadyForAggregationQueues) {\n accounts.add(queue.accountName);\n }\n }\n\n for (const account of accounts) {\n this.rankedStorageAccountSet.registerStorageAccount(account);\n }\n }\n\n groupResourcesByStorageAccount(resources: ResourceURI[]): Map<string, ResourceURI[]> {\n const result = new Map<string, ResourceURI[]>();\n for (const resource of resources) {\n if (!result.has(resource.accountName)) {\n result.set(resource.accountName, []);\n }\n result.get(resource.accountName)?.push(resource);\n }\n return result;\n }\n\n getRankedAndShuffledStorageAccounts(resources: ResourceURI[]): ResourceURI[][] {\n const resourcesByAccount = this.groupResourcesByStorageAccount(resources);\n const rankedStorageAccounts = this.rankedStorageAccountSet.getRankedShuffledAccounts();\n const result = new Array<ResourceURI[]>();\n for (const account of rankedStorageAccounts) {\n const accountName = account.getAccountName();\n if (resourcesByAccount.has(accountName)) {\n result.push(resourcesByAccount.get(accountName) as ResourceURI[]);\n }\n }\n return result;\n }\n\n getRoundRobinRankedAndShuffledResources(resources: ResourceURI[]): ResourceURI[] {\n const rankedAccounts = this.getRankedAndShuffledStorageAccounts(resources);\n const result = new Array<ResourceURI>();\n let index = 0;\n while (result.length < resources.length) {\n const account = rankedAccounts[index % rankedAccounts.length];\n if (account.length > 0) {\n result.push(account.shift() as ResourceURI);\n }\n index++;\n }\n return result;\n }\n\n async refreshAuthorizationContext(): Promise<string> {\n const error = await this.tryRefresh(true);\n\n if (this.authorizationContext == null) {\n throw new Error(`Failed to fetch Authorization context from service. ${error?.message}.\\n ${error?.stack}`);\n }\n\n return this.authorizationContext;\n }\n\n async tryRefresh(isAuthContextFetch: boolean): Promise<Error | null> {\n const resource = isAuthContextFetch ? this.authorizationContext?.trim() : this.ingestClientResources;\n const lastRefresh = isAuthContextFetch ? this.authorizationContextLastUpdate : this.ingestClientResourcesLastUpdate;\n const now = Date.now();\n let error: Error | null = null;\n if (!resource || !lastRefresh || lastRefresh + this.refreshPeriod <= now) {\n try {\n if (isAuthContextFetch) {\n this.authorizationContext = await this.getAuthorizationContextFromService();\n this.authorizationContextLastUpdate = now;\n } else {\n this.ingestClientResources = await this.getIngestClientResourcesFromService();\n this.ingestClientResourcesLastUpdate = now;\n this.pupulateStorageAccounts();\n }\n } catch (e) {\n error = e as Error;\n }\n }\n\n return error;\n }\n\n async getAuthorizationContextFromService() {\n const retry = new ExponentialRetry(ATTEMPT_COUNT, this.baseSleepTimeSecs, this.baseJitterSecs);\n while (retry.shouldTry()) {\n try {\n const response = await this.kustoClient.execute(\"NetDefaultDB\", \".get kusto identity token\");\n const next = response.primaryResults[0].rows().next();\n if (next.done) {\n throw new Error(\"Failed to get authorization context - got empty results\");\n }\n return next.value.toJSON<{ AuthorizationContext: string }>().AuthorizationContext;\n } catch (error: unknown) {\n if (!(error instanceof KustoDataErrors.ThrottlingError)) {\n throw error;\n }\n await retry.backoff();\n }\n }\n throw new Error(`Failed to get identity token from server - the request was throttled ${ATTEMPT_COUNT} times.`);\n }\n\n async getIngestionQueues(): Promise<ResourceURI[] | null> {\n const queues = (await this.refreshIngestClientResources()).securedReadyForAggregationQueues;\n return queues ? this.getRoundRobinRankedAndShuffledResources(queues) : null;\n }\n\n async getFailedIngestionsQueues(): Promise<ResourceURI[] | null> {\n return (await this.refreshIngestClientResources()).failedIngestionsQueues;\n }\n\n async getSuccessfulIngestionsQueues(): Promise<ResourceURI[] | null> {\n return (await this.refreshIngestClientResources()).successfulIngestionsQueues;\n }\n\n async getContainers(): Promise<ResourceURI[] | null> {\n const containers = (await this.refreshIngestClientResources()).containers;\n return containers ? this.getRoundRobinRankedAndShuffledResources(containers) : null;\n }\n\n async getAuthorizationContext(): Promise<string> {\n return this.refreshAuthorizationContext();\n }\n\n async getStatusTables(): Promise<ResourceURI[] | null> {\n return (await this.refreshIngestClientResources()).statusTables;\n }\n\n async createStatusTable() {\n const statusTables = await this.getStatusTables();\n if (!statusTables) {\n throw new Error(\"Failed to get status table\");\n }\n\n return createStatusTableClient(statusTables![0].uri);\n }\n\n close(): void {\n this.kustoClient.close();\n }\n\n reportResourceUsageResult(accountName: string, success: boolean): void {\n this.rankedStorageAccountSet.logResultToAccount(accountName, success);\n }\n}\n\nexport const createStatusTableClient = (uri: string): TableClient => {\n const tableUrl = new URL(uri);\n const origin = tableUrl.origin;\n const sasToken = tableUrl.search;\n const tableName = tableUrl.pathname.replace(\"/\", \"\");\n return new TableClient(origin + sasToken, tableName);\n};\n\nexport default ResourceManager;\n"]}
|
|
@@ -7,8 +7,8 @@ const fileDescriptor_browser_1 = require("./fileDescriptor.browser");
|
|
|
7
7
|
const streamUtils_browser_1 = require("./streamUtils.browser");
|
|
8
8
|
const streamingIngestClientBase_1 = require("./streamingIngestClientBase");
|
|
9
9
|
class KustoStreamingIngestClient extends streamingIngestClientBase_1.KustoStreamingIngestClientBase {
|
|
10
|
-
constructor(kcsb, defaultProps) {
|
|
11
|
-
super(kcsb, defaultProps);
|
|
10
|
+
constructor(kcsb, defaultProps, autoCorrectEndpoint) {
|
|
11
|
+
super(kcsb, defaultProps, autoCorrectEndpoint);
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* Use Readable for Node.js and ArrayBuffer in browser
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamingIngestClient.browser.js","sourceRoot":"","sources":["../../src/streamingIngestClient.browser.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAKlC,+CAAiD;AACjD,qEAA0D;AAC1D,+DAAwD;AACxD,2EAA6E;AAE7E,MAAM,0BAA2B,SAAQ,0DAA8B;IACnE,YAAY,IAA2C,EAAE,YAAuC;
|
|
1
|
+
{"version":3,"file":"streamingIngestClient.browser.js","sourceRoot":"","sources":["../../src/streamingIngestClient.browser.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAKlC,+CAAiD;AACjD,qEAA0D;AAC1D,+DAAwD;AACxD,2EAA6E;AAE7E,MAAM,0BAA2B,SAAQ,0DAA8B;IACnE,YAAY,IAA2C,EAAE,YAAuC,EAAE,mBAA6B;QAC3H,KAAK,CAAC,IAAI,EAAE,YAAY,EAAE,mBAAmB,CAAC,CAAC;IACnD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,gBAAgB,CAAC,MAAsC,EAAE,mBAA8C,EAAE,eAAwB;;QACnI,IAAI,CAAC,UAAU,EAAE,CAAC;QAElB,MAAM,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC;QACxD,MAAM,UAAU,GAAqB,MAAM,YAAY,8BAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,8BAAgB,CAAC,MAAM,CAAC,CAAC;QAChH,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,sBAAsB,CAChD,KAAK,CAAC,QAAkB,EACxB,KAAK,CAAC,KAAe,EACrB,UAAU,CAAC,MAAM,EACjB,KAAK,CAAC,MAAM,EACZ,MAAA,KAAK,CAAC,yBAAyB,mCAAI,IAAI,EACvC,eAAe,CAClB,CAAC;IACN,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,cAAc,CAAC,IAA2B,EAAE,mBAA8C;QAC5F,IAAI,CAAC,UAAU,EAAE,CAAC;QAElB,MAAM,UAAU,GAAmB,IAAI,YAAY,uCAAc,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,uCAAc,CAAC,IAAI,CAAC,CAAC;QACpG,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,IAAA,qCAAe,EAAC,UAAU,CAAC,EAAE,mBAAmB,CAAC,CAAC;IACzF,CAAC;CACJ;AAED,kBAAe,0BAA0B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { IngestionPropertiesInput } from \"./ingestionProperties\";\n\nimport { KustoConnectionStringBuilder, KustoResponseDataSet } from \"azure-kusto-data\";\nimport { StreamDescriptor } from \"./descriptors\";\nimport { FileDescriptor } from \"./fileDescriptor.browser\";\nimport { tryFileToBuffer } from \"./streamUtils.browser\";\nimport { KustoStreamingIngestClientBase } from \"./streamingIngestClientBase\";\n\nclass KustoStreamingIngestClient extends KustoStreamingIngestClientBase {\n constructor(kcsb: string | KustoConnectionStringBuilder, defaultProps?: IngestionPropertiesInput, autoCorrectEndpoint?: boolean) {\n super(kcsb, defaultProps, autoCorrectEndpoint);\n }\n\n /**\n * Use Readable for Node.js and ArrayBuffer in browser\n */\n async ingestFromStream(stream: StreamDescriptor | ArrayBuffer, ingestionProperties?: IngestionPropertiesInput, clientRequestId?: string): Promise<any> {\n this.ensureOpen();\n\n const props = this._getMergedProps(ingestionProperties);\n const descriptor: StreamDescriptor = stream instanceof StreamDescriptor ? stream : new StreamDescriptor(stream);\n return await this.kustoClient.executeStreamingIngest(\n props.database as string,\n props.table as string,\n descriptor.stream,\n props.format,\n props.ingestionMappingReference ?? null,\n clientRequestId\n );\n }\n\n /**\n * Use string for Node.js and Blob in browser\n */\n async ingestFromFile(file: FileDescriptor | Blob, ingestionProperties?: IngestionPropertiesInput): Promise<KustoResponseDataSet> {\n this.ensureOpen();\n\n const descriptor: FileDescriptor = file instanceof FileDescriptor ? file : new FileDescriptor(file);\n return this.ingestFromStream(await tryFileToBuffer(descriptor), ingestionProperties);\n }\n}\n\nexport default KustoStreamingIngestClient;\n"]}
|
|
@@ -11,8 +11,8 @@ const fileDescriptor_1 = require("./fileDescriptor");
|
|
|
11
11
|
const streamUtils_1 = require("./streamUtils");
|
|
12
12
|
const streamingIngestClientBase_1 = require("./streamingIngestClientBase");
|
|
13
13
|
class KustoStreamingIngestClient extends streamingIngestClientBase_1.KustoStreamingIngestClientBase {
|
|
14
|
-
constructor(kcsb, defaultProps) {
|
|
15
|
-
super(kcsb, defaultProps);
|
|
14
|
+
constructor(kcsb, defaultProps, autoCorrectEndpoint) {
|
|
15
|
+
super(kcsb, defaultProps, autoCorrectEndpoint);
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Use Readable for Node.js and ArrayBuffer in browser
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamingIngestClient.js","sourceRoot":"","sources":["../../src/streamingIngestClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;AAMlC,gDAAwB;AACxB,+CAAkE;AAClE,qDAAkD;AAClD,+CAA6C;AAC7C,2EAA6E;AAE7E,MAAM,0BAA2B,SAAQ,0DAA8B;IACnE,YAAY,IAA2C,EAAE,YAAuC;
|
|
1
|
+
{"version":3,"file":"streamingIngestClient.js","sourceRoot":"","sources":["../../src/streamingIngestClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;AAMlC,gDAAwB;AACxB,+CAAkE;AAClE,qDAAkD;AAClD,+CAA6C;AAC7C,2EAA6E;AAE7E,MAAM,0BAA2B,SAAQ,0DAA8B;IACnE,YAAY,IAA2C,EAAE,YAAuC,EAAE,mBAA6B;QAC3H,KAAK,CAAC,IAAI,EA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kBAAe,0BAA0B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { IngestionPropertiesInput } from \"./ingestionProperties\";\n\nimport { KustoConnectionStringBuilder, KustoResponseDataSet } from \"azure-kusto-data\";\nimport { Readable } from \"stream\";\nimport zlib from \"zlib\";\nimport { CompressionType, StreamDescriptor } from \"./descriptors\";\nimport { FileDescriptor } from \"./fileDescriptor\";\nimport { fileToStream } from \"./streamUtils\";\nimport { KustoStreamingIngestClientBase } from \"./streamingIngestClientBase\";\n\nclass KustoStreamingIngestClient extends KustoStreamingIngestClientBase {\n constructor(kcsb: string | KustoConnectionStringBuilder, defaultProps?: IngestionPropertiesInput, autoCorrectEndpoint?: boolean) {\n super(kcsb, defaultProps, autoCorrectEndpoint);\n }\n\n /**\n * Use Readable for Node.js and ArrayBuffer in browser\n */\n async ingestFromStream(\n stream: StreamDescriptor | Readable | ArrayBuffer,\n ingestionProperties?: IngestionPropertiesInput,\n clientRequestId?: string\n ): Promise<any> {\n this.ensureOpen();\n\n const props = this._getMergedProps(ingestionProperties);\n const descriptor: StreamDescriptor = stream instanceof StreamDescriptor ? stream : new StreamDescriptor(stream);\n\n const compressedStream =\n descriptor.compressionType === CompressionType.None\n ? !(descriptor.stream instanceof ArrayBuffer)\n ? descriptor.stream.pipe(zlib.createGzip())\n : descriptor.stream\n : descriptor.stream;\n return await this.kustoClient.executeStreamingIngest(\n props.database as string,\n props.table as string,\n compressedStream,\n props.format,\n props.ingestionMappingReference ?? null,\n clientRequestId\n );\n }\n\n /**\n * Use string for Node.js and Blob in browser\n */\n async ingestFromFile(file: FileDescriptor | string | Blob, ingestionProperties?: IngestionPropertiesInput): Promise<KustoResponseDataSet> {\n this.ensureOpen();\n\n const descriptor: FileDescriptor = file instanceof FileDescriptor ? file : new FileDescriptor(file);\n return this.ingestFromStream(await fileToStream(descriptor), ingestionProperties);\n }\n}\n\nexport default KustoStreamingIngestClient;\n"]}
|
|
@@ -7,8 +7,14 @@ const descriptors_1 = require("./descriptors");
|
|
|
7
7
|
const abstractKustoClient_1 = require("./abstractKustoClient");
|
|
8
8
|
const azure_kusto_data_1 = require("azure-kusto-data");
|
|
9
9
|
class KustoStreamingIngestClientBase extends abstractKustoClient_1.AbstractKustoClient {
|
|
10
|
-
constructor(kcsb, defaultProps) {
|
|
10
|
+
constructor(kcsb, defaultProps, autoCorrectEndpoint = true) {
|
|
11
11
|
super(defaultProps);
|
|
12
|
+
if (typeof kcsb === "string") {
|
|
13
|
+
kcsb = new azure_kusto_data_1.KustoConnectionStringBuilder(kcsb);
|
|
14
|
+
}
|
|
15
|
+
if (autoCorrectEndpoint) {
|
|
16
|
+
kcsb.dataSource = this.getQueryEndpoint(kcsb.dataSource);
|
|
17
|
+
}
|
|
12
18
|
this.kustoClient = new azure_kusto_data_1.Client(kcsb);
|
|
13
19
|
this.defaultDatabase = this.kustoClient.defaultDatabase;
|
|
14
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamingIngestClientBase.js","sourceRoot":"","sources":["../../src/streamingIngestClientBase.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAIlC,+CAA+C;AAC/C,+DAA4D;AAC5D,uDAAuF;AAEvF,MAAsB,8BAA+B,SAAQ,yCAAmB;IAE5E,YAAY,IAA2C,EAAE,YAAuC;
|
|
1
|
+
{"version":3,"file":"streamingIngestClientBase.js","sourceRoot":"","sources":["../../src/streamingIngestClientBase.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAIlC,+CAA+C;AAC/C,+DAA4D;AAC5D,uDAAuF;AAEvF,MAAsB,8BAA+B,SAAQ,yCAAmB;IAE5E,YAAY,IAA2C,EAAE,YAAuC,EAAE,sBAA+B,IAAI;QACjI,KAAK,CAAC,YAAY,CAAC,CAAC;QACpB,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YAC1B,IAAI,GAAG,IAAI,+CAA4B,CAAC,IAAI,CAAC,CAAC;SACjD;QACD,IAAI,mBAAmB,EAAE;YACrB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SAC5D;QACD,IAAI,CAAC,WAAW,GAAG,IAAI,yBAAW,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,IAA6B,EAAE,mBAA8C,EAAE,eAAwB;;QACxH,MAAM,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC;QACxD,MAAM,UAAU,GAAG,IAAI,YAAY,4BAAc,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,4BAAc,CAAC,IAAI,CAAC,CAAC;QACpF,uEAAuE;QACvE,MAAM,UAAU,CAAC,QAAQ,EAAE,CAAC;QAE5B,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,sBAAsB,CAChD,KAAK,CAAC,QAAkB,EACxB,KAAK,CAAC,KAAe,EACrB,SAAS,EACT,KAAK,CAAC,MAAM,EACZ,MAAA,KAAK,CAAC,yBAAyB,mCAAI,IAAI,EACvC,UAAU,CAAC,IAAI,EACf,eAAe,CAClB,CAAC;IACN,CAAC;IAED,KAAK;QACD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACjB,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;SAC5B;QACD,KAAK,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;CACJ;AArCD,wEAqCC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { IngestionPropertiesInput } from \"./ingestionProperties\";\n\nimport { BlobDescriptor } from \"./descriptors\";\nimport { AbstractKustoClient } from \"./abstractKustoClient\";\nimport { Client as KustoClient, KustoConnectionStringBuilder } from \"azure-kusto-data\";\n\nexport abstract class KustoStreamingIngestClientBase extends AbstractKustoClient {\n protected kustoClient: KustoClient;\n constructor(kcsb: string | KustoConnectionStringBuilder, defaultProps?: IngestionPropertiesInput, autoCorrectEndpoint: boolean = true) {\n super(defaultProps);\n if (typeof kcsb === \"string\") {\n kcsb = new KustoConnectionStringBuilder(kcsb);\n }\n if (autoCorrectEndpoint) {\n kcsb.dataSource = this.getQueryEndpoint(kcsb.dataSource);\n }\n this.kustoClient = new KustoClient(kcsb);\n this.defaultDatabase = this.kustoClient.defaultDatabase;\n }\n\n async ingestFromBlob(blob: string | BlobDescriptor, ingestionProperties?: IngestionPropertiesInput, clientRequestId?: string): Promise<any> {\n const props = this._getMergedProps(ingestionProperties);\n const descriptor = blob instanceof BlobDescriptor ? blob : new BlobDescriptor(blob);\n // No need to check blob size if it was given to us that it's not empty\n await descriptor.fillSize();\n\n return await this.kustoClient.executeStreamingIngest(\n props.database as string,\n props.table as string,\n undefined,\n props.format,\n props.ingestionMappingReference ?? null,\n descriptor.path,\n clientRequestId\n );\n }\n\n close() {\n if (!this._isClosed) {\n this.kustoClient.close();\n }\n super.close();\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "azure-kusto-ingest",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.1",
|
|
4
4
|
"description": "Azure Data Explorer Ingestion SDK",
|
|
5
5
|
"module": "dist-esm/src/index.js",
|
|
6
6
|
"types": "./types/src/index.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"clean": "rimraf dist/* dist-esm/* types/*"
|
|
11
11
|
},
|
|
12
12
|
"engines": {
|
|
13
|
-
"node": ">=
|
|
13
|
+
"node": ">= 18.0.0"
|
|
14
14
|
},
|
|
15
15
|
"publishConfig": {
|
|
16
16
|
"access": "public"
|
|
@@ -54,17 +54,20 @@
|
|
|
54
54
|
"./dist-esm/src/ingestClient.js": "./dist-esm/src/ingestClient.browser.js"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
+
"@azure/data-tables": "^13.2.2",
|
|
57
58
|
"@azure/storage-blob": "^12.11.0",
|
|
58
59
|
"@azure/storage-queue": "^12.10.0",
|
|
60
|
+
"@types/jsbn": "^1.2.33",
|
|
59
61
|
"@types/pako": "^2.0.0",
|
|
60
62
|
"@types/stream-array": "^1.1.0",
|
|
61
63
|
"@types/stream-to-array": "^2.3.0",
|
|
62
64
|
"@types/tmp": "^0.2.3",
|
|
63
65
|
"@types/uuid": "^8.3.4",
|
|
64
66
|
"@types/uuid-validate": "0.0.1",
|
|
65
|
-
"azure-kusto-data": "^
|
|
67
|
+
"azure-kusto-data": "^6.0.1",
|
|
66
68
|
"browserify-zlib": "0.2.0",
|
|
67
69
|
"buffer": "^6.0.3",
|
|
70
|
+
"is-ip": "^3.1.0",
|
|
68
71
|
"stream-array": "^1.1.2",
|
|
69
72
|
"stream-browserify": "3.0.0",
|
|
70
73
|
"stream-to-array": "^2.3.0",
|
|
@@ -76,5 +79,5 @@
|
|
|
76
79
|
"@types/sinon": "^10.0.13",
|
|
77
80
|
"assert": "^2.0.0"
|
|
78
81
|
},
|
|
79
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "22105ff85cd5489bce46fce38987fb616dd6cd75"
|
|
80
83
|
}
|
|
@@ -11,5 +11,8 @@ export declare abstract class AbstractKustoClient {
|
|
|
11
11
|
abstract ingestFromBlob(blob: string | BlobDescriptor, ingestionProperties?: IngestionPropertiesInput): Promise<any>;
|
|
12
12
|
close(): void;
|
|
13
13
|
protected ensureOpen(): void;
|
|
14
|
+
getIngestionEndpoint(clusterUrl?: string): string | undefined;
|
|
15
|
+
getQueryEndpoint(clusterUrl?: string): string | undefined;
|
|
16
|
+
isReservedHostname(clusterUrl: string): boolean;
|
|
14
17
|
}
|
|
15
18
|
//# sourceMappingURL=abstractKustoClient.d.ts.map
|
|
@@ -7,6 +7,7 @@ export declare enum CompressionType {
|
|
|
7
7
|
None = ""
|
|
8
8
|
}
|
|
9
9
|
export declare const getSourceId: (sourceId: string | null) => string;
|
|
10
|
+
export declare function shouldCompressFileByExtension(extension?: string): boolean;
|
|
10
11
|
export declare abstract class AbstractDescriptor {
|
|
11
12
|
sourceId: string | null;
|
|
12
13
|
size: number | null;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AbstractDescriptor, CompressionType, FileDescriptorBase } from "./descriptors";
|
|
2
|
+
import { IngestionPropertiesInput } from "./ingestionProperties";
|
|
2
3
|
export declare class FileDescriptor extends AbstractDescriptor implements FileDescriptorBase {
|
|
3
4
|
readonly file: Blob;
|
|
4
5
|
readonly extension?: string | undefined;
|
|
@@ -6,9 +7,10 @@ export declare class FileDescriptor extends AbstractDescriptor implements FileDe
|
|
|
6
7
|
size: number | null;
|
|
7
8
|
zipped: boolean;
|
|
8
9
|
compressionType: CompressionType;
|
|
10
|
+
shouldNotCompress: boolean;
|
|
9
11
|
cleanupTmp?: () => Promise<void>;
|
|
10
12
|
constructor(file: Blob, sourceId?: string | null, size?: number | null, compressionType?: CompressionType, extension?: string | undefined, name?: string | undefined);
|
|
11
|
-
prepare(): Promise<Blob>;
|
|
13
|
+
prepare(ingestionProperties?: IngestionPropertiesInput): Promise<Blob>;
|
|
12
14
|
cleanup(): Promise<void>;
|
|
13
15
|
getCompressionSuffix(): string;
|
|
14
16
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AbstractDescriptor, CompressionType, FileDescriptorBase } from "./descriptors";
|
|
2
|
+
import { IngestionPropertiesInput } from "./ingestionProperties";
|
|
2
3
|
/**
|
|
3
4
|
* Describes a file to be ingested. Use string to describe a local path in Node.JS and Blob object in browsers
|
|
4
5
|
*/
|
|
@@ -11,6 +12,7 @@ export declare class FileDescriptor extends AbstractDescriptor implements FileDe
|
|
|
11
12
|
readonly name?: string | undefined;
|
|
12
13
|
zipped: boolean;
|
|
13
14
|
compressionType: CompressionType;
|
|
15
|
+
shouldNotCompress: boolean;
|
|
14
16
|
cleanupTmp?: () => Promise<void>;
|
|
15
17
|
constructor(
|
|
16
18
|
/**
|
|
@@ -19,7 +21,7 @@ export declare class FileDescriptor extends AbstractDescriptor implements FileDe
|
|
|
19
21
|
file: string | Blob, sourceId?: string | null, size?: number | null, compressionType?: CompressionType, extension?: string | undefined, // Extracted from file name by default
|
|
20
22
|
name?: string | undefined);
|
|
21
23
|
_gzip(): Promise<string>;
|
|
22
|
-
prepare(): Promise<string>;
|
|
24
|
+
prepare(ingestionProperties?: IngestionPropertiesInput): Promise<string>;
|
|
23
25
|
private _calculateSize;
|
|
24
26
|
cleanup(): Promise<void>;
|
|
25
27
|
getCompressionSuffix(): string;
|
package/types/src/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import KustoIngestClient from "./ingestClient";
|
|
|
2
2
|
import streamingIngestClient from "./streamingIngestClient";
|
|
3
3
|
import managedStreamingIngestClient from "./managedStreamingIngestClient";
|
|
4
4
|
import KustoIngestStatusQueues from "./status";
|
|
5
|
+
import { IngestionResult, OperationStatus, IngestionStatus, IngestionStatusInTableDescription } from "./ingestionResult";
|
|
5
6
|
import { DataFormat, IngestionMappingKind, ReportLevel, ReportMethod, ValidationImplications, ValidationOptions, ValidationPolicy, dataFormatMappingKind } from "./ingestionProperties";
|
|
6
7
|
import { ApacheAvroColumnMapping, AvroColumnMapping, ColumnMapping, ConstantTransformation, CsvColumnMapping, FieldTransformation, JsonColumnMapping, OrcColumnMapping, ParquetColumnMapping, SStreamColumnMapping, W3CLogFileMapping } from "./columnMappings";
|
|
7
8
|
import { BlobDescriptor, CompressionType, StreamDescriptor } from "./descriptors";
|
|
@@ -17,7 +18,7 @@ export declare const IngestionDescriptors: {
|
|
|
17
18
|
FileDescriptor: typeof FileDescriptor;
|
|
18
19
|
StreamDescriptor: typeof StreamDescriptor;
|
|
19
20
|
};
|
|
20
|
-
export { ApacheAvroColumnMapping, AvroColumnMapping, BlobDescriptor, ColumnMapping, CompressionType, ConstantTransformation, CsvColumnMapping, DataFormat, FieldTransformation, FileDescriptor, IngestionMappingKind, JsonColumnMapping, OrcColumnMapping, ParquetColumnMapping, ReportLevel, ReportMethod, SStreamColumnMapping, StreamDescriptor, ValidationImplications, ValidationOptions, ValidationPolicy, W3CLogFileMapping, dataFormatMappingKind, };
|
|
21
|
+
export { ApacheAvroColumnMapping, AvroColumnMapping, BlobDescriptor, ColumnMapping, CompressionType, ConstantTransformation, CsvColumnMapping, DataFormat, FieldTransformation, FileDescriptor, IngestionMappingKind, JsonColumnMapping, OrcColumnMapping, ParquetColumnMapping, ReportLevel, ReportMethod, SStreamColumnMapping, StreamDescriptor, ValidationImplications, ValidationOptions, ValidationPolicy, W3CLogFileMapping, dataFormatMappingKind, IngestionResult, OperationStatus, IngestionStatus, IngestionStatusInTableDescription, };
|
|
21
22
|
/**
|
|
22
23
|
* @deprecated - import directly instead
|
|
23
24
|
*/
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { KustoConnectionStringBuilder } from "azure-kusto-data";
|
|
2
2
|
import { StreamDescriptor } from "./descriptors";
|
|
3
3
|
import { FileDescriptor } from "./fileDescriptor.browser";
|
|
4
|
-
import { QueueSendMessageResponse } from "@azure/storage-queue";
|
|
5
4
|
import { IngestionPropertiesInput } from "./ingestionProperties";
|
|
6
5
|
import { KustoIngestClientBase } from "./ingestClientBase";
|
|
6
|
+
import { IngestionResult } from "./ingestionResult";
|
|
7
7
|
export declare class KustoIngestClient extends KustoIngestClientBase {
|
|
8
|
-
constructor(kcsb: string | KustoConnectionStringBuilder, defaultProps?: IngestionPropertiesInput);
|
|
8
|
+
constructor(kcsb: string | KustoConnectionStringBuilder, defaultProps?: IngestionPropertiesInput, autoCorrectEndpoint?: boolean);
|
|
9
9
|
/**
|
|
10
10
|
* Use string for Node.js and Blob in browser
|
|
11
11
|
*/
|
|
12
|
-
ingestFromFile(file: Blob | FileDescriptor, ingestionProperties?: IngestionPropertiesInput): Promise<
|
|
12
|
+
ingestFromFile(file: Blob | FileDescriptor, ingestionProperties?: IngestionPropertiesInput): Promise<IngestionResult>;
|
|
13
13
|
/**
|
|
14
14
|
* Use Readable for Node.js and ArrayBuffer in browser
|
|
15
15
|
*/
|
|
16
|
-
ingestFromStream(stream: ArrayBuffer | StreamDescriptor, ingestionProperties?: IngestionPropertiesInput): Promise<
|
|
16
|
+
ingestFromStream(stream: ArrayBuffer | StreamDescriptor, ingestionProperties?: IngestionPropertiesInput): Promise<IngestionResult>;
|
|
17
17
|
}
|
|
18
18
|
export default KustoIngestClient;
|
|
19
19
|
//# sourceMappingURL=ingestClient.browser.d.ts.map
|
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
import { KustoConnectionStringBuilder } from "azure-kusto-data";
|
|
3
3
|
import { StreamDescriptor } from "./descriptors";
|
|
4
4
|
import { FileDescriptor } from "./fileDescriptor";
|
|
5
|
-
import { QueueSendMessageResponse } from "@azure/storage-queue";
|
|
6
5
|
import { IngestionPropertiesInput } from "./ingestionProperties";
|
|
7
6
|
import { KustoIngestClientBase } from "./ingestClientBase";
|
|
8
7
|
import { Readable } from "stream";
|
|
8
|
+
import { IngestionResult } from "./ingestionResult";
|
|
9
9
|
export declare class KustoIngestClient extends KustoIngestClientBase {
|
|
10
|
-
constructor(kcsb: string | KustoConnectionStringBuilder, defaultProps?: IngestionPropertiesInput);
|
|
10
|
+
constructor(kcsb: string | KustoConnectionStringBuilder, defaultProps?: IngestionPropertiesInput, autoCorrectEndpoint?: boolean);
|
|
11
11
|
/**
|
|
12
12
|
* Use string in Node.JS and Blob in browser
|
|
13
13
|
*/
|
|
14
|
-
ingestFromFile(file: FileDescriptor | string | Blob, ingestionProperties?: IngestionPropertiesInput): Promise<
|
|
14
|
+
ingestFromFile(file: FileDescriptor | string | Blob, ingestionProperties?: IngestionPropertiesInput): Promise<IngestionResult>;
|
|
15
15
|
/**
|
|
16
16
|
* Use Readable in Node.JS and ArrayBuffer in browser
|
|
17
17
|
*/
|
|
18
|
-
ingestFromStream(stream: StreamDescriptor | Readable | ArrayBuffer, ingestionProperties?: IngestionPropertiesInput): Promise<
|
|
18
|
+
ingestFromStream(stream: StreamDescriptor | Readable | ArrayBuffer, ingestionProperties?: IngestionPropertiesInput): Promise<IngestionResult>;
|
|
19
19
|
}
|
|
20
20
|
export default KustoIngestClient;
|
|
21
21
|
//# sourceMappingURL=ingestClient.d.ts.map
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { KustoConnectionStringBuilder } from "azure-kusto-data";
|
|
2
|
-
import { BlobDescriptor } from "./descriptors";
|
|
3
2
|
import ResourceManager from "./resourceManager";
|
|
4
|
-
import { QueueSendMessageResponse } from "@azure/storage-queue";
|
|
5
3
|
import { IngestionPropertiesInput } from "./ingestionProperties";
|
|
6
4
|
import { AbstractKustoClient } from "./abstractKustoClient";
|
|
5
|
+
import { IngestionResult } from "./ingestionResult";
|
|
6
|
+
import { BlobDescriptor, StreamDescriptor } from "./descriptors";
|
|
7
7
|
export declare abstract class KustoIngestClientBase extends AbstractKustoClient {
|
|
8
8
|
resourceManager: ResourceManager;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
applicationForTracing: string | null;
|
|
10
|
+
clientVersionForTracing: string | null;
|
|
11
|
+
static readonly MaxNumberOfRetryAttempts = 3;
|
|
12
|
+
constructor(kcsb: string | KustoConnectionStringBuilder, defaultProps?: IngestionPropertiesInput, autoCorrectEndpoint?: boolean, isBrowser?: boolean);
|
|
13
|
+
ingestFromBlob(blob: string | BlobDescriptor, ingestionProperties?: IngestionPropertiesInput, maxRetries?: number): Promise<IngestionResult>;
|
|
14
|
+
private sendQueueMessage;
|
|
15
|
+
private createStatusObject;
|
|
16
|
+
uploadToBlobWithRetry(descriptor: string | Blob | ArrayBuffer | StreamDescriptor, blobName: string, maxRetries?: number): Promise<string>;
|
|
11
17
|
close(): void;
|
|
12
18
|
}
|
|
13
19
|
export default KustoIngestClientBase;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BlobDescriptor } from "./descriptors";
|
|
2
2
|
import IngestionProperties, { ReportLevel, ReportMethod } from "./ingestionProperties";
|
|
3
|
+
import { IngestionStatusInTableDescription } from "./ingestionResult";
|
|
3
4
|
export declare class IngestionBlobInfo {
|
|
4
5
|
BlobPath: string;
|
|
5
6
|
RawDataSize: number | null;
|
|
@@ -15,7 +16,10 @@ export declare class IngestionBlobInfo {
|
|
|
15
16
|
AdditionalProperties: {
|
|
16
17
|
[additional: string]: any;
|
|
17
18
|
};
|
|
18
|
-
|
|
19
|
+
IngestionStatusInTable: IngestionStatusInTableDescription | null;
|
|
20
|
+
ApplicationForTracing?: string | null;
|
|
21
|
+
ClientVersionForTracing?: string | null;
|
|
22
|
+
constructor(blobDescriptor: BlobDescriptor, ingestionProperties: IngestionProperties, authContext?: string | null, applicationForTracing?: string | null, clientVersionForTracing?: string | null);
|
|
19
23
|
}
|
|
20
24
|
export default IngestionBlobInfo;
|
|
21
25
|
//# sourceMappingURL=ingestionBlobInfo.d.ts.map
|
|
@@ -145,5 +145,6 @@ export declare class IngestionProperties {
|
|
|
145
145
|
setDefaults(): void;
|
|
146
146
|
}
|
|
147
147
|
export type IngestionPropertiesInput = IngestionProperties | IngestionPropertiesFields | null | undefined;
|
|
148
|
+
export declare function shouldCompressFileByFormat(ingestionProperties?: IngestionPropertiesInput): boolean;
|
|
148
149
|
export default IngestionProperties;
|
|
149
150
|
//# sourceMappingURL=ingestionProperties.d.ts.map
|