-
Notifications
You must be signed in to change notification settings - Fork 9
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
Feat/use etag from upstream #390
base: main
Are you sure you want to change the base?
Conversation
2137ff8
to
7fefc52
Compare
use super::*; | ||
|
||
#[test] | ||
fn building_an_initial_state_from_backup_also_adds_etags_for_features() { |
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.
Nice test case!
server/src/middleware/etag.rs
Outdated
client_token: &Option<EdgeToken>, | ||
if_none_match: &Option<IfNoneMatch>, | ||
) -> bool { | ||
match (if_none_match, client_token) { |
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 match one looks odd to me here. You can do a tuple destructuring if let Some
here:
fn we_know_this_etag_from_upstream(
etag_cache: Arc<DashMap<EdgeToken, EntityTag>>,
client_token: &Option<EdgeToken>,
if_none_match: &Option<IfNoneMatch>,
) -> bool {
if let (Some(if_none), Some(token)) = (if_none_match, client_token) {
etag_cache.get(token).map_or(false, |etag| {
if_none == &IfNoneMatch::Any || if_none.to_string() == etag.to_string()
})
} else {
false
}
}
Entirely optional
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.
Nice! Small comment, up to you if you want to do anything with it
This changes our client features endpoint to rely on etag we get from upstream, avoiding doing the service call and just returning 304 if we match.