azure-kusto-ingest
Version:
Azure Data Explorer Ingestion SDK
31 lines • 1.56 kB
JavaScript
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { StreamDescriptor } from "./descriptors.js";
import { FileDescriptor } from "./fileDescriptor.browser.js";
import { tryFileToBuffer } from "./streamUtils.browser.js";
import { KustoStreamingIngestClientBase } from "./streamingIngestClientBase.js";
class KustoStreamingIngestClient extends KustoStreamingIngestClientBase {
constructor(kcsb, defaultProps, autoCorrectEndpoint) {
super(kcsb, defaultProps, autoCorrectEndpoint);
}
/**
* Use Readable for Node.js and ArrayBuffer in browser
*/
async ingestFromStream(stream, ingestionProperties, clientRequestId) {
var _a;
this.ensureOpen();
const props = this._getMergedProps(ingestionProperties);
const descriptor = stream instanceof StreamDescriptor ? stream : new StreamDescriptor(stream);
return await this.kustoClient.executeStreamingIngest(props.database, props.table, descriptor.stream, props.format, (_a = props.ingestionMappingReference) !== null && _a !== void 0 ? _a : null, undefined, clientRequestId);
}
/**
* Use string for Node.js and Blob in browser
*/
async ingestFromFile(file, ingestionProperties) {
this.ensureOpen();
const descriptor = file instanceof FileDescriptor ? file : new FileDescriptor(file);
return this.ingestFromStream(await tryFileToBuffer(descriptor), ingestionProperties);
}
}
export default KustoStreamingIngestClient;
//# sourceMappingURL=streamingIngestClient.browser.js.map