ConnectionManager class
Manages the lifecycle of connections
- Implemented types
Constructors
- ConnectionManager.new({Duration idleTimeout = const Duration(minutes: 5), Duration shutdownTimeout = const Duration(seconds: 30)})
- Creates a new connection manager
Properties
- activeConnections → int
-
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- idleTimeout → Duration
-
Duration after which an idle connection is considered stale
final
- notifiee → Notifiee
-
Returns an implementation that can be called back to inform of
opened and closed connections.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shutdownTimeout → Duration
-
Duration to wait for graceful shutdown before forcing closure
final
Methods
-
checkLimit(
GetConnLimiter limiter) → String? -
Will return an error if the connection manager's internal
connection limit exceeds the provided system limit.
override
-
close(
) → Future< void> -
Closes the connection manager and stops background processes.
override
-
closeAll(
) → Future< void> - Closes all managed connections
-
closeConnection(
TransportConn connection) → Future< void> -
Initiates graceful shutdown of a connection
override
-
dispose(
) → Future< void> -
Disposes of the connection manager and releases all resources
override
-
getState(
TransportConn connection) → ConnectionState? -
Gets the current state of a connection
override
-
getStateStream(
TransportConn connection) → Stream< ConnectionStateChange> ? -
Gets the stream of state changes for a connection
override
-
getTagInfo(
PeerId peerId) → TagInfo? -
Returns the metadata associated with the peer,
or null if no metadata has been recorded for the peer.
override
-
isProtected(
PeerId peerId, String tag) → bool -
Returns true if the peer is protected for some tag; if the tag is the empty string
then it will return true if the peer is protected for any tag
override
-
isProtectedConnection(
TransportConn conn) → bool -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
protect(
PeerId peerId, String tag) → void -
Protects a peer from having its connection(s) pruned.
override
-
recordActivity(
TransportConn connection) → void -
Records activity on a connection
override
-
registerConnection(
TransportConn connection) → void -
Registers a new connection with the manager
override
-
tagPeer(
PeerId peerId, String tag, int value) → void -
Tags a peer with a string, associating a weight with the tag.
override
-
toString(
) → String -
A string representation of this object.
inherited
-
trimOpenConns(
) → Future< void> -
Terminates open connections based on an implementation-defined heuristic.
override
-
unprotect(
PeerId peerId, String tag) → bool -
Removes a protection that may have been placed on a peer, under the specified tag.
override
-
untagPeer(
PeerId peerId, String tag) → void -
Removes the tagged value from the peer.
override
-
updateState(
TransportConn connection, ConnectionState newState, {Object? error}) → void -
Updates the state of a connection
override
-
upsertTag(
PeerId peerId, String tag, int upsert(int)) → void -
Updates an existing tag or inserts a new one.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited