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.
Like Pool, Agent inherits all ClientOptions. allowH2 defaults to true and maxConcurrentStreams to 100. The per-origin Pool it creates uses the default unlimited connections, so concurrent requests to the same origin land on separate Client instances and separate TCP/TLS sockets — HTTP/2 multiplexing on a shared session does not apply unless connections is set to a small value. See PoolOptions.
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.