rename network.Stat to Stats, introduce ConnStats (#226)

This commit is contained in:
Marten Seemann 2021-12-12 14:58:02 +04:00 committed by GitHub
parent 975f71b238
commit ed7a5ab432
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 4 deletions

View File

@ -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() ConnStats
}

View File

@ -96,8 +96,15 @@ func (r Reachability) String() string {
return str[r]
}
// Stat stores metadata pertaining to a given Stream/Conn.
type Stat struct {
// ConnStats stores metadata pertaining to a given Conn.
type ConnStats struct {
Stats
// NumStreams is the number of streams on the connection.
NumStreams int
}
// Stats stores metadata pertaining to a given Stream / Conn.
type Stats struct {
// Direction specifies whether this is an inbound or an outbound connection.
Direction Direction
// Opened is the timestamp when this connection was opened.

View File

@ -21,7 +21,7 @@ type Stream interface {
SetProtocol(id protocol.ID)
// Stat returns metadata pertaining to this stream.
Stat() Stat
Stat() Stats
// Conn returns the connection this stream is part of.
Conn() Conn