azure-kusto-ingest 5.0.4 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -57
- package/dist-esm/src/abstractKustoClient.js.map +1 -0
- package/dist-esm/src/columnMappings.js.map +1 -0
- package/dist-esm/src/descriptors.js +28 -8
- package/dist-esm/src/descriptors.js.map +1 -0
- package/dist-esm/src/errors.js.map +1 -0
- package/dist-esm/src/fileDescriptor.browser.js +2 -3
- package/dist-esm/src/fileDescriptor.browser.js.map +1 -0
- package/dist-esm/src/fileDescriptor.js +2 -3
- package/dist-esm/src/fileDescriptor.js.map +1 -0
- package/dist-esm/src/index.js +14 -8
- package/dist-esm/src/index.js.map +1 -0
- package/dist-esm/src/ingestClient.browser.js.map +1 -0
- package/dist-esm/src/ingestClient.js +6 -1
- package/dist-esm/src/ingestClient.js.map +1 -0
- package/dist-esm/src/ingestClientBase.js.map +1 -0
- package/dist-esm/src/ingestionBlobInfo.js.map +1 -0
- package/dist-esm/src/ingestionProperties.js.map +1 -0
- package/dist-esm/src/managedStreamingIngestClient.js +47 -23
- package/dist-esm/src/managedStreamingIngestClient.js.map +1 -0
- package/dist-esm/src/resourceManager.js +33 -14
- package/dist-esm/src/resourceManager.js.map +1 -0
- package/dist-esm/src/retry.js.map +1 -0
- package/dist-esm/src/status.js.map +1 -0
- package/dist-esm/src/statusQ.js.map +1 -0
- package/dist-esm/src/streamUtils.browser.js +6 -1
- package/dist-esm/src/streamUtils.browser.js.map +1 -0
- package/dist-esm/src/streamUtils.js +6 -2
- package/dist-esm/src/streamUtils.js.map +1 -0
- package/dist-esm/src/streamingIngestClient.browser.js +3 -12
- package/dist-esm/src/streamingIngestClient.browser.js.map +1 -0
- package/dist-esm/src/streamingIngestClient.js +4 -13
- package/dist-esm/src/streamingIngestClient.js.map +1 -0
- package/dist-esm/src/streamingIngestClientBase.js +31 -0
- package/dist-esm/src/streamingIngestClientBase.js.map +1 -0
- package/package.json +5 -3
- package/types/src/abstractKustoClient.d.ts +2 -1
- package/types/src/descriptors.d.ts +9 -7
- package/types/src/fileDescriptor.browser.d.ts +2 -3
- package/types/src/fileDescriptor.d.ts +2 -4
- package/types/src/index.d.ts +6 -6
- package/types/src/managedStreamingIngestClient.d.ts +7 -6
- package/types/src/resourceManager.d.ts +2 -0
- package/types/src/streamUtils.browser.d.ts +1 -0
- package/types/src/streamUtils.d.ts +2 -1
- package/types/src/streamingIngestClient.browser.d.ts +3 -6
- package/types/src/streamingIngestClient.d.ts +4 -7
- package/types/src/streamingIngestClientBase.d.ts +11 -0
|
@@ -5,16 +5,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
6
|
};
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
const core_util_1 = require("@azure/core-util");
|
|
9
|
+
const azure_kusto_data_1 = require("azure-kusto-data");
|
|
10
|
+
const abstractKustoClient_1 = require("./abstractKustoClient");
|
|
8
11
|
const descriptors_1 = require("./descriptors");
|
|
9
12
|
const fileDescriptor_1 = require("./fileDescriptor");
|
|
10
|
-
const abstractKustoClient_1 = require("./abstractKustoClient");
|
|
11
|
-
const azure_kusto_data_1 = require("azure-kusto-data");
|
|
12
|
-
const streamingIngestClient_1 = __importDefault(require("./streamingIngestClient"));
|
|
13
|
-
const streamUtils_1 = require("./streamUtils");
|
|
14
13
|
const ingestClient_1 = __importDefault(require("./ingestClient"));
|
|
15
|
-
const stream_array_1 = __importDefault(require("stream-array"));
|
|
16
14
|
const retry_1 = require("./retry");
|
|
17
|
-
const
|
|
15
|
+
const streamUtils_1 = require("./streamUtils");
|
|
16
|
+
const streamingIngestClient_1 = __importDefault(require("./streamingIngestClient"));
|
|
18
17
|
const maxStreamSize = 1024 * 1024 * 4;
|
|
19
18
|
const attemptCount = 3;
|
|
20
19
|
const ingestPrefix = "https://ingest-";
|
|
@@ -67,20 +66,53 @@ class KustoManagedStreamingIngestClient extends abstractKustoClient_1.AbstractKu
|
|
|
67
66
|
/**
|
|
68
67
|
* Use Readable for Node.js and ArrayBuffer in browser
|
|
69
68
|
*/
|
|
70
|
-
async ingestFromStream(stream, ingestionProperties) {
|
|
69
|
+
async ingestFromStream(stream, ingestionProperties, clientRequestId) {
|
|
70
|
+
var _a;
|
|
71
71
|
this.ensureOpen();
|
|
72
72
|
const props = this._getMergedProps(ingestionProperties);
|
|
73
|
-
|
|
73
|
+
let descriptor = stream instanceof descriptors_1.StreamDescriptor ? stream : new descriptors_1.StreamDescriptor(stream);
|
|
74
74
|
let result = core_util_1.isNode ? await (0, streamUtils_1.tryStreamToArray)(descriptor.stream, maxStreamSize) : descriptor.stream;
|
|
75
|
-
|
|
75
|
+
descriptor = new descriptors_1.StreamDescriptor(result).merge(descriptor);
|
|
76
|
+
let streamingResult = null;
|
|
77
|
+
// tryStreamToArray returns a Buffer in NodeJS impl if stream size is small enouph
|
|
78
|
+
if ((core_util_1.isNode && result instanceof Buffer) || !core_util_1.isNode) {
|
|
79
|
+
streamingResult = await this.streamWithRetries(core_util_1.isNode ? (_a = descriptor.size) !== null && _a !== void 0 ? _a : 0 : descriptor.stream.byteLength, descriptor, props, clientRequestId, result);
|
|
80
|
+
result = core_util_1.isNode ? (0, streamUtils_1.readableToStream)(result) : descriptor.stream;
|
|
81
|
+
}
|
|
82
|
+
return streamingResult !== null && streamingResult !== void 0 ? streamingResult : this.queuedIngestClient.ingestFromStream(new descriptors_1.StreamDescriptor(result).merge(descriptor), props);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Use string for Node.js and Blob in browser
|
|
86
|
+
*/
|
|
87
|
+
async ingestFromFile(file, ingestionProperties) {
|
|
88
|
+
this.ensureOpen();
|
|
89
|
+
const stream = file instanceof fileDescriptor_1.FileDescriptor ? await (0, streamUtils_1.tryFileToBuffer)(file) : await (0, streamUtils_1.tryFileToBuffer)(new fileDescriptor_1.FileDescriptor(file));
|
|
90
|
+
return await this.ingestFromStream(stream, ingestionProperties);
|
|
91
|
+
}
|
|
92
|
+
async ingestFromBlob(blob, ingestionProperties, clientRequestId) {
|
|
93
|
+
var _a;
|
|
94
|
+
const props = this._getMergedProps(ingestionProperties);
|
|
95
|
+
const descriptor = blob instanceof descriptors_1.BlobDescriptor ? blob : new descriptors_1.BlobDescriptor(blob);
|
|
96
|
+
// No need to check blob size if it was given to us that it's not empty
|
|
97
|
+
await descriptor.fillSize();
|
|
98
|
+
const streamingResult = await this.streamWithRetries((_a = descriptor.size) !== null && _a !== void 0 ? _a : 0, descriptor, props, clientRequestId);
|
|
99
|
+
return streamingResult !== null && streamingResult !== void 0 ? streamingResult : this.queuedIngestClient.ingestFromBlob(descriptor, props);
|
|
100
|
+
}
|
|
101
|
+
async streamWithRetries(length, descriptor, props, clientRequestId, stream) {
|
|
102
|
+
const isBlob = descriptor instanceof descriptors_1.BlobDescriptor;
|
|
103
|
+
if (length <= maxStreamSize) {
|
|
76
104
|
// If we get buffer that means it was less than the max size, so we can do streamingIngestion
|
|
77
105
|
const retry = new retry_1.ExponentialRetry(attemptCount, this.baseSleepTimeSecs, this.baseJitterSecs);
|
|
78
106
|
while (retry.shouldTry()) {
|
|
79
107
|
try {
|
|
80
|
-
const sourceId = `KNC.executeManagedStreamingIngest;${descriptor.sourceId};${retry.currentAttempt}`;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
108
|
+
const sourceId = clientRequestId !== null && clientRequestId !== void 0 ? clientRequestId : `KNC.executeManagedStreamingIngest${isBlob ? "FromBlob" : "FromStream"};${descriptor.sourceId};${retry.currentAttempt}`;
|
|
109
|
+
if (isBlob) {
|
|
110
|
+
return this.streamingIngestClient.ingestFromBlob(descriptor, props, sourceId);
|
|
111
|
+
}
|
|
112
|
+
if (core_util_1.isNode) {
|
|
113
|
+
return await this.streamingIngestClient.ingestFromStream(new descriptors_1.StreamDescriptor((0, streamUtils_1.readableToStream)(stream)).merge(descriptor), props, sourceId);
|
|
114
|
+
}
|
|
115
|
+
return await this.streamingIngestClient.ingestFromStream(descriptor, props, sourceId);
|
|
84
116
|
}
|
|
85
117
|
catch (err) {
|
|
86
118
|
const oneApiError = err;
|
|
@@ -90,17 +122,9 @@ class KustoManagedStreamingIngestClient extends abstractKustoClient_1.AbstractKu
|
|
|
90
122
|
await retry.backoff();
|
|
91
123
|
}
|
|
92
124
|
}
|
|
93
|
-
|
|
125
|
+
stream = isBlob ? undefined : core_util_1.isNode && stream ? (0, streamUtils_1.readableToStream)(stream) : descriptor.stream;
|
|
94
126
|
}
|
|
95
|
-
return
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Use string for Node.js and Blob in browser
|
|
99
|
-
*/
|
|
100
|
-
async ingestFromFile(file, ingestionProperties) {
|
|
101
|
-
this.ensureOpen();
|
|
102
|
-
const stream = file instanceof fileDescriptor_1.FileDescriptor ? await (0, streamUtils_1.tryFileToBuffer)(file) : await (0, streamUtils_1.tryFileToBuffer)(new fileDescriptor_1.FileDescriptor(file));
|
|
103
|
-
return await this.ingestFromStream(stream, ingestionProperties);
|
|
127
|
+
return null;
|
|
104
128
|
}
|
|
105
129
|
close() {
|
|
106
130
|
if (!this._isClosed) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"managedStreamingIngestClient.js","sourceRoot":"","sources":["../../src/managedStreamingIngestClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;AAIlC,gDAA0C;AAE1C,uDAAsF;AAEtF,+DAA4D;AAC5D,+CAAqF;AACrF,qDAAkD;AAClD,kEAA0C;AAC1C,mCAA2C;AAC3C,+CAAoF;AACpF,oFAA4D;AAE5D,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC;AACtC,MAAM,YAAY,GAAG,CAAC,CAAC;AACvB,MAAM,YAAY,GAAG,iBAAiB,CAAC;AAEvC,MAAM,iCAAkC,SAAQ,yCAAmB;IAM/D;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AM,WAAW,GAAG,GAAiC,CAAC;oBACtD,IAAI,WAAW,CAAC,YAAY,CAAC,EAAE;wBAC3B,MAAM,GAAG,CAAC;qBACb;oBACD,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;iBACzB;aACJ;YAED,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,kBAAM,IAAI,MAAM,CAAC,CAAC,CAAC,IAAA,8BAAgB,EAAC,MAAM,CAAC,CAAC,CAAC,CAAE,UAA+B,CAAC,MAAM,CAAC;SACvH;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,KAAK;QACD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACjB,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC;YACnC,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC;SACnC;QACD,KAAK,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;CACJ;AAED,kBAAe,iCAAiC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { IngestionPropertiesInput } from \"./ingestionProperties\";\n\nimport { isNode } from \"@azure/core-util\";\nimport { QueueSendMessageResponse } from \"@azure/storage-queue\";\nimport { KustoConnectionStringBuilder, KustoResponseDataSet } from \"azure-kusto-data\";\nimport { Readable } from \"stream\";\nimport { AbstractKustoClient } from \"./abstractKustoClient\";\nimport { AbstractDescriptor, BlobDescriptor, StreamDescriptor } from \"./descriptors\";\nimport { FileDescriptor } from \"./fileDescriptor\";\nimport IngestClient from \"./ingestClient\";\nimport { ExponentialRetry } from \"./retry\";\nimport { readableToStream, tryFileToBuffer, tryStreamToArray } from \"./streamUtils\";\nimport StreamingIngestClient from \"./streamingIngestClient\";\n\nconst maxStreamSize = 1024 * 1024 * 4;\nconst attemptCount = 3;\nconst ingestPrefix = \"https://ingest-\";\n\nclass KustoManagedStreamingIngestClient extends AbstractKustoClient {\n private streamingIngestClient: StreamingIngestClient;\n private queuedIngestClient: IngestClient;\n private baseSleepTimeSecs = 1;\n private baseJitterSecs = 1;\n\n /**\n * Creates a KustoManagedStreamingIngestClient from a DM connection string.\n * This method infers the engine connection string.\n * For advanced usage, use the constructor that takes a DM connection string and an engine connection string.\n *\n * @param dmConnectionString The DM connection string.\n * @param defaultProps The default ingestion properties.\n */\n static fromDmConnectionString(\n dmConnectionString: KustoConnectionStringBuilder,\n defaultProps?: IngestionPropertiesInput\n ): KustoManagedStreamingIngestClient {\n if (dmConnectionString.dataSource == null || !dmConnectionString.dataSource.startsWith(ingestPrefix)) {\n throw new Error(`DM connection string must include the prefix '${ingestPrefix}'`);\n }\n\n const engineConnectionString = KustoConnectionStringBuilder.fromExisting(dmConnectionString);\n engineConnectionString.dataSource = engineConnectionString.dataSource?.replace(ingestPrefix, \"https://\");\n\n return new KustoManagedStreamingIngestClient(engineConnectionString, dmConnectionString, defaultProps);\n }\n\n /**\n * Creates a KustoManagedStreamingIngestClient from a engine connection string.\n * This method infers the engine connection string.\n * For advanced usage, use the constructor that takes an engine connection string and an engine connection string.\n *\n * @param engineConnectionString The engine connection string.\n * @param defaultProps The default ingestion properties.\n */\n static fromEngineConnectionString(\n engineConnectionString: KustoConnectionStringBuilder,\n defaultProps?: IngestionPropertiesInput\n ): KustoManagedStreamingIngestClient {\n if (engineConnectionString.dataSource == null || engineConnectionString.dataSource.startsWith(ingestPrefix)) {\n throw new Error(`Engine connection string must not include the prefix '${ingestPrefix}'`);\n }\n\n const dmConnectionString = KustoConnectionStringBuilder.fromExisting(engineConnectionString);\n dmConnectionString.dataSource = dmConnectionString.dataSource?.replace(\"https://\", ingestPrefix);\n\n return new KustoManagedStreamingIngestClient(engineConnectionString, dmConnectionString, defaultProps);\n }\n\n constructor(engineKcsb: string | KustoConnectionStringBuilder, dmKcsb: string | KustoConnectionStringBuilder, defaultProps?: IngestionPropertiesInput) {\n super(defaultProps);\n this.streamingIngestClient = new StreamingIngestClient(engineKcsb, defaultProps);\n this.queuedIngestClient = new IngestClient(dmKcsb, defaultProps);\n\n if (this.streamingIngestClient.defaultDatabase && this.streamingIngestClient.defaultDatabase !== this.queuedIngestClient.defaultDatabase) {\n throw new Error(\n `Default database for streaming ingest client (${this.streamingIngestClient.defaultDatabase}) must match default database for queued ingest client (${this.queuedIngestClient.defaultDatabase})`\n );\n }\n\n this.defaultDatabase = this.streamingIngestClient.defaultDatabase;\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 const props = this._getMergedProps(ingestionProperties);\n let descriptor = stream instanceof StreamDescriptor ? stream : new StreamDescriptor(stream);\n let result = isNode ? await tryStreamToArray(descriptor.stream as Readable, maxStreamSize) : descriptor.stream;\n descriptor = new StreamDescriptor(result).merge(descriptor);\n let streamingResult: Promise<any> | null = null;\n // tryStreamToArray returns a Buffer in NodeJS impl if stream size is small enouph\n if ((isNode && result instanceof Buffer) || !isNode) {\n streamingResult = await this.streamWithRetries(\n isNode ? descriptor.size ?? 0 : (descriptor.stream as ArrayBuffer).byteLength,\n descriptor,\n props,\n clientRequestId,\n result\n );\n\n result = isNode ? readableToStream(result) : descriptor.stream;\n }\n\n return streamingResult ?? this.queuedIngestClient.ingestFromStream(new StreamDescriptor(result).merge(descriptor), props);\n }\n\n /**\n * Use string for Node.js and Blob in browser\n */\n async ingestFromFile(\n file: FileDescriptor | string | Blob,\n ingestionProperties?: IngestionPropertiesInput\n ): Promise<KustoResponseDataSet | QueueSendMessageResponse> {\n this.ensureOpen();\n\n const stream = file instanceof FileDescriptor ? await tryFileToBuffer(file) : await tryFileToBuffer(new FileDescriptor(file));\n return await this.ingestFromStream(stream, ingestionProperties);\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 const streamingResult = await this.streamWithRetries(descriptor.size ?? 0, descriptor, props, clientRequestId);\n return streamingResult ?? this.queuedIngestClient.ingestFromBlob(descriptor, props);\n }\n\n async streamWithRetries(\n length: number,\n descriptor: AbstractDescriptor,\n props?: IngestionPropertiesInput,\n clientRequestId?: string,\n stream?: Readable | ArrayBuffer\n ): Promise<any> {\n const isBlob = descriptor instanceof BlobDescriptor;\n if (length <= maxStreamSize) {\n // If we get buffer that means it was less than the max size, so we can do streamingIngestion\n const retry = new ExponentialRetry(attemptCount, this.baseSleepTimeSecs, this.baseJitterSecs);\n while (retry.shouldTry()) {\n try {\n const sourceId =\n clientRequestId ??\n `KNC.executeManagedStreamingIngest${isBlob ? \"FromBlob\" : \"FromStream\"};${descriptor.sourceId};${retry.currentAttempt}`;\n if (isBlob) {\n return this.streamingIngestClient.ingestFromBlob(descriptor as BlobDescriptor, props, sourceId);\n }\n\n if (isNode) {\n return await this.streamingIngestClient.ingestFromStream(\n new StreamDescriptor(readableToStream(stream!)).merge(descriptor as StreamDescriptor),\n props,\n sourceId\n );\n }\n\n return await this.streamingIngestClient.ingestFromStream(descriptor as StreamDescriptor, props, sourceId);\n } catch (err: unknown) {\n const oneApiError = err as { \"@permanent\"?: boolean };\n if (oneApiError[\"@permanent\"]) {\n throw err;\n }\n await retry.backoff();\n }\n }\n\n stream = isBlob ? undefined : isNode && stream ? readableToStream(stream) : (descriptor as StreamDescriptor).stream;\n }\n\n return null;\n }\n\n close() {\n if (!this._isClosed) {\n this.streamingIngestClient.close();\n this.queuedIngestClient.close();\n }\n super.close();\n }\n}\n\nexport default KustoManagedStreamingIngestClient;\n"]}
|
|
@@ -33,19 +33,16 @@ class ResourceManager {
|
|
|
33
33
|
this.baseSleepTimeSecs = 1;
|
|
34
34
|
this.baseJitterSecs = 1;
|
|
35
35
|
this.refreshPeriod = azure_kusto_data_1.TimeUtils.toMilliseconds(1, 0, 0);
|
|
36
|
+
this.refreshPeriodOnError = azure_kusto_data_1.TimeUtils.toMilliseconds(0, 10, 0);
|
|
36
37
|
this.ingestClientResources = null;
|
|
37
38
|
this.ingestClientResourcesLastUpdate = null;
|
|
38
39
|
this.authorizationContext = null;
|
|
39
40
|
this.authorizationContextLastUpdate = null;
|
|
40
41
|
}
|
|
41
42
|
async refreshIngestClientResources() {
|
|
42
|
-
const
|
|
43
|
-
if (!this.ingestClientResources
|
|
44
|
-
|
|
45
|
-
this.ingestClientResourcesLastUpdate + this.refreshPeriod <= now ||
|
|
46
|
-
!this.ingestClientResources.valid()) {
|
|
47
|
-
this.ingestClientResources = await this.getIngestClientResourcesFromService();
|
|
48
|
-
this.ingestClientResourcesLastUpdate = now;
|
|
43
|
+
const error = await this.tryRefresh(false);
|
|
44
|
+
if (!this.ingestClientResources) {
|
|
45
|
+
throw new Error(`Failed to fetch ingestion resources from service. ${error === null || error === void 0 ? void 0 : error.message}.\n ${error === null || error === void 0 ? void 0 : error.stack}`);
|
|
49
46
|
}
|
|
50
47
|
return this.ingestClientResources;
|
|
51
48
|
}
|
|
@@ -56,7 +53,11 @@ class ResourceManager {
|
|
|
56
53
|
const cmd = `.get ingestion resources ${this.isBrowser ? `with (EnableBlobCors='true', EnableQueueCors='true', EnableTableCors='true')` : ""}`;
|
|
57
54
|
const response = await this.kustoClient.execute("NetDefaultDB", cmd);
|
|
58
55
|
const table = response.primaryResults[0];
|
|
59
|
-
|
|
56
|
+
const resoures = new IngestClientResources(this.getResourceByName(table, "SecuredReadyForAggregationQueue"), this.getResourceByName(table, "FailedIngestionsQueue"), this.getResourceByName(table, "SuccessfulIngestionsQueue"), this.getResourceByName(table, "TempStorage"));
|
|
57
|
+
if (!resoures.valid()) {
|
|
58
|
+
throw new Error("Unexpected error occured - fetched data returned missing resource");
|
|
59
|
+
}
|
|
60
|
+
return resoures;
|
|
60
61
|
}
|
|
61
62
|
catch (error) {
|
|
62
63
|
if (!(error instanceof azure_kusto_data_1.KustoDataErrors.ThrottlingError)) {
|
|
@@ -78,16 +79,34 @@ class ResourceManager {
|
|
|
78
79
|
return result;
|
|
79
80
|
}
|
|
80
81
|
async refreshAuthorizationContext() {
|
|
82
|
+
const error = await this.tryRefresh(true);
|
|
83
|
+
if (this.authorizationContext == null) {
|
|
84
|
+
throw new Error(`Failed to fetch Authorization context from service. ${error === null || error === void 0 ? void 0 : error.message}.\n ${error === null || error === void 0 ? void 0 : error.stack}`);
|
|
85
|
+
}
|
|
86
|
+
return this.authorizationContext;
|
|
87
|
+
}
|
|
88
|
+
async tryRefresh(isAuthContextFetch) {
|
|
81
89
|
var _a;
|
|
90
|
+
const resource = isAuthContextFetch ? (_a = this.authorizationContext) === null || _a === void 0 ? void 0 : _a.trim() : this.ingestClientResources;
|
|
91
|
+
const lastRefresh = isAuthContextFetch ? this.authorizationContextLastUpdate : this.ingestClientResourcesLastUpdate;
|
|
82
92
|
const now = Date.now();
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
93
|
+
let error = null;
|
|
94
|
+
if (!resource || !lastRefresh || lastRefresh + this.refreshPeriod <= now) {
|
|
95
|
+
try {
|
|
96
|
+
if (isAuthContextFetch) {
|
|
97
|
+
this.authorizationContext = await this.getAuthorizationContextFromService();
|
|
98
|
+
this.authorizationContextLastUpdate = now;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
this.ingestClientResources = await this.getIngestClientResourcesFromService();
|
|
102
|
+
this.ingestClientResourcesLastUpdate = now;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
error = e;
|
|
88
107
|
}
|
|
89
108
|
}
|
|
90
|
-
return
|
|
109
|
+
return error;
|
|
91
110
|
}
|
|
92
111
|
async getAuthorizationContextFromService() {
|
|
93
112
|
const retry = new retry_1.ExponentialRetry(ATTEMPT_COUNT, this.baseSleepTimeSecs, this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C,CAAC;SAC/C;QACD,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,UAAU,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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../src/retry.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAE3B,MAAM,KAAK,GAAG,CAAC,EAAU,EAAiB,EAAE;IAC/C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAJW,QAAA,KAAK,SAIhB;AAEF,MAAa,gBAAgB;IAGzB,YAAmB,YAAoB,EAAS,aAAqB,EAAS,aAAqB;QAAhF,iBAAY,GAAZ,YAAY,CAAQ;QAAS,kBAAa,GAAb,aAAa,CAAQ;QAAS,kBAAa,GAAb,aAAa,CAAQ;QAC/F,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC;IAC5B,CAAC;IAEM,KAAK,CAAC,OAAO;QAChB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE;YACnB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;SAC3C;QAED,IAAI,CAAC,cAAc,EAAE,CAAC;QAEtB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE;YACnB,6CAA6C;YAC7C,OAAO;SACV;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC;QACvE,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QAC9D,MAAM,IAAA,aAAK,EAAC,IAAI,GAAG,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC;IACxC,CAAC;IAEM,SAAS;QACZ,OAAO,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,YAAY,CAAC;IACnD,CAAC;CACJ;AA3BD,4CA2BC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport const sleep = (ms: number): Promise<void> => {\n return new Promise((resolve) => {\n setTimeout(resolve, ms);\n });\n};\n\nexport class ExponentialRetry {\n public currentAttempt: number;\n\n constructor(public attemptCount: number, public sleepBaseSecs: number, public maxJitterSecs: number) {\n this.currentAttempt = 0;\n }\n\n public async backoff(): Promise<void> {\n if (!this.shouldTry()) {\n throw new Error(\"Max retries exceeded\");\n }\n\n this.currentAttempt++;\n\n if (!this.shouldTry()) {\n // This was the last retry - no need to sleep\n return;\n }\n\n const base = this.sleepBaseSecs * Math.pow(2, this.currentAttempt - 1);\n const jitter = Math.floor(this.maxJitterSecs * Math.random());\n await sleep(1000 * (base + jitter));\n }\n\n public shouldTry(): boolean {\n return this.currentAttempt < this.attemptCount;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/status.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,uCAAwC;AAIxC,MAAa,aAAa;IAStB,YAAY,GAAQ,EAAE,GAAQ,EAAE,UAA2B;QACvD,IAAI,KAAK,GAAa,CAAC,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,gBAAgB,CAAC,CAAC;QAEzH,IAAI,UAAU,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;YACrC,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;SACpC;QAED,MAAM,IAAI,GAAwB,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;QAEhF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACtB,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;SAC3B;IACL,CAAC;CACJ;AAtBD,sCAsBC;AAED,MAAM,cAAe,SAAQ,aAAa;IAGtC,YAAY,GAAQ,EAAE,GAAQ;QAC1B,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IACrC,CAAC;CACJ;AAED,MAAM,cAAe,SAAQ,aAAa;IAOtC,YAAY,GAAQ,EAAE,GAAQ;QAC1B,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,4BAA4B,EAAE,aAAa,CAAC,CAAC,CAAC;IACxH,CAAC;CACJ;AAED,MAAa,uBAAuB;IAGhC,YAAY,iBAAoC;QAC5C,IAAI,CAAC,OAAO,GAAG,IAAI,qBAAW,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,eAAe,CAAC,6BAA6B,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAkB,CAAC,EAAE,cAAc,CAAC,CAAC;QACxJ,IAAI,CAAC,OAAO,GAAG,IAAI,qBAAW,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,eAAe,CAAC,yBAAyB,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAkB,CAAC,EAAE,cAAc,CAAC,CAAC;IACxJ,CAAC;CACJ;AAPD,0DAOC;AAED,kBAAe,uBAAuB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { StatusQueue } from \"./statusQ\";\nimport KustoIngestClient from \"./ingestClient\";\nimport { ResourceURI } from \"./resourceManager\";\n\nexport class StatusMessage {\n OperationId?: string;\n Database?: string;\n Table?: string;\n IngestionSourceId?: string;\n IngestionSourcePath?: string;\n RootActivityId?: string;\n\n [other: string]: any;\n constructor(raw: any, obj: any, extraProps: string[] | null) {\n let props: string[] = [\"OperationId\", \"Database\", \"Table\", \"IngestionSourceId\", \"IngestionSourcePath\", \"RootActivityId\"];\n\n if (extraProps && extraProps.length > 0) {\n props = props.concat(extraProps);\n }\n\n const _obj: Record<string, any> = obj || JSON.parse(raw || JSON.stringify(raw));\n\n for (const prop of props) {\n this[prop] = _obj[prop];\n }\n }\n}\n\nclass SuccessMessage extends StatusMessage {\n SucceededOn?: string;\n\n constructor(raw: any, obj: any) {\n super(raw, obj, [\"SucceededOn\"]);\n }\n}\n\nclass FailureMessage extends StatusMessage {\n FailedOn?: string;\n Details?: string;\n ErrorCode?: string;\n FailureStatus?: string;\n OriginatesFromUpdatePolicy?: string;\n ShouldRetry?: string;\n constructor(raw: any, obj: any) {\n super(raw, obj, [\"FailedOn\", \"Details\", \"ErrorCode\", \"FailureStatus\", \"OriginatesFromUpdatePolicy\", \"ShouldRetry\"]);\n }\n}\n\nexport class KustoIngestStatusQueues {\n success: StatusQueue;\n failure: StatusQueue;\n constructor(kustoIngestClient: KustoIngestClient) {\n this.success = new StatusQueue(() => kustoIngestClient.resourceManager.getSuccessfulIngestionsQueues().then((r) => r as ResourceURI[]), SuccessMessage);\n this.failure = new StatusQueue(() => kustoIngestClient.resourceManager.getFailedIngestionsQueues().then((r) => r as ResourceURI[]), FailureMessage);\n }\n}\n\nexport default KustoIngestStatusQueues;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statusQ.js","sourceRoot":"","sources":["../../src/statusQ.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,wDAAsE;AAItE,MAAM,YAAY;IACd,YAAqB,IAAY,EAAW,OAAoB;QAA3C,SAAI,GAAJ,IAAI,CAAQ;QAAW,YAAO,GAAP,OAAO,CAAa;IAAG,CAAC;CACvE;AAED,MAAM,OAAO,GAAG,CAAI,CAAM,EAAO,EAAE;IAC/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,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAC1D,IAAI,OAAO,CAAC,IAAI,EAAE;YACd,OAAO,OAAO,CAAC,MAAM,CAAC;SACzB;QAED,MAAM,iBAAiB,GAAG,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;QAEpD,2FAA2F;QAC3F,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,MAAA,OAAO,CAAC,MAAM,CAAC,UAAU,mCAAI,EAAE,EAAE,iBAAiB,EAAE,OAAO,CAAC,CAAC;QAC3F,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;CACJ;AApHD,kCAoHC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { PeekedMessageItem, QueueClient } from \"@azure/storage-queue\";\nimport { ResourceURI } from \"./resourceManager\";\nimport { StatusMessage } from \"./status\";\n\nclass QueueDetails {\n constructor(readonly name: string, readonly service: QueueClient) {}\n}\n\nconst shuffle = <T>(a: T[]): T[] => {\n for (let i = a.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n const temp = a[j];\n a[j] = a[i];\n a[i] = temp;\n }\n\n return a;\n};\n\ninterface PeekParams {\n raw: boolean;\n}\n\ninterface PopParams {\n raw: boolean;\n remove: boolean;\n}\n\ntype Message = PeekedMessageItem | StatusMessage;\n\nexport class StatusQueue {\n constructor(readonly getQueuesFunc: () => Promise<ResourceURI[]>, readonly messageCls: typeof StatusMessage) {}\n\n _getQServices(queuesDetails: ResourceURI[]) {\n return queuesDetails.map((q) => {\n const fullUri = q.uri;\n if (!fullUri) {\n throw new Error(\"Empty or null connection string\");\n }\n // chop off sas\n const indexOfSas = q.uri.indexOf(\"?\");\n const name = indexOfSas > 0 ? q.uri.substring(0, indexOfSas) : q.uri;\n return new QueueDetails(name, new QueueClient(fullUri));\n });\n }\n\n async isEmpty() {\n const result = await this.peek(1, { raw: true });\n return !result || result.length === 0;\n }\n\n decodeContent(content: string) {\n return Buffer.from(content, \"base64\").toString(\"ascii\");\n }\n\n deserializeMessage(m: PeekedMessageItem): StatusMessage {\n return new this.messageCls(this.decodeContent(m.messageText), null, null);\n }\n\n async _peek(qs: QueueDetails[], n: number, options: PeekParams | null): Promise<{ result: Message[]; nonEmptyQs: QueueDetails[]; done: boolean }> {\n const result: Message[] = [];\n const nonEmptyQs: QueueDetails[] = [];\n\n for (const q of qs) {\n const response = await q.service.peekMessages();\n const messages = response.peekedMessageItems;\n\n if (messages && messages.length > 0) {\n nonEmptyQs.push(q);\n }\n\n for (const m of messages) {\n if (m && Object.keys(m).length > 0) {\n result.push(options && options.raw ? m : this.deserializeMessage(m));\n\n if (result.length === n) {\n return { done: true, nonEmptyQs, result };\n }\n }\n }\n }\n return { done: nonEmptyQs.length === 0, nonEmptyQs, result };\n }\n\n async peek(n = 1, options: PeekParams | null = null): Promise<Message[]> {\n const queues = await this.getQueuesFunc();\n const qServices: QueueDetails[] = shuffle(this._getQServices(queues));\n const perQ = qServices.length > 1 ? Math.floor(n / qServices.length) : qServices.length;\n\n // First, iterate evenly and randomly on status queues\n const partial = await this._peek(qServices, perQ, options);\n\n if (partial.done) {\n return partial.result;\n }\n const messagesLeftToPeek = n - partial.result.length;\n\n // In case queues are uneven, iterate again. This time, request for all n messages and trim\n return (await this._peek(partial.nonEmptyQs, messagesLeftToPeek, options)).result;\n }\n\n async _pop(\n qs: QueueDetails[],\n n: number,\n options: PopParams | null\n ): Promise<{ result: Message[] & { nonEmptyQs?: QueueDetails[] }; nonEmptyQs: any[]; done: boolean }> {\n const nonEmptyQs: any[] = [];\n const result = [];\n\n for (const q of qs) {\n const response = await q.service.receiveMessages({ numOfMessages: n });\n const messages = response.receivedMessageItems;\n for (const m of messages) {\n if (m && Object.keys(m).length > 0) {\n result.push(options && options.raw ? m : this.deserializeMessage(m));\n\n if (!(options && !options.remove)) {\n await q.service.deleteMessage(m.messageId, m.popReceipt);\n }\n if (result.length === n) {\n return { done: true, nonEmptyQs, result };\n }\n }\n }\n }\n\n return { done: nonEmptyQs.length === 0, nonEmptyQs, result };\n }\n\n async pop(n = 1, options: PopParams | null = null): Promise<Message[]> {\n const queues = await this.getQueuesFunc();\n const qServices = shuffle(this._getQServices(queues));\n const perQ = qServices.length > 1 ? Math.floor(n / qServices.length) : qServices.length;\n\n // First, iterate evenly and randomly on status queues\n const partial = await this._pop(qServices, perQ, options);\n if (partial.done) {\n return partial.result;\n }\n\n const messagesLeftToPop = n - partial.result.length;\n\n // In case queues are uneven, iterate again. This time, request for all n messages and trim\n const final = await this._pop(partial.result.nonEmptyQs ?? [], messagesLeftToPop, options);\n return partial.result.concat(final.result);\n }\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright (c) Microsoft Corporation.
|
|
3
3
|
// Licensed under the MIT License.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.tryStreamToArray = exports.tryFileToBuffer = exports.fileToStream = void 0;
|
|
5
|
+
exports.readableToStream = exports.tryStreamToArray = exports.tryFileToBuffer = exports.fileToStream = void 0;
|
|
6
6
|
const descriptors_1 = require("./descriptors");
|
|
7
7
|
const fileToStream = async (file) => {
|
|
8
8
|
const streamFs = await file.file.arrayBuffer();
|
|
@@ -19,4 +19,9 @@ const tryStreamToArray = async (stream) => {
|
|
|
19
19
|
return Promise.resolve(stream);
|
|
20
20
|
};
|
|
21
21
|
exports.tryStreamToArray = tryStreamToArray;
|
|
22
|
+
// NOT USED
|
|
23
|
+
const readableToStream = (stream) => {
|
|
24
|
+
return stream;
|
|
25
|
+
};
|
|
26
|
+
exports.readableToStream = readableToStream;
|
|
22
27
|
//# sourceMappingURL=streamUtils.browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streamUtils.browser.js","sourceRoot":"","sources":["../../src/streamUtils.browser.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,+CAAkE;AAG3D,MAAM,YAAY,GAAG,KAAK,EAAE,IAAoB,EAA6B,EAAE;IAClF,MAAM,QAAQ,GAAG,MAAO,IAAI,CAAC,IAAa,CAAC,WAAW,EAAE,CAAC;IACzD,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,6BAAe,CAAC,IAAI,CAAC,CAAC,CAAC,6BAAe,CAAC,IAAI,CAAC;IAClF,OAAO,IAAI,8BAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;AAC1E,CAAC,CAAC;AAJW,QAAA,YAAY,gBAIvB;AAEK,MAAM,eAAe,GAAG,KAAK,EAAE,IAAoB,EAA6B,EAAE;IACrF,OAAO,MAAM,IAAA,oBAAY,EAAC,IAAI,CAAC,CAAC;AACpC,CAAC,CAAC;AAFW,QAAA,eAAe,mBAE1B;AAEF,WAAW;AACJ,MAAM,gBAAgB,GAAG,KAAK,EAAE,MAAW,EAAmB,EAAE;IACnE,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AACnC,CAAC,CAAC;AAFW,QAAA,gBAAgB,oBAE3B;AAEF,WAAW;AACJ,MAAM,gBAAgB,GAAG,CAAC,MAAmB,EAAe,EAAE;IACjE,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAFW,QAAA,gBAAgB,oBAE3B","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { CompressionType, StreamDescriptor } from \"./descriptors\";\nimport { FileDescriptor } from \"./fileDescriptor.browser\";\n\nexport const fileToStream = async (file: FileDescriptor): Promise<StreamDescriptor> => {\n const streamFs = await (file.file as Blob).arrayBuffer();\n const compressionType = file.zipped ? CompressionType.GZIP : CompressionType.None;\n return new StreamDescriptor(streamFs, file.sourceId, compressionType);\n};\n\nexport const tryFileToBuffer = async (file: FileDescriptor): Promise<StreamDescriptor> => {\n return await fileToStream(file);\n};\n\n// NOT USED\nexport const tryStreamToArray = async (stream: any): Promise<Buffer> => {\n return Promise.resolve(stream);\n};\n\n// NOT USED\nexport const readableToStream = (stream: ArrayBuffer): ArrayBuffer => {\n return stream;\n};\n"]}
|
|
@@ -5,11 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
6
|
};
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.tryStreamToArray = exports.tryFileToBuffer = exports.fileToStream = void 0;
|
|
9
|
-
const descriptors_1 = require("./descriptors");
|
|
8
|
+
exports.readableToStream = exports.tryStreamToArray = exports.tryFileToBuffer = exports.fileToStream = void 0;
|
|
10
9
|
const fs_1 = __importDefault(require("fs"));
|
|
11
10
|
const stream_1 = require("stream");
|
|
12
11
|
const stream_array_1 = __importDefault(require("stream-array"));
|
|
12
|
+
const descriptors_1 = require("./descriptors");
|
|
13
13
|
// Returns fs.ReadStream for node and NodeJS.ReadableStream in browser
|
|
14
14
|
const fileToStream = (fileDescriptor) => {
|
|
15
15
|
const streamFs = fs_1.default.createReadStream(fileDescriptor.file);
|
|
@@ -63,4 +63,8 @@ const tryStreamToArray = async (stream, maxBufferSize) => {
|
|
|
63
63
|
});
|
|
64
64
|
};
|
|
65
65
|
exports.tryStreamToArray = tryStreamToArray;
|
|
66
|
+
const readableToStream = (stream) => {
|
|
67
|
+
return (0, stream_array_1.default)([stream]);
|
|
68
|
+
};
|
|
69
|
+
exports.readableToStream = readableToStream;
|
|
66
70
|
//# sourceMappingURL=streamUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streamUtils.js","sourceRoot":"","sources":["../../src/streamUtils.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;AAElC,4CAAoB;AACpB,mCAA+C;AAC/C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AAK,EAAE,WAAW,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAtBW,QAAA,gBAAgB,oBAsB3B;AAEK,MAAM,gBAAgB,GAAG,CAAC,MAA8B,EAAY,EAAE;IACzE,OAAO,IAAA,sBAAS,EAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAC/B,CAAC,CAAC;AAFW,QAAA,gBAAgB,oBAE3B","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport fs from \"fs\";\nimport { PassThrough, Readable } from \"stream\";\nimport streamify from \"stream-array\";\nimport { CompressionType, StreamDescriptor } from \"./descriptors\";\nimport { FileDescriptor } from \"./fileDescriptor\";\n\n// Returns fs.ReadStream for node and NodeJS.ReadableStream in browser\nexport const fileToStream = (fileDescriptor: FileDescriptor): Promise<StreamDescriptor> => {\n const streamFs = fs.createReadStream(fileDescriptor.file as string);\n const compressionType = fileDescriptor.zipped ? CompressionType.GZIP : CompressionType.None;\n return Promise.resolve(new StreamDescriptor(streamFs, fileDescriptor.sourceId, compressionType));\n};\n\n// Used in managed streaming where we buffer the file to memory for retries\nexport const tryFileToBuffer = async (fileDescriptor: FileDescriptor): Promise<StreamDescriptor> => {\n try {\n const buffer = fs.readFileSync(fileDescriptor.file as string);\n const compressionType = fileDescriptor.zipped ? CompressionType.GZIP : CompressionType.None;\n return new StreamDescriptor(buffer, fileDescriptor.sourceId, compressionType);\n } catch (error) {\n return await fileToStream(fileDescriptor);\n }\n};\n\nconst mergeStreams = (...streams: Readable[]): Readable => {\n let pass = new PassThrough();\n let waiting = streams.length;\n for (const stream of streams) {\n pass = stream.pipe(pass, { end: false });\n stream.once(\"end\", () => --waiting === 0 && pass.emit(\"end\"));\n }\n return pass;\n};\n\nexport const tryStreamToArray = async (stream: Readable, maxBufferSize: number): Promise<Buffer | Readable> => {\n if (stream instanceof Buffer) {\n return stream;\n }\n return await new Promise<Buffer | Readable>((resolve, reject) => {\n const result: Buffer[] = [];\n const endListener = () => resolve(Buffer.concat(result));\n const dataHandler = (chunk: Buffer) => {\n try {\n result.push(chunk);\n if (result.reduce((sum, b) => sum + b.length, 0) > maxBufferSize) {\n stream.removeListener(\"data\", dataHandler);\n stream.removeListener(\"end\", endListener);\n resolve(mergeStreams(streamify(result), stream));\n }\n } catch (e) {\n reject(e);\n }\n };\n stream.on(\"data\", dataHandler);\n stream.on(\"end\", endListener);\n });\n};\n\nexport const readableToStream = (stream: Readable | ArrayBuffer): Readable => {\n return streamify([stream]);\n};\n"]}
|
|
@@ -4,14 +4,11 @@
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
const descriptors_1 = require("./descriptors");
|
|
6
6
|
const fileDescriptor_browser_1 = require("./fileDescriptor.browser");
|
|
7
|
-
const abstractKustoClient_1 = require("./abstractKustoClient");
|
|
8
|
-
const azure_kusto_data_1 = require("azure-kusto-data");
|
|
9
7
|
const streamUtils_browser_1 = require("./streamUtils.browser");
|
|
10
|
-
|
|
8
|
+
const streamingIngestClientBase_1 = require("./streamingIngestClientBase");
|
|
9
|
+
class KustoStreamingIngestClient extends streamingIngestClientBase_1.KustoStreamingIngestClientBase {
|
|
11
10
|
constructor(kcsb, defaultProps) {
|
|
12
|
-
super(defaultProps);
|
|
13
|
-
this.kustoClient = new azure_kusto_data_1.Client(kcsb);
|
|
14
|
-
this.defaultDatabase = this.kustoClient.defaultDatabase;
|
|
11
|
+
super(kcsb, defaultProps);
|
|
15
12
|
}
|
|
16
13
|
/**
|
|
17
14
|
* Use Readable for Node.js and ArrayBuffer in browser
|
|
@@ -31,12 +28,6 @@ class KustoStreamingIngestClient extends abstractKustoClient_1.AbstractKustoClie
|
|
|
31
28
|
const descriptor = file instanceof fileDescriptor_browser_1.FileDescriptor ? file : new fileDescriptor_browser_1.FileDescriptor(file);
|
|
32
29
|
return this.ingestFromStream(await (0, streamUtils_browser_1.tryFileToBuffer)(descriptor), ingestionProperties);
|
|
33
30
|
}
|
|
34
|
-
close() {
|
|
35
|
-
if (!this._isClosed) {
|
|
36
|
-
this.kustoClient.close();
|
|
37
|
-
}
|
|
38
|
-
super.close();
|
|
39
|
-
}
|
|
40
31
|
}
|
|
41
32
|
exports.default = KustoStreamingIngestClient;
|
|
42
33
|
//# sourceMappingURL=streamingIngestClient.browser.js.map
|
|
@@ -0,0 +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;QAC5F,KAAK,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAC9B,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) {\n super(kcsb, defaultProps);\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"]}
|
|
@@ -5,17 +5,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
6
|
};
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
const zlib_1 = __importDefault(require("zlib"));
|
|
8
9
|
const descriptors_1 = require("./descriptors");
|
|
9
10
|
const fileDescriptor_1 = require("./fileDescriptor");
|
|
10
|
-
const zlib_1 = __importDefault(require("zlib"));
|
|
11
|
-
const abstractKustoClient_1 = require("./abstractKustoClient");
|
|
12
|
-
const azure_kusto_data_1 = require("azure-kusto-data");
|
|
13
11
|
const streamUtils_1 = require("./streamUtils");
|
|
14
|
-
|
|
12
|
+
const streamingIngestClientBase_1 = require("./streamingIngestClientBase");
|
|
13
|
+
class KustoStreamingIngestClient extends streamingIngestClientBase_1.KustoStreamingIngestClientBase {
|
|
15
14
|
constructor(kcsb, defaultProps) {
|
|
16
|
-
super(defaultProps);
|
|
17
|
-
this.kustoClient = new azure_kusto_data_1.Client(kcsb);
|
|
18
|
-
this.defaultDatabase = this.kustoClient.defaultDatabase;
|
|
15
|
+
super(kcsb, defaultProps);
|
|
19
16
|
}
|
|
20
17
|
/**
|
|
21
18
|
* Use Readable for Node.js and ArrayBuffer in browser
|
|
@@ -40,12 +37,6 @@ class KustoStreamingIngestClient extends abstractKustoClient_1.AbstractKustoClie
|
|
|
40
37
|
const descriptor = file instanceof fileDescriptor_1.FileDescriptor ? file : new fileDescriptor_1.FileDescriptor(file);
|
|
41
38
|
return this.ingestFromStream(await (0, streamUtils_1.fileToStream)(descriptor), ingestionProperties);
|
|
42
39
|
}
|
|
43
|
-
close() {
|
|
44
|
-
if (!this._isClosed) {
|
|
45
|
-
this.kustoClient.close();
|
|
46
|
-
}
|
|
47
|
-
super.close();
|
|
48
|
-
}
|
|
49
40
|
}
|
|
50
41
|
exports.default = KustoStreamingIngestClient;
|
|
51
42
|
//# sourceMappingURL=streamingIngestClient.js.map
|
|
@@ -0,0 +1 @@
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G,IAAI,CAAC,UAAU,EAAE,CAAC;QAElB,MAAM,UAAU,GAAmB,IAAI,YAAY,+BAAc,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,+BAAc,CAAC,IAAI,CAAC,CAAC;QACpG,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,IAAA,0BAAY,EAAC,UAAU,CAAC,EAAE,mBAAmB,CAAC,CAAC;IACtF,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 { 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) {\n super(kcsb, defaultProps);\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"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.KustoStreamingIngestClientBase = void 0;
|
|
6
|
+
const descriptors_1 = require("./descriptors");
|
|
7
|
+
const abstractKustoClient_1 = require("./abstractKustoClient");
|
|
8
|
+
const azure_kusto_data_1 = require("azure-kusto-data");
|
|
9
|
+
class KustoStreamingIngestClientBase extends abstractKustoClient_1.AbstractKustoClient {
|
|
10
|
+
constructor(kcsb, defaultProps) {
|
|
11
|
+
super(defaultProps);
|
|
12
|
+
this.kustoClient = new azure_kusto_data_1.Client(kcsb);
|
|
13
|
+
this.defaultDatabase = this.kustoClient.defaultDatabase;
|
|
14
|
+
}
|
|
15
|
+
async ingestFromBlob(blob, ingestionProperties, clientRequestId) {
|
|
16
|
+
var _a;
|
|
17
|
+
const props = this._getMergedProps(ingestionProperties);
|
|
18
|
+
const descriptor = blob instanceof descriptors_1.BlobDescriptor ? blob : new descriptors_1.BlobDescriptor(blob);
|
|
19
|
+
// No need to check blob size if it was given to us that it's not empty
|
|
20
|
+
await descriptor.fillSize();
|
|
21
|
+
return await this.kustoClient.executeStreamingIngest(props.database, props.table, undefined, props.format, (_a = props.ingestionMappingReference) !== null && _a !== void 0 ? _a : null, descriptor.path, clientRequestId);
|
|
22
|
+
}
|
|
23
|
+
close() {
|
|
24
|
+
if (!this._isClosed) {
|
|
25
|
+
this.kustoClient.close();
|
|
26
|
+
}
|
|
27
|
+
super.close();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.KustoStreamingIngestClientBase = KustoStreamingIngestClientBase;
|
|
31
|
+
//# sourceMappingURL=streamingIngestClientBase.js.map
|
|
@@ -0,0 +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;QAC5F,KAAK,CAAC,YAAY,CAAC,CAAC;QACpB,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;AA/BD,wEA+BC","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) {\n super(defaultProps);\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": "5.0
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "Azure Data Explorer Ingestion SDK",
|
|
5
5
|
"module": "dist-esm/src/index.js",
|
|
6
6
|
"types": "./types/src/index.d.ts",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"directory": "azure-kusto-ingest"
|
|
32
32
|
},
|
|
33
33
|
"files": [
|
|
34
|
+
"dist-esm/src/*.js.map",
|
|
34
35
|
"dist-esm/src/*.js",
|
|
35
36
|
"types/src/*.d.ts",
|
|
36
37
|
"tsconfig.tsbuildinfo"
|
|
@@ -61,8 +62,9 @@
|
|
|
61
62
|
"@types/tmp": "^0.2.3",
|
|
62
63
|
"@types/uuid": "^8.3.4",
|
|
63
64
|
"@types/uuid-validate": "0.0.1",
|
|
64
|
-
"azure-kusto-data": "^5.0
|
|
65
|
+
"azure-kusto-data": "^5.2.0",
|
|
65
66
|
"browserify-zlib": "0.2.0",
|
|
67
|
+
"buffer": "^6.0.3",
|
|
66
68
|
"stream-array": "^1.1.2",
|
|
67
69
|
"stream-browserify": "3.0.0",
|
|
68
70
|
"stream-to-array": "^2.3.0",
|
|
@@ -74,5 +76,5 @@
|
|
|
74
76
|
"@types/sinon": "^10.0.13",
|
|
75
77
|
"assert": "^2.0.0"
|
|
76
78
|
},
|
|
77
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "0d653678b2a70173739b6b140fc3a6e9e3b8bd78"
|
|
78
80
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IngestionProperties, IngestionPropertiesInput } from "./ingestionProperties";
|
|
2
|
-
import { StreamDescriptor, FileDescriptorBase } from "./descriptors";
|
|
2
|
+
import { StreamDescriptor, FileDescriptorBase, BlobDescriptor } from "./descriptors";
|
|
3
3
|
export declare abstract class AbstractKustoClient {
|
|
4
4
|
defaultProps: IngestionProperties;
|
|
5
5
|
defaultDatabase?: string;
|
|
@@ -8,6 +8,7 @@ export declare abstract class AbstractKustoClient {
|
|
|
8
8
|
_getMergedProps(newProperties?: IngestionPropertiesInput): IngestionProperties;
|
|
9
9
|
abstract ingestFromStream(stream: StreamDescriptor, ingestionProperties: IngestionPropertiesInput): Promise<any>;
|
|
10
10
|
abstract ingestFromFile(file: FileDescriptorBase | string | Blob, ingestionProperties: IngestionPropertiesInput): Promise<any>;
|
|
11
|
+
abstract ingestFromBlob(blob: string | BlobDescriptor, ingestionProperties?: IngestionPropertiesInput): Promise<any>;
|
|
11
12
|
close(): void;
|
|
12
13
|
protected ensureOpen(): void;
|
|
13
14
|
}
|
|
@@ -7,23 +7,25 @@ export declare enum CompressionType {
|
|
|
7
7
|
None = ""
|
|
8
8
|
}
|
|
9
9
|
export declare const getSourceId: (sourceId: string | null) => string;
|
|
10
|
-
export declare class
|
|
11
|
-
|
|
10
|
+
export declare abstract class AbstractDescriptor {
|
|
11
|
+
sourceId: string | null;
|
|
12
12
|
size: number | null;
|
|
13
|
+
constructor(sourceId?: string | null, size?: number | null);
|
|
14
|
+
}
|
|
15
|
+
export declare class StreamDescriptor extends AbstractDescriptor {
|
|
16
|
+
readonly stream: Readable | ArrayBuffer;
|
|
13
17
|
compressionType: CompressionType;
|
|
14
|
-
sourceId: string;
|
|
15
18
|
/**
|
|
16
19
|
* Use Readable for Node.js and ArrayBuffer in browser
|
|
17
20
|
*/
|
|
18
|
-
constructor(stream: Readable | ArrayBuffer, sourceId?: string | null, compressionType?: CompressionType);
|
|
21
|
+
constructor(stream: Readable | ArrayBuffer, sourceId?: string | null, compressionType?: CompressionType, size?: number | null);
|
|
19
22
|
merge(other: StreamDescriptor): this;
|
|
20
23
|
getCompressionSuffix(): string;
|
|
21
24
|
}
|
|
22
|
-
export declare class BlobDescriptor {
|
|
25
|
+
export declare class BlobDescriptor extends AbstractDescriptor {
|
|
23
26
|
readonly path: string;
|
|
24
|
-
size: number | null;
|
|
25
|
-
sourceId: string;
|
|
26
27
|
constructor(path: string, size?: number | null, sourceId?: string | null);
|
|
28
|
+
fillSize(): Promise<void>;
|
|
27
29
|
}
|
|
28
30
|
export interface FileDescriptorBase {
|
|
29
31
|
size: number | null;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { CompressionType, FileDescriptorBase } from "./descriptors";
|
|
2
|
-
export declare class FileDescriptor implements FileDescriptorBase {
|
|
1
|
+
import { AbstractDescriptor, CompressionType, FileDescriptorBase } from "./descriptors";
|
|
2
|
+
export declare class FileDescriptor extends AbstractDescriptor implements FileDescriptorBase {
|
|
3
3
|
readonly file: Blob;
|
|
4
|
-
readonly sourceId: string | null;
|
|
5
4
|
readonly extension?: string | undefined;
|
|
6
5
|
readonly name?: string | undefined;
|
|
7
6
|
size: number | null;
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import { CompressionType, FileDescriptorBase } from "./descriptors";
|
|
1
|
+
import { AbstractDescriptor, CompressionType, FileDescriptorBase } from "./descriptors";
|
|
2
2
|
/**
|
|
3
3
|
* Describes a file to be ingested. Use string to describe a local path in Node.JS and Blob object in browsers
|
|
4
4
|
*/
|
|
5
|
-
export declare class FileDescriptor implements FileDescriptorBase {
|
|
5
|
+
export declare class FileDescriptor extends AbstractDescriptor implements FileDescriptorBase {
|
|
6
6
|
/**
|
|
7
7
|
* Use string in Node.JS and Blob in browser
|
|
8
8
|
*/
|
|
9
9
|
readonly file: string | Blob;
|
|
10
10
|
readonly extension?: string | undefined;
|
|
11
11
|
readonly name?: string | undefined;
|
|
12
|
-
size: number | null;
|
|
13
12
|
zipped: boolean;
|
|
14
13
|
compressionType: CompressionType;
|
|
15
14
|
cleanupTmp?: () => Promise<void>;
|
|
16
|
-
sourceId: string;
|
|
17
15
|
constructor(
|
|
18
16
|
/**
|
|
19
17
|
* Use string in Node.JS and Blob in browser
|