added space for extra statistical items by exterrnal services

This commit is contained in:
2025-01-13 15:20:36 +09:00
parent 7e772b7d3f
commit 091d28d52e
2 changed files with 18 additions and 0 deletions

View File

@ -89,6 +89,9 @@ type Server struct {
routes atomic.Int64
peers atomic.Int64
ssh_proxy_sessions atomic.Int64
extra_mtx sync.Mutex
extra map[string]int64
}
wpx_resp_tf ServerWpxResponseTransformer
@ -1146,6 +1149,7 @@ func NewServer(ctx context.Context, logger Logger, ctl_addrs []string, rpc_addrs
s.stats.routes.Store(0)
s.stats.peers.Store(0)
s.stats.ssh_proxy_sessions.Store(0)
s.stats.extra = make(map[string]int64, 64)
return &s, nil
@ -1660,3 +1664,9 @@ func (s *Server) WaitForTermination() {
func (s *Server) WriteLog(id string, level LogLevel, fmtstr string, args ...interface{}) {
s.log.Write(id, level, fmtstr, args...)
}
func (s *Server) SetExtraStat(key string, val int64) {
s.stats.extra_mtx.Lock()
s.stats.extra[key] = val
s.stats.extra_mtx.Unlock()
}