mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
Remove delay for global statsz, bump RC version
Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
@@ -40,7 +40,7 @@ var (
|
||||
|
||||
const (
|
||||
// VERSION is the current version for the server.
|
||||
VERSION = "2.0.0-RC3"
|
||||
VERSION = "2.0.0-RC4"
|
||||
|
||||
// PROTO is the currently supported protocol.
|
||||
// 0 was the original
|
||||
|
||||
@@ -16,7 +16,6 @@ package server
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -445,7 +444,7 @@ func (s *Server) initEventTracking() {
|
||||
s.Errorf("Error setting up internal tracking: %v", err)
|
||||
}
|
||||
// Listen for ping messages that will be sent to all servers for statsz.
|
||||
if _, err := s.sysSubscribe(serverStatsPingReqSubj, s.statszPing); err != nil {
|
||||
if _, err := s.sysSubscribe(serverStatsPingReqSubj, s.statszReq); err != nil {
|
||||
s.Errorf("Error setting up internal tracking: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -572,30 +571,6 @@ func (s *Server) connsRequest(sub *subscription, subject, reply string, msg []by
|
||||
}
|
||||
}
|
||||
|
||||
// random back off interval for broadcast statsz ping requests.
|
||||
const randomBackoff = 250 * time.Millisecond
|
||||
|
||||
// statszPing will handle global requests for our server statsz. This will be a
|
||||
// broadcast msg so we want to be mindful of that. We will do a random backoff and
|
||||
// process in a separate go routine.
|
||||
func (s *Server) statszPing(sub *subscription, subject, reply string, msg []byte) {
|
||||
if !s.EventsEnabled() || reply == _EMPTY_ {
|
||||
return
|
||||
}
|
||||
s.startGoRoutine(func() {
|
||||
defer s.grWG.Done()
|
||||
delay := time.Duration(rand.Intn(int(randomBackoff)))
|
||||
select {
|
||||
case <-time.After(delay):
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
s.sendStatsz(reply)
|
||||
case <-s.quitCh:
|
||||
return
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// statszReq is a request for us to respond with current statz.
|
||||
func (s *Server) statszReq(sub *subscription, subject, reply string, msg []byte) {
|
||||
s.mu.Lock()
|
||||
|
||||
@@ -1178,14 +1178,14 @@ func TestServerEventsPingStatsZ(t *testing.T) {
|
||||
m := ServerStatsMsg{}
|
||||
|
||||
// Receive both manually.
|
||||
msg, err := sub.NextMsg(randomBackoff * 2)
|
||||
msg, err := sub.NextMsg(time.Second)
|
||||
if err != nil {
|
||||
t.Fatalf("Error receiving msg: %v", err)
|
||||
}
|
||||
if err := json.Unmarshal(msg.Data, &m); err != nil {
|
||||
t.Fatalf("Error unmarshalling the statz json: %v", err)
|
||||
}
|
||||
msg, err = sub.NextMsg(randomBackoff)
|
||||
msg, err = sub.NextMsg(time.Second)
|
||||
if err != nil {
|
||||
t.Fatalf("Error receiving msg: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user