mirror of
https://github.com/libp2p/go-libp2p-core.git
synced 2025-03-13 11:00:10 +08:00
feat(metrics): add function to trim idle meters
This commit is contained in:
parent
d350e2be80
commit
e7c93f4fa1
@ -2,6 +2,8 @@
|
||||
package metrics
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/libp2p/go-flow-metrics"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p-core/protocol"
|
||||
@ -163,3 +165,11 @@ func (bwc *BandwidthCounter) Reset() {
|
||||
bwc.peerIn.Clear()
|
||||
bwc.peerOut.Clear()
|
||||
}
|
||||
|
||||
// TrimIdle trims all timers idle since the given time.
|
||||
func (bwc *BandwidthCounter) TrimIdle(since time.Time) {
|
||||
bwc.peerIn.TrimIdle(since)
|
||||
bwc.peerOut.TrimIdle(since)
|
||||
bwc.protocolIn.TrimIdle(since)
|
||||
bwc.protocolOut.TrimIdle(since)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user