-
Notifications
You must be signed in to change notification settings - Fork 6
chore: Clean up CacheHeaderInterceptor
#33
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
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 for cleaning this up
src/grpc/cache_header_interceptor.rs
Outdated
fn call( | ||
&mut self, | ||
mut request: tonic::Request<()>, | ||
) -> Result<tonic::Request<()>, tonic::Status> { | ||
let request_metadata = request.metadata().clone(); |
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 even need this clone anymore?
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.
It seems that let cache_name = request.metadata().get("cahce").unwrap()
is immutable borrow; therefore request
cannot be called with metadata_mut().insert()
after that call.
So I think we need to clone first and get cache
metadata.
src/grpc/cache_header_interceptor.rs
Outdated
"content-type", | ||
tonic::metadata::AsciiMetadataValue::from_str("application/grpc").unwrap(), | ||
); | ||
|
||
let cache_name = request_metadata.get("cache").unwrap(); | ||
|
||
// need to re-add our `cache` header back into the interceptor or it will be stripped out |
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.
is this out of date now?
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 catch! Since we updated to use mutable request
directly, it does not seem necessary to add cache
back to metadata, which also solve the above comment.
I can just remove this and the above altogether.
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
Make
request
arg mutable forCacheHeaderInterceptor
so that we don't need to create a new request.Related conversations: #31 (comment)