Skip to content
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

Closed
wants to merge 9 commits into from
Closed

Partion resilience #268

wants to merge 9 commits into from

Conversation

alexsnaps
Copy link
Member

@alexsnaps alexsnaps commented Mar 14, 2024

This is a shot at starting to address #265

@alexsnaps alexsnaps force-pushed the partion-resilience branch 2 times, most recently from 8761a42 to ca921b2 Compare March 14, 2024 18:40
@alexsnaps alexsnaps force-pushed the partion-resilience branch from ca921b2 to 98d6b4f Compare March 14, 2024 18:42
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 });
Copy link
Member Author

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)
Copy link
Member Author

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…

Comment on lines +22 to +36
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)
}
})
}
Copy link
Member Author

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())
Copy link
Member Author

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

@alexsnaps
Copy link
Member Author

Closing in favor of #279

@alexsnaps alexsnaps closed this Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant