package rcmgr
import (
"github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/core/protocol"
)
type MetricsReporter interface {
AllowConn (dir network .Direction , usefd bool )
BlockConn (dir network .Direction , usefd bool )
AllowStream (p peer .ID , dir network .Direction )
BlockStream (p peer .ID , dir network .Direction )
AllowPeer (p peer .ID )
BlockPeer (p peer .ID )
AllowProtocol (proto protocol .ID )
BlockProtocol (proto protocol .ID )
BlockProtocolPeer (proto protocol .ID , p peer .ID )
AllowService (svc string )
BlockService (svc string )
BlockServicePeer (svc string , p peer .ID )
AllowMemory (size int )
BlockMemory (size int )
}
type metrics struct {
reporter MetricsReporter
}
func WithMetrics (reporter MetricsReporter ) Option {
return func (r *resourceManager ) error {
r .metrics = &metrics {reporter : reporter }
return nil
}
}
func (m *metrics ) AllowConn (dir network .Direction , usefd bool ) {
if m == nil {
return
}
m .reporter .AllowConn (dir , usefd )
}
func (m *metrics ) BlockConn (dir network .Direction , usefd bool ) {
if m == nil {
return
}
m .reporter .BlockConn (dir , usefd )
}
func (m *metrics ) AllowStream (p peer .ID , dir network .Direction ) {
if m == nil {
return
}
m .reporter .AllowStream (p , dir )
}
func (m *metrics ) BlockStream (p peer .ID , dir network .Direction ) {
if m == nil {
return
}
m .reporter .BlockStream (p , dir )
}
func (m *metrics ) AllowPeer (p peer .ID ) {
if m == nil {
return
}
m .reporter .AllowPeer (p )
}
func (m *metrics ) BlockPeer (p peer .ID ) {
if m == nil {
return
}
m .reporter .BlockPeer (p )
}
func (m *metrics ) AllowProtocol (proto protocol .ID ) {
if m == nil {
return
}
m .reporter .AllowProtocol (proto )
}
func (m *metrics ) BlockProtocol (proto protocol .ID ) {
if m == nil {
return
}
m .reporter .BlockProtocol (proto )
}
func (m *metrics ) BlockProtocolPeer (proto protocol .ID , p peer .ID ) {
if m == nil {
return
}
m .reporter .BlockProtocolPeer (proto , p )
}
func (m *metrics ) AllowService (svc string ) {
if m == nil {
return
}
m .reporter .AllowService (svc )
}
func (m *metrics ) BlockService (svc string ) {
if m == nil {
return
}
m .reporter .BlockService (svc )
}
func (m *metrics ) BlockServicePeer (svc string , p peer .ID ) {
if m == nil {
return
}
m .reporter .BlockServicePeer (svc , p )
}
func (m *metrics ) AllowMemory (size int ) {
if m == nil {
return
}
m .reporter .AllowMemory (size )
}
func (m *metrics ) BlockMemory (size int ) {
if m == nil {
return
}
m .reporter .BlockMemory (size )
}
The pages are generated with Golds v0.8.2 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .