KeyPool
Defined in: core/src/key-pool.ts:83
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new KeyPool(label, opts): KeyPool;Defined in: core/src/key-pool.ts:91
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
label |
string |
opts |
KeyPoolOptions |
Returns
Section titled “Returns”KeyPool
Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get size(): number;Defined in: core/src/key-pool.ts:106
Returns
Section titled “Returns”number
Methods
Section titled “Methods”status()
Section titled “status()”status(): object[];Defined in: core/src/key-pool.ts:113
Each key’s tier and when it is back (0 = serving now): free keys in config order, then the paid one. Never the key itself, so a status page can show it as is.
Returns
Section titled “Returns”object[]
with()
Section titled “with()”with<T>(fn, opts?): Promise<T>;Defined in: core/src/key-pool.ts:133
Run fn with the next available key, rotating on key-specific and
transient failures. Everything else (a bad request, a content block) throws
straight through: it would fail identically on every key, and spending the
pool on it only turns one bad request into an outage.
Set maxAttempts: 1 for a paid request that must not be sent again. Only
actual callback invocations count, not keys skipped during cooldown. At
the cap the key is still benched as usual, but its original error is thrown
instead of trying another key. This does not limit retries inside fn
or in a wrapper around with.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
fn |
(apiKey, tier) => Promise<T> |
opts |
KeyPoolCallOptions |
Returns
Section titled “Returns”Promise<T>