mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
feat(stream watchers) end streaming if too many notifications
This commit is contained in:
@@ -80,7 +80,14 @@ func handleWatch(key string, recursive, stream bool, waitIndex string, w http.Re
|
||||
case <-closeChan:
|
||||
chunkWriter.Close()
|
||||
return nil
|
||||
case event := <-watcher.EventChan:
|
||||
case event, ok := <-watcher.EventChan:
|
||||
if !ok {
|
||||
// If the channel is closed this may be an indication of
|
||||
// that notifications are much more than we are able to
|
||||
// send to the client in time. Then we simply end streaming.
|
||||
return nil
|
||||
}
|
||||
|
||||
b, _ := json.Marshal(event)
|
||||
_, err := chunkWriter.Write(b)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user