Browse Source

remove all clients (including closing all channels) on shutdown

pull/1842/head
Anton Kaliaev 7 years ago
parent
commit
8062ade787
No known key found for this signature in database GPG Key ID: 7B6881D965918214
1 changed files with 3 additions and 6 deletions
  1. +3
    -6
      pubsub/pubsub.go

+ 3
- 6
pubsub/pubsub.go View File

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


Loading…
Cancel
Save