Skip to content

Commit

Permalink
etcdserver: simplify non/streaming handling
Browse files Browse the repository at this point in the history
  • Loading branch information
jonboulle committed Sep 23, 2014
1 parent f3ed6c5 commit f23f732
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions etcdserver/etcdhttp/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,22 +353,6 @@ func handleWatch(w http.ResponseWriter, wa store.Watcher, stream bool) {

cw := httputil.NewChunkedWriter(w)

if !stream {
select {
case <-nch:
// Client closed connection. Nothing to do.
case <-tch:
cw.Close()
case ev := <-ech:
if err := json.NewEncoder(cw).Encode(ev); err != nil {
// Should never be reached
log.Println("error writing event: %v", err)
}
}
return
}

// streaming loop
for {
select {
case <-nch:
Expand All @@ -389,6 +373,9 @@ func handleWatch(w http.ResponseWriter, wa store.Watcher, stream bool) {
log.Println("error writing event: %v", err)
return
}
if !stream {
return
}
w.(http.Flusher).Flush()
}
}
Expand Down

0 comments on commit f23f732

Please sign in to comment.