-
Notifications
You must be signed in to change notification settings - Fork 23
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
Partion resilience #268
Partion resilience #268
Conversation
8761a42
to
ca921b2
Compare
ca921b2
to
98d6b4f
Compare
let storage = RedisLenient::new(storage); | ||
let arc = Arc::new(storage); | ||
let copy = arc.clone(); | ||
tokio::spawn(async move { copy.sanity_check(Duration::from_secs(5)).await }); |
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 needs to be configurable…
pub async fn is_alive(&self) -> bool { | ||
self.conn_manager | ||
.clone() | ||
.incr::<&str, i32, u64>("LIMITADOR_LIVE_CHECK", 1) |
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 probably needs to be configurable as well…
if self.is_partitioned() { | ||
self.fallback.is_within_limits(counter, delta) | ||
} else { | ||
self.redis | ||
.is_within_limits(counter, delta) | ||
.await | ||
.or_else(|err| { | ||
if err.is_transient() { | ||
self.partitioned(true); | ||
self.fallback.is_within_limits(counter, delta) | ||
} else { | ||
Err(err) | ||
} | ||
}) | ||
} |
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 pattern could be extracted in a macro possible
self.fallback.get_counters(&limits) | ||
} else { | ||
self.redis | ||
.get_counters(limits.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.
Refactor this to have the limits: HashSet<Limit>
be returned back as part of the Err
to avoid the (early?) .clone()
here
d00d91f
to
c67ee2f
Compare
Closing in favor of #279 |
This is a shot at starting to address #265