-
Notifications
You must be signed in to change notification settings - Fork 123
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
Bug 1605097 - Persist X-Debug-ID header and use persisted on creation of requests #1042
Conversation
BONUS: refactor the request module to use a builder-style creational pattern for PingRequests.
@@ -327,45 +346,6 @@ mod test { | |||
assert!(!wrong_contents_file_path.exists()); | |||
} | |||
|
|||
#[test] | |||
fn non_json_ping_body_files_are_deleted_and_ignored() { |
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 is unrelated. After talking to @badboy we decided to stop checking if the ping body is valid JSON. It is very unlikely that it will be, since we are the ones writing to that file. Also the ping will be rejected by the pipeline in the unlikely event it is not valid 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.
r+wc.
Code looks good, I especially like the builder pattern used.
Some inline questions.
And one more general:
We should probably have one explicit test that we write and handle that third line correctly and also handle files without that third line correctly.
Or do we by chance already have such a test?
); | ||
} | ||
if let (Some(Ok(path)), Some(Ok(body)), Ok(metadata)) = | ||
(lines.next(), lines.next(), lines.next().transpose()) |
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.
Oh wow, I think this is the first time I see transpose()
be used.
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.
Hehe, first time I use it too! It's funny that I remember what transpose
does, but always have to google map
and and_then
.
let mut request = PingRequest::builder(&local_language_binding_name) | ||
.document_id(document_id) | ||
.path(path) | ||
.body(body); |
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.
Yey, good use of the builder pattern here!
Co-authored-by: Jan-Erik Rediger <badboy@archlinux.us>
Yes, I agree. I will add an explicit test. We do have a test that indirectly tests that, but it would be nicer to have one on the ping maker tests. See: https://github.com/mozilla/glean/blob/main/glean-core/src/upload/mod.rs#L949 |
I tried to make this so that it is easy to persist more headers or even other types of metadata in the future.