1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-01-02 07:25:19 -05:00

stats feature

This commit is contained in:
Darien Raymond
2018-03-30 19:56:59 +02:00
parent 24f393a23f
commit 35e160a1ff
9 changed files with 239 additions and 5 deletions

View File

@@ -28,6 +28,7 @@ type Instance struct {
router syncRouter
ihm syncInboundHandlerManager
ohm syncOutboundHandlerManager
stats syncStatManager
access sync.Mutex
features []Feature
@@ -148,6 +149,8 @@ func (s *Instance) RegisterFeature(feature interface{}, instance Feature) error
s.ihm.Set(instance.(InboundHandlerManager))
case OutboundHandlerManager, *OutboundHandlerManager:
s.ohm.Set(instance.(OutboundHandlerManager))
case StatManager, *StatManager:
s.stats.Set(instance.(StatManager))
default:
s.access.Lock()
s.features = append(s.features, instance)
@@ -162,7 +165,7 @@ func (s *Instance) RegisterFeature(feature interface{}, instance Feature) error
}
func (s *Instance) allFeatures() []Feature {
return append([]Feature{s.DNSClient(), s.PolicyManager(), s.Dispatcher(), s.Router(), s.InboundHandlerManager(), s.OutboundHandlerManager()}, s.features...)
return append([]Feature{s.DNSClient(), s.PolicyManager(), s.Dispatcher(), s.Router(), s.InboundHandlerManager(), s.OutboundHandlerManager(), s.Stats()}, s.features...)
}
// GetFeature returns a feature that was registered in this Instance. Nil if not found.
@@ -207,3 +210,7 @@ func (s *Instance) InboundHandlerManager() InboundHandlerManager {
func (s *Instance) OutboundHandlerManager() OutboundHandlerManager {
return &(s.ohm)
}
func (s *Instance) Stats() StatManager {
return &(s.stats)
}