-
Notifications
You must be signed in to change notification settings - Fork 15
fix(bottlecap): fix how Telemetry API stream is being read #259
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
fix(bottlecap): fix how Telemetry API stream is being read #259
Conversation
read properly from the stream so we can read every byte, retry 3 times in case theres no data
also some integration tests, moving away from mocking `TcpStream`, since signature changed
bottlecap/src/telemetry/listener.rs
Outdated
| let content_length = parser | ||
| .headers | ||
| .get("content-length") | ||
| .expect("unfallible") |
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.
do we want to expect here? can't we just drop the request if it's malformed or something broke in our assumption?
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 loop before that ensures that the key exist, which means that this is infallible, wdyt?
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.
hmm, I think that's okay. It just makes me nervous
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 could definitely add another if let Some(...) block if that makes you feel more confident
| fn handle_stream( | ||
| stream: &mut impl Read, | ||
| mut buf: [u8; 262_144], | ||
| stream: &TcpStream, |
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.
ah yeah I made this change in my branch too, a bit easier to handle than receiving a generic which implements Read.
How?
Created a new
from_streammethod, which reads headers untilcontent-lengthis found, and proceeds to read the exact remaining body size.Motivation
First developed in #256, also SVLS-4932