-
-
Notifications
You must be signed in to change notification settings - Fork 651
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
Upgrade tonic to v0.5.0 #12416
Upgrade tonic to v0.5.0 #12416
Conversation
[ci skip-build-wheels]
[ci skip-build-wheels]
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.
Thanks!
[ci skip-build-wheels]
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.
Looks good!
|
||
Ok((header_name, header_value)) | ||
}) | ||
.collect::<Vec<Result<(HeaderName, HeaderValue), String>>>(); |
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.
If you're happy to only return the first error, rather than wanting to collect them all, you can collect directly to Result<Vec<_>, _>
rather than Vec<Result<_, _>>
which would allow you to avoid needing to then partition as well. And then actually, a HeaderMap
is directly collectable-to; i.e. this function could literally be:
pub fn headers_to_http_header_map(headers: &BTreeMap<String, String>) -> Result<HeaderMap, String> {
headers
.iter()
.map(|(key, value)| {
let header_name = HeaderName::from_str(key.as_str())
.map_err(|err| format!("Invalid header name {}: {}", key, err))?;
let header_value = HeaderValue::from_str(value.as_str())
.map_err(|err| format!("Invalid header value {}: {}", value, err))?;
Ok((header_name, header_value))
})
.collect::<Result<_, String>>()
.map_err(|err| format!("header conversion error: {}", err))
}
Not saying you necessarily should, just letting you know that you could :)
[ci skip-build-wheels]
Implicit deref conversion works. Switched to that. |
Cleaned up the header conversion a little, but left in the ability to report multiple errors. |
Upgrade the Tonic crate to v0.5.0 and Prost to v0.8.0.
Notes:
tonic::Interceptor
was removed. Thewith_interceptor
functions now takes aFnMut(tonic::Request<()>) -> Result<tonic::Request<()>, Status>
type for the interceptor. Moreover,FooClient::new
andFooClient::with_interceptor
now return different types and so the return values from each function cannot be stored in the same field any more. Also,with_interceptor
now returns anInterceptedService
which encodes the type of theFnMut
into its type signature. Thus, when I tried using an "identity interceptor" function alongside the actual header interceptor function, the use ofInterceptedService
failed to compile because each closure had a different type and trying to box and/or use anArc
just ended up in type hell.SetRequestHeadersLayer
based on thetower-http
crate and to updatelayered_service
(andLayeredService
) to always take a set of headers to apply.tonic::Status
is no longerClone
. The derivations ofClone
intestutil/mock
for various types have been removed.Fixed a header setup issue in
src/rust/engine/process_execution/src/remote.rs
where user agent may not have been passed through into one of the channels because of the way in which the header map is modified in place.