mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
add in client lang and version reporting, bump limit
This commit is contained in:
@@ -39,9 +39,13 @@ type ConnInfo struct {
|
||||
InBytes int64 `json:"in_bytes"`
|
||||
OutBytes int64 `json:"out_bytes"`
|
||||
NumSubs uint32 `json:"subscriptions"`
|
||||
Lang string `json:"lang,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
Subs []string `json:"subscriptions_list,omitempty"`
|
||||
}
|
||||
|
||||
const DefaultConnListSize = 1024
|
||||
|
||||
// HandleConnz process HTTP requests for connection information.
|
||||
func (s *Server) HandleConnz(w http.ResponseWriter, r *http.Request) {
|
||||
c := &Connz{Conns: []*ConnInfo{}}
|
||||
@@ -50,7 +54,7 @@ func (s *Server) HandleConnz(w http.ResponseWriter, r *http.Request) {
|
||||
c.Offset, _ = strconv.Atoi(r.URL.Query().Get("offset"))
|
||||
c.Limit, _ = strconv.Atoi(r.URL.Query().Get("limit"))
|
||||
if c.Limit == 0 {
|
||||
c.Limit = 100
|
||||
c.Limit = DefaultConnListSize
|
||||
}
|
||||
|
||||
// Walk the list
|
||||
@@ -75,6 +79,8 @@ func (s *Server) HandleConnz(w http.ResponseWriter, r *http.Request) {
|
||||
InBytes: client.inBytes,
|
||||
OutBytes: client.outBytes,
|
||||
NumSubs: client.subs.Count(),
|
||||
Lang: client.opts.Lang,
|
||||
Version: client.opts.Version,
|
||||
}
|
||||
|
||||
if subs == 1 {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2012-2014 Apcera Inc. All rights reserved.
|
||||
// Copyright 2012-2015 Apcera Inc. All rights reserved.
|
||||
|
||||
package test
|
||||
|
||||
@@ -169,8 +169,8 @@ func TestConnz(t *testing.T) {
|
||||
t.Fatalf("Expected 1 connections in array, got %p\n", c.Conns)
|
||||
}
|
||||
|
||||
if c.Limit != 100 {
|
||||
t.Fatalf("Expected limit of 100, got %v\n", c.Limit)
|
||||
if c.Limit != server.DefaultConnListSize {
|
||||
t.Fatalf("Expected limit of %d, got %v\n", server.DefaultConnListSize, c.Limit)
|
||||
}
|
||||
|
||||
if c.Offset != 0 {
|
||||
|
||||
Reference in New Issue
Block a user