-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
etcdserver: handle watch timeouts and streaming #1138
Conversation
jonboulle
commented
Sep 23, 2014
Putting this up for discussion as I'm not actually sure on the best way we should handle this. (5 minutes is taken from this: 084dcb5#diff-6ea3031fec2b1a1ef7ff4f657c95d88fR299) Previously we just abort the connection with EOF when the timeout is reached - should we keep doing that? |
derr, I just realised another big difference in watch from 0.4.x - we aren't sending any HTTP headers until receiving a response from etcdserver - whereas in 0.4.x we sent a 200 OK + other headers immediately, only blocking on the body. @xiangli-cmu @unihorn is this expected/intentional? |
@jonboulle : context for quickly returning header: #877 i think it should return |
@unihorn thanks for the reference, totally missed that. Not sure why this was not implemented in this code to begin with.. I'll revisit this patch, stand by. |
e2e05b7
to
f3ed6c5
Compare
OK, updated to re-introduce streaming and respect the RFC. |
stand by, more changes incoming |
f23f732
to
561e797
Compare
ok, here goes - |
// Ensure headers are flushed early, in case of long polling | ||
w.(http.Flusher).Flush() | ||
|
||
cw := httputil.NewChunkedWriter(w) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implies a divergence from 0.4.x behaviour, but afaict 0.4.x behaviour was quite broken.
Specifically, watches now properly obey the streaming spec - writing the content length and carriage returns/newlines for each event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arguably we should actually differentiate here between streaming/non-streaming cases and only use a ChunkedWriter for the former.. But in that case, we would need to define the behaviour of a non-streamed watch timing out - what gets sent to the client? Thoughts?
@xiangli-cmu I think we should probably just support stream for backwards compatibility since it's a very small maintenance overhead (at least that's how it looks to me). Then we could re-evaluate for API v3 if you want. |
a9c9fee
to
f2746ee
Compare
@@ -14,17 +14,16 @@ | |||
package etcdserverpb | |||
|
|||
import proto "github.com/coreos/etcd/third_party/code.google.com/p/gogoprotobuf/proto" | |||
import json "encoding/json" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonboulle Wrong gogoprotobuf version. you have to reset the head. :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xiangli-cmu I reset to the SHA you gave me.... can you double check?
blocked on the protobuf problem. |
This reintroduces the 'stream' parameter to support long-lived watch sessions. These sessions respect a server timeout (set to 5 minutes by default).
54887b5
to
a9caa24
Compare
Fixed protobufs. |
lgtm |
etcdserver: handle watch timeouts and streaming