mirror of
https://github.com/libp2p/go-libp2p-resource-manager.git
synced 2025-03-31 22:50:19 +08:00
fix shadowing of service name (#37)
This commit is contained in:
parent
50387915ba
commit
100309ee2e
@ -138,7 +138,7 @@ func (r *resourceManager) Stat() (result ResourceManagerStat) {
|
|||||||
}
|
}
|
||||||
result.Services = make(map[string]network.ScopeStat, len(svcs))
|
result.Services = make(map[string]network.ScopeStat, len(svcs))
|
||||||
for _, svc := range svcs {
|
for _, svc := range svcs {
|
||||||
result.Services[svc.name] = svc.Stat()
|
result.Services[svc.service] = svc.Stat()
|
||||||
}
|
}
|
||||||
result.Transient = r.transient.Stat()
|
result.Transient = r.transient.Stat()
|
||||||
result.System = r.system.Stat()
|
result.System = r.system.Stat()
|
||||||
|
16
rcmgr.go
16
rcmgr.go
@ -58,8 +58,8 @@ var _ network.ResourceScope = (*transientScope)(nil)
|
|||||||
type serviceScope struct {
|
type serviceScope struct {
|
||||||
*resourceScope
|
*resourceScope
|
||||||
|
|
||||||
name string
|
service string
|
||||||
rcmgr *resourceManager
|
rcmgr *resourceManager
|
||||||
|
|
||||||
peers map[peer.ID]*resourceScope
|
peers map[peer.ID]*resourceScope
|
||||||
}
|
}
|
||||||
@ -378,13 +378,13 @@ func newTransientScope(limit Limit, rcmgr *resourceManager) *transientScope {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newServiceScope(name string, limit Limit, rcmgr *resourceManager) *serviceScope {
|
func newServiceScope(service string, limit Limit, rcmgr *resourceManager) *serviceScope {
|
||||||
return &serviceScope{
|
return &serviceScope{
|
||||||
resourceScope: newResourceScope(limit,
|
resourceScope: newResourceScope(limit,
|
||||||
[]*resourceScope{rcmgr.system.resourceScope},
|
[]*resourceScope{rcmgr.system.resourceScope},
|
||||||
fmt.Sprintf("service:%s", name), rcmgr.trace, rcmgr.metrics),
|
fmt.Sprintf("service:%s", service), rcmgr.trace, rcmgr.metrics),
|
||||||
name: name,
|
service: service,
|
||||||
rcmgr: rcmgr,
|
rcmgr: rcmgr,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -431,7 +431,7 @@ func newStreamScope(dir network.Direction, limit Limit, peer *peerScope, rcmgr *
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *serviceScope) Name() string {
|
func (s *serviceScope) Name() string {
|
||||||
return s.name
|
return s.service
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *serviceScope) getPeerScope(p peer.ID) *resourceScope {
|
func (s *serviceScope) getPeerScope(p peer.ID) *resourceScope {
|
||||||
@ -444,7 +444,7 @@ func (s *serviceScope) getPeerScope(p peer.ID) *resourceScope {
|
|||||||
return ps
|
return ps
|
||||||
}
|
}
|
||||||
|
|
||||||
l := s.rcmgr.limits.GetServicePeerLimits(s.name)
|
l := s.rcmgr.limits.GetServicePeerLimits(s.service)
|
||||||
|
|
||||||
if s.peers == nil {
|
if s.peers == nil {
|
||||||
s.peers = make(map[peer.ID]*resourceScope)
|
s.peers = make(map[peer.ID]*resourceScope)
|
||||||
|
Loading…
Reference in New Issue
Block a user