From ec606ebed24ac3cb756f0ea64deaf7f40f73dd85 Mon Sep 17 00:00:00 2001 From: "R.I.Pienaar" Date: Mon, 19 Oct 2020 11:56:49 +0200 Subject: [PATCH] add type hints num accounts message Signed-off-by: R.I.Pienaar --- server/events.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server/events.go b/server/events.go index 21b38ca7..4d5b7330 100644 --- a/server/events.go +++ b/server/events.go @@ -134,6 +134,7 @@ const DisconnectEventMsgType = "io.nats.server.advisory.v1.client_disconnect" // a given account when the number of connections changes. It will also HB // updates in the absence of any changes. type AccountNumConns struct { + TypedEvent Server ServerInfo `json:"server"` Account string `json:"acc"` Conns int `json:"conns"` @@ -141,6 +142,8 @@ type AccountNumConns struct { TotalConns int `json:"total_conns"` } +const AccountNumConnsMsgType = "io.nats.server.advisory.v1.account_connections" + // accNumConnsReq is sent when we are starting to track an account for the first // time. We will request others send info to us about their local state. type accNumConnsReq struct { @@ -1164,10 +1167,16 @@ func (s *Server) sendAccConnsUpdate(a *Account, subj ...string) { return } // Build event with account name and number of local clients and leafnodes. + eid := s.nextEventID() a.mu.Lock() s.mu.Unlock() localConns := a.numLocalConnections() m := &AccountNumConns{ + TypedEvent: TypedEvent{ + Type: AccountNumConnsMsgType, + ID: eid, + Time: time.Now().UTC(), + }, Account: a.Name, Conns: localConns, LeafNodes: a.numLocalLeafNodes(),