mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-17 11:24:44 -07:00
Address CR feedback
This commit is contained in:
@@ -13,6 +13,7 @@ max_control_line: 512 # change on reload
|
||||
ping_interval: 5 # change on reload
|
||||
ping_max: 1 # change on reload
|
||||
write_deadline: "2s" # change on reload
|
||||
max_payload: 1024 # change on reload
|
||||
|
||||
# Enable TLS on reload
|
||||
tls {
|
||||
|
||||
@@ -381,7 +381,7 @@ type Varz struct {
|
||||
*Info
|
||||
*Options
|
||||
Port int `json:"port"`
|
||||
MaxPayload int64 `json:"max_payload"`
|
||||
MaxPayload int `json:"max_payload"`
|
||||
Start time.Time `json:"start"`
|
||||
Now time.Time `json:"now"`
|
||||
Uptime string `json:"uptime"`
|
||||
|
||||
@@ -54,7 +54,7 @@ type Options struct {
|
||||
HTTPSPort int `json:"https_port"`
|
||||
AuthTimeout float64 `json:"auth_timeout"`
|
||||
MaxControlLine int `json:"max_control_line"`
|
||||
MaxPayload int64 `json:"max_payload"`
|
||||
MaxPayload int `json:"max_payload"`
|
||||
Cluster ClusterOpts `json:"cluster"`
|
||||
ProfPort int `json:"-"`
|
||||
PidFile string `json:"-"`
|
||||
@@ -245,7 +245,7 @@ func ProcessConfigFile(configFile string) (*Options, error) {
|
||||
case "max_control_line":
|
||||
opts.MaxControlLine = int(v.(int64))
|
||||
case "max_payload":
|
||||
opts.MaxPayload = v.(int64)
|
||||
opts.MaxPayload = int(v.(int64))
|
||||
case "max_connections", "max_conn":
|
||||
opts.MaxConn = int(v.(int64))
|
||||
case "ping_interval":
|
||||
|
||||
@@ -355,7 +355,7 @@ func (m *maxControlLineOption) Apply(server *Server) {
|
||||
// setting.
|
||||
type maxPayloadOption struct {
|
||||
noopOption
|
||||
newValue int64
|
||||
newValue int
|
||||
}
|
||||
|
||||
// Apply the setting by updating the server info and each client.
|
||||
@@ -364,7 +364,7 @@ func (m *maxPayloadOption) Apply(server *Server) {
|
||||
server.info.MaxPayload = m.newValue
|
||||
server.generateServerInfoJSON()
|
||||
for _, client := range server.clients {
|
||||
atomic.StoreInt64(&client.mpay, m.newValue)
|
||||
atomic.StoreInt64(&client.mpay, int64(m.newValue))
|
||||
}
|
||||
server.mu.Unlock()
|
||||
server.Noticef("Reloaded: max_payload = %d", m.newValue)
|
||||
@@ -507,7 +507,7 @@ func (s *Server) diffOptions(newOpts *Options) ([]option, error) {
|
||||
case "maxcontrolline":
|
||||
diffOpts = append(diffOpts, &maxControlLineOption{newValue: newValue.(int)})
|
||||
case "maxpayload":
|
||||
diffOpts = append(diffOpts, &maxPayloadOption{newValue: newValue.(int64)})
|
||||
diffOpts = append(diffOpts, &maxPayloadOption{newValue: newValue.(int)})
|
||||
case "pinginterval":
|
||||
diffOpts = append(diffOpts, &pingIntervalOption{newValue: newValue.(time.Duration)})
|
||||
case "maxpingsout":
|
||||
|
||||
@@ -232,6 +232,9 @@ func TestConfigReload(t *testing.T) {
|
||||
if updated.WriteDeadline != 2*time.Second {
|
||||
t.Fatalf("WriteDeadline is incorrect.\nexpected 2s\ngot: %s", updated.WriteDeadline)
|
||||
}
|
||||
if updated.MaxPayload != 1024 {
|
||||
t.Fatalf("MaxPayload is incorrect.\nexpected 1024\ngot: %d", updated.MaxPayload)
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure Reload supports TLS config changes. Test this by starting a server
|
||||
|
||||
@@ -36,7 +36,7 @@ type Info struct {
|
||||
SSLRequired bool `json:"ssl_required"` // DEPRECATED: ssl json used for older clients
|
||||
TLSRequired bool `json:"tls_required"`
|
||||
TLSVerify bool `json:"tls_verify"`
|
||||
MaxPayload int64 `json:"max_payload"`
|
||||
MaxPayload int `json:"max_payload"`
|
||||
IP string `json:"ip,omitempty"`
|
||||
ClientConnectURLs []string `json:"connect_urls,omitempty"` // Contains URLs a client can connect to.
|
||||
|
||||
@@ -640,7 +640,7 @@ func (s *Server) createClient(conn net.Conn) *client {
|
||||
// Snapshot server options.
|
||||
opts := s.getOpts()
|
||||
|
||||
c := &client{srv: s, nc: conn, opts: defaultOpts, mpay: opts.MaxPayload, start: time.Now()}
|
||||
c := &client{srv: s, nc: conn, opts: defaultOpts, mpay: int64(opts.MaxPayload), start: time.Now()}
|
||||
|
||||
// Grab JSON info string
|
||||
s.mu.Lock()
|
||||
|
||||
Reference in New Issue
Block a user