Extends: undici.Dispatcher
Agent allows dispatching requests against multiple different origins.
Requests are not guaranteed to be dispatched in order of invocation.
new undici.Agent(options?): voidArguments:
- options
AgentOptions(optional)
Returns: Agent
Extends: PoolOptions
- factory
(origin: URL, opts: Object) => Dispatcher- Default:(origin, opts) => new Pool(origin, opts) - maxOrigins
number(optional) - Default:Infinity- Limits the total number of origins that can receive requests at a time, throwing anMaxOriginsReachedErrorerror when attempting to dispatch when the max is reached. IfInfinity, no limit is enforced.
[!NOTE] Like
Pool,Agentinherits allClientOptions.allowH2defaults totrueandmaxConcurrentStreamsto100. The per-originPoolit creates uses the default unlimitedconnections, so concurrent requests to the same origin land on separateClientinstances and separate TCP/TLS sockets — HTTP/2 multiplexing on a shared session does not apply unlessconnectionsis set to a small value. SeePoolOptions.
Implements Client.closed
Implements Client.destroyed
Agent.close(callback?): voidImplements Dispatcher.close([callback]).
Agent.destroy(error?, callback?): voidImplements Dispatcher.destroy([error, callback]).
Agent.dispatch(options, handler: AgentDispatchOptions): voidImplements Dispatcher.dispatch(options, handler).
Extends: DispatchOptions
- origin
string | URL
Implements Dispatcher.destroy([error, callback]).
Agent.connect(options, callback?): voidSee Dispatcher.connect(options[, callback]).
Agent.dispatch(options, handler): voidImplements Dispatcher.dispatch(options, handler).
Agent.pipeline(options, handler): voidSee Dispatcher.pipeline(options, handler).
Agent.request(options, callback?): voidSee Dispatcher.request(options [, callback]).
Agent.stream(options, factory, callback?): voidSee Dispatcher.stream(options, factory[, callback]).
Agent.upgrade(options, callback?): voidSee Dispatcher.upgrade(options[, callback]).
Agent.stats(): voidReturns an object of stats by origin in the format of Record<string, TClientStats | TPoolStats>
See PoolStats and ClientStats.