-
Notifications
You must be signed in to change notification settings - Fork 38
Add support for watch. #40
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
Conversation
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: brendandburns The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
kubernetes/src/kubernetes/watch.rb
Outdated
| } | ||
| request = @client.build_request('GET', path + '?watch=true', opts) | ||
| request.on_body do |chunk| | ||
| parts = chunk.split(/\n/) |
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.
I'm not sure transport chunks always end in a newline. Last part might be incomplete, may need to buffer it and concat with first part of next chunk?
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.
Good point. Fixed (and added some tests to validate)
|
@cben thanks for the feedback, comment addressed! |
|
Feels like we should rebase the |
kubernetes/src/kubernetes/watch.rb
Outdated
|
|
||
| def split_lines(last, chunk) | ||
| data = chunk | ||
| data = last + "\n" + data unless last.empty? |
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.
the idea was that a single line could(?) be split between prev chunk and this one, so I think this should just be
| data = last + "\n" + data unless last.empty? | |
| data = last + data |
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.
No, because if last itself is empty you don't want to randomly prepend a newline... (I had that bug)
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.
Right but I'm saying you don't want the newline between them!
Say first chunk is cut {"Foo": 0}\n{"ba
and next chunk continues it r": 1}\n{"baz.
If you join with a newline, the 2nd json will not parse properly.
Then, prepending an empty string is harmless, you can keep the unless last.empty? or drop it, as you prefer.
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.
fixed.
ad4c9d7 to
55c8daf
Compare
|
Do kube_condig.rb changes belong in this PR? No opinion on those. |
|
Just to be clear, I'm not a merger/maintainer here. |
|
@brendandburns mind rebasing/fixing/closing depending on how you see fit? |
|
@drubin rebased. please take another look. Thanks! |
|
/lgtm |
Closes #4
@drubin
Thanks!