UNPKG

agentfootprint

Version:

The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.

25 lines • 1.12 kB
/** * hosting/signin/checkGate — a door-wide cap on concurrent password checks. * * A password check is slow on purpose (scrypt holds 128 MiB and a thread for a * sizeable fraction of a second; a directory bind is a network round trip). An * unauthenticated burst of parallel logins would otherwise queue hundreds of * them and starve the process's shared thread pool — file I/O, DNS, zlib — for * everybody. So at most `concurrent` checks run at once, at most `queue` wait, * and anything beyond is refused at once (503 with `Retry-After`). */ export interface CheckGateOptions { /** Checks running at once. Default 4. */ readonly concurrent?: number; /** Checks waiting for a slot. Default 32. */ readonly queue?: number; } export interface CheckGate { /** Run `check` when a slot is free; `undefined` when the queue is already full. */ run<T>(check: () => Promise<T>): Promise<{ readonly value: T; } | undefined>; readonly concurrent: number; } export declare function checkGate(options?: CheckGateOptions): CheckGate; //# sourceMappingURL=checkGate.d.ts.map