mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-03-17 08:00:51 +00:00
* refactor: initial refactor of the connection manager * fix: start/stop issues * fix: add tests and resolve pruning issues * chore: fix lint * test: move conn manager tests to node only for now * chore: apply suggestions from code review Co-Authored-By: Vasco Santos <vasco.santos@moxy.studio> * fix: assert min max connection options * test: fix assertion check for browser * docs: add api and config docs for conn manager
2.0 KiB
2.0 KiB
Connection Manager
The Connection Manager works with the Registrar to keep connections across libp2p within acceptable ranges, which can be configured. By default Connection Manager will monitor:
- The total number of open connections
- The latency/delay of the event loop
If Metrics are enabled for libp2p, see ./CONFIGURATION.md#configuring-metrics on how to configure metrics, the Connection Manager can be used to prune connections when certain limits are exceeded.
The following is a list of available options for setting limits for the Connection Manager to enforce.
Options
maxConnections
: the maximum number of connections libp2p is willing to have before it starts disconnecting. Defaults toInfinity
minConnections
: the minimum number of connections below which libp2p not activate preemptive disconnections. Defaults to0
.maxData
: sets the maximum data — in bytes per second - (sent and received) this node is willing to endure before it starts disconnecting peers. Defaults toInfinity
.maxSentData
: sets the maximum sent data — in bytes per second - this node is willing to endure before it starts disconnecting peers. Defaults toInfinity
.maxReceivedData
: sets the maximum received data — in bytes per second - this node is willing to endure before it starts disconnecting peers. Defaults toInfinity
.maxEventLoopDelay
: sets the maximum event loop delay (measured in milliseconds) this node is willing to endure before it starts disconnecting peers. Defaults toInfinity
.pollInterval
: sets the poll interval (in milliseconds) for assessing the current state and determining if this peer needs to force a disconnect. Defaults to2000
(2 seconds).movingAverageInterval
: the interval used to calculate moving averages (in milliseconds). Defaults to60000
(1 minute). This must be an available interval configured inMetrics
defaultPeerValue
: number between 0 and 1. Defaults to 1.