add in client lang and version reporting, bump limit

This commit is contained in:
Derek Collison
2015-06-15 20:58:59 -07:00
parent bb3b8d2af2
commit aabc9a2a7c
2 changed files with 10 additions and 4 deletions

View File

@@ -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 {

View File

@@ -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 {