QueryHost
Esc

Documentation menu

API reference · functions

Function: queryMany()

Generated from the QueryHost package public TypeScript contract.

queryMany<G>(inputs, options?): AsyncGenerator<QueryManyEntry<G>, void, undefined>

Queries many game servers with bounded concurrency, yielding each result as it settles.

Entries arrive in completion order; index gives each input's position. Every input started yields exactly one entry, and a failed target is a QueryFailure entry rather than a rejected batch. Inputs are read lazily, and no query starts until iteration begins. Stopping iteration early cancels the queries still in flight and waits for their cleanup.

Type Parameters

G

G extends GameInputId

Parameters

inputs

Iterable<QueryInput<G>>

options?

QueryManyOptions

Returns

AsyncGenerator<QueryManyEntry<G>, void, undefined>

Throws

TypeError or RangeError, synchronously, when inputs is not iterable or options is invalid. Invalid individual inputs resolve as INVALID_INPUT entries instead.

Example

for await (const { input, result } of queryMany(servers, { concurrency: 4 })) {
  console.log(input.host, result.ok ? result.server.players : result.error.code);
}