mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
add type hints num accounts message
Signed-off-by: R.I.Pienaar <rip@devco.net>
This commit is contained in:
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user