This commit is contained in:
Amit Shalev 2021-05-23 17:24:49 +03:00 коммит произвёл GitHub
Родитель 42f34d337b
Коммит 6f77491404
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
6 изменённых файлов: 36 добавлений и 13 удалений

2
azure-kusto-data/package-lock.json сгенерированный
Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "azure-kusto-data",
"version": "2.1.5",
"version": "2.1.6",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "azure-kusto-data",
"version": "2.1.5",
"version": "2.1.6",
"description": "Azure Data Explorer Query SDK",
"main": "index.js",
"types": "index.d.ts",

Просмотреть файл

@ -8,7 +8,9 @@ import {KustoResponseDataSet, KustoResponseDataSetV1, KustoResponseDataSetV2} fr
import ConnectionStringBuilder from "./connectionBuilder";
import ClientRequestProperties from "./clientRequestProperties";
import pkg from "../package.json";
import axios from "axios";
import axios, { AxiosInstance } from "axios";
import http from "http";
import https from "https";
const COMMAND_TIMEOUT_IN_MILLISECS = moment.duration(10.5, "minutes").asMilliseconds();
const QUERY_TIMEOUT_IN_MILLISECS = moment.duration(4.5, "minutes").asMilliseconds();
@ -27,7 +29,7 @@ export class KustoClient {
cluster: string;
endpoints: { [key in ExecutionType] : string; };
aadHelper: AadHelper;
headers: { [name: string]: string };
axiosInstance: AxiosInstance;
constructor(kcsb: string | ConnectionStringBuilder) {
this.connectionString = typeof (kcsb) === "string" ? new ConnectionStringBuilder(kcsb) : kcsb;
@ -39,11 +41,20 @@ export class KustoClient {
[ExecutionType.QueryV1]: `${this.cluster}/v1/rest/query`,
};
this.aadHelper = new AadHelper(this.connectionString);
this.headers = {
const headers = {
"Accept": "application/json",
"Accept-Encoding": "gzip,deflate",
"x-ms-client-version": `Kusto.Node.Client:${pkg.version}`,
"Connection": "Keep-Alive",
};
this.axiosInstance = axios.create({
headers,
validateStatus: (status: number) => status == 200,
// keepAlive pools and reuses TCP connections, so it's faster
httpAgent: new http.Agent({ keepAlive: true }),
httpsAgent: new https.Agent({ keepAlive: true }),
})
}
async execute(db: string, query: string, properties?: ClientRequestProperties) {
@ -84,7 +95,6 @@ export class KustoClient {
stream: string | null,
properties?: ClientRequestProperties | null): Promise<KustoResponseDataSet> {
const headers: { [header: string]: string } = {};
Object.assign(headers, this.headers);
let payload: { db: string, csl: string, properties?: any };
let clientRequestPrefix = "";
@ -128,13 +138,12 @@ export class KustoClient {
properties?: ClientRequestProperties | null): Promise<KustoResponseDataSet> {
const axiosConfig = {
headers,
gzip: true,
timeout
timeout,
};
let axiosResponse;
try {
axiosResponse = await axios.post(endpoint, payload, axiosConfig);
axiosResponse = await this.axiosInstance.post(endpoint, payload, axiosConfig);
} catch (error) {
if (error.response) {
throw error.response.data.error;

2
azure-kusto-ingest/package-lock.json сгенерированный
Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "azure-kusto-ingest",
"version": "2.1.5",
"version": "2.1.6",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "azure-kusto-ingest",
"version": "2.1.5",
"version": "2.1.6",
"description": "Azure Data Explorer Ingestion SDK",
"main": "index.js",
"types": "index.d.ts",

Просмотреть файл

@ -7,7 +7,8 @@ import IngestClient from "../../source/ingestClient";
import KustoIngestStatusQueues from "../../source/status";
import {
Client,
KustoConnectionStringBuilder as ConnectionStringBuilder
KustoConnectionStringBuilder as ConnectionStringBuilder,
ClientRequestProperties,
// @ts-ignore
} from "../.././node_modules/azure-kusto-data";
import StreamingIngestClient from "../../source/streamingIngestClient";
@ -20,7 +21,7 @@ const appKey = process.env.APP_KEY;
const tenantId = process.env.TENANT_ID;
function main(): void {
if (!databaseName || !appId || !appKey || !tenantId) {
process.stdout.write("Skip E2E test - Missing env variables");
return;
@ -221,6 +222,19 @@ function main(): void {
}
assert.fail(`Didn't throw PartialQueryFailure`);
});
it('executionTimeout', async function () {
try {
var properties = new ClientRequestProperties();
properties.setTimeout(10);
await queryClient.executeQuery(databaseName, `${tableName}`, properties);
} catch (ex) {
assert.equal(ex.code, 'Request execution timeout');
return;
}
assert.fail(`Didn't throw executionTimeout`);
});
});
});