in packages/azure-kusto-ingest/src/statusQ.ts [94:109]
async peek(n = 1, options: PeekParams | null = null): Promise<Message[]> {
const queues = await this.getQueuesFunc();
const qServices: QueueDetails[] = shuffle(this._getQServices(queues));
const perQ = qServices.length > 1 ? Math.floor(n / qServices.length) : qServices.length;
// First, iterate evenly and randomly on status queues
const partial = await this._peek(qServices, perQ, options);
if (partial.done) {
return partial.result;
}
const messagesLeftToPeek = n - partial.result.length;
// In case queues are uneven, iterate again. This time, request for all n messages and trim
return (await this._peek(partial.nonEmptyQs, messagesLeftToPeek, options)).result;
}