From dd8856b1af3abefa11fb08c7128fc0e40aae5e46 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Fri, 10 Dec 2021 15:04:32 +0400 Subject: [PATCH] return a ConnectionStat instead of a Stat for the Conn --- network/conn.go | 2 +- network/network.go | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/network/conn.go b/network/conn.go index e1b6d56..4351619 100644 --- a/network/conn.go +++ b/network/conn.go @@ -63,5 +63,5 @@ type ConnMultiaddrs interface { // ConnStat is an interface mixin for connection types that provide connection statistics. type ConnStat interface { // Stat stores metadata pertaining to this conn. - Stat() Stat + Stat() ConnectionStat } diff --git a/network/network.go b/network/network.go index a2ed8d7..279db7a 100644 --- a/network/network.go +++ b/network/network.go @@ -96,7 +96,14 @@ func (r Reachability) String() string { return str[r] } -// Stat stores metadata pertaining to a given Stream/Conn. +// ConnectionStat stores metadata pertaining to a given Conn. +type ConnectionStat struct { + Stat + // NumStreams is the number of streams on the connection. + NumStreams int +} + +// Stat stores metadata pertaining to a given Stream / Conn. type Stat struct { // Direction specifies whether this is an inbound or an outbound connection. Direction Direction