Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adds documentation and fixes
  • Loading branch information
tdeekens committed Apr 15, 2025
commit 15bc63b63f3437a938505be6999f6b91f1503e3a
12 changes: 9 additions & 3 deletions docs/docs/api/Agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ Requests are not guaranteed to be dispatched in order of invocation.

Arguments:

* **options** `AgentOptions` (optional)
- **options** `AgentOptions` (optional)

Returns: `Agent`

### Parameter: `AgentOptions`

Extends: [`PoolOptions`](/docs/docs/api/Pool.md#parameter-pooloptions)

* **factory** `(origin: URL, opts: Object) => Dispatcher` - Default: `(origin, opts) => new Pool(origin, opts)`
- **factory** `(origin: URL, opts: Object) => Dispatcher` - Default: `(origin, opts) => new Pool(origin, opts)`

## Instance Properties

Expand Down Expand Up @@ -48,7 +48,7 @@ Implements [`Dispatcher.dispatch(options, handler)`](/docs/docs/api/Dispatcher.m

Extends: [`DispatchOptions`](/docs/docs/api/Dispatcher.md#parameter-dispatchoptions)

* **origin** `string | URL`
- **origin** `string | URL`

Implements [`Dispatcher.destroy([error, callback])`](/docs/docs/api/Dispatcher.md#dispatcherdestroyerror-callback-promise).

Expand All @@ -75,3 +75,9 @@ See [`Dispatcher.stream(options, factory[, callback])`](/docs/docs/api/Dispatche
### `Agent.upgrade(options[, callback])`

See [`Dispatcher.upgrade(options[, callback])`](/docs/docs/api/Dispatcher.md#dispatcherupgradeoptions-callback).

### `Agent.stats()`

Returns stats of all clients for each origin in format of `[string, [TClientStats | TPoolStats]][]`

See [`PoolStats`](/docs/docs/api/PoolStats.md) and [`ClientStats`](/docs/docs/api/ClientStats.md).
27 changes: 27 additions & 0 deletions docs/docs/api/ClientStats.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Class: ClientStats

Stats for a [Client](/docs/docs/api/Client.md).

## `new ClientStats(client)`

Arguments:

* **client** `Client` - Client from which to return stats.

## Instance Properties

### `ClientStats.connected`

Boolean if socket as open connection by this client.

### `ClientStats.pending`

Number of pending requests of this client.

### `ClientStats.running`

Number of currently active requests across this client.

### `ClientStats.size`

Number of active, pending, or queued requests of this clients.
2 changes: 1 addition & 1 deletion types/agent.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ declare class Agent extends Dispatcher {
/** Dispatches a request. */
dispatch (options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandler): boolean
/** Aggregate stats for a Agent by origin. */
readonly stats: [string, [TClientStats, TPoolStats]][]
readonly stats: [string, [TClientStats | TPoolStats]][]
}

declare namespace Agent {
Expand Down
10 changes: 5 additions & 5 deletions types/client-stats.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ export default ClientStats

declare class ClientStats {
constructor (pool: Client)
/** Number of open socket connections in this pool. */
connected: number
/** Number of open socket connections in this pool that do not have an active request. */
/** If socket has open connection. */
connected: boolean
/** Number of open socket connections in this client that do not have an active request. */
pending: number
/** Number of currently active requests across all clients in this pool. */
/** Number of currently active requests of this client. */
running: number
/** Number of active, pending, or queued requests across all clients in this pool. */
/** Number of active, pending, or queued requests of this client. */
size: number
}
Loading