async getIngestClientResourcesFromService()

in packages/azure-kusto-ingest/src/resourceManager.ts [79:107]


    async getIngestClientResourcesFromService(): Promise<IngestClientResources> {
        const retry = new ExponentialRetry(ATTEMPT_COUNT, this.baseSleepTimeSecs, this.baseJitterSecs);
        while (retry.shouldTry()) {
            try {
                const cmd = `.get ingestion resources ${this.isBrowser ? `with (EnableBlobCors='true', EnableQueueCors='true', EnableTableCors='true')` : ""}`;
                const response = await this.kustoClient.execute("NetDefaultDB", cmd);
                const table = response.primaryResults[0];
                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),
                );

                if (!resoures.valid()) {
                    throw new Error("Unexpected error occured - fetched data returned missing resource");
                }

                return resoures;
            } catch (error: unknown) {
                if (!(error instanceof KustoDataErrors.ThrottlingError)) {
                    throw error;
                }
                await retry.backoff();
            }
        }
        throw new Error(`Failed to get ingestion resources from server - the request was throttled ${ATTEMPT_COUNT} times.`);
    }