remove all clients (including closing all channels) on shutdown

This commit is contained in:
Anton Kaliaev
2017-07-12 13:10:36 +03:00
parent a99b8a6210
commit 8062ade787

View File

@@ -216,7 +216,9 @@ loop:
state.removeAll(cmd.clientID)
}
case shutdown:
state.reset()
for clientID, _ := range state.clients {
state.removeAll(clientID)
}
break loop
case sub:
state.add(cmd.clientID, cmd.query, cmd.ch)
@@ -286,11 +288,6 @@ func (state *state) removeAll(clientID string) {
delete(state.clients, clientID)
}
func (state *state) reset() {
state.queries = make(map[Query]map[string]chan<- interface{})
state.clients = make(map[string]map[Query]struct{})
}
func (state *state) send(msg interface{}, tags map[string]interface{}, slowClientStrategy overflowStrategy, logger log.Logger) {
for q, clientToChannelMap := range state.queries {
// NOTE we can use LRU cache to speed up common cases like query = "