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

First step: Limit storage #352

Merged
merged 4 commits into from
Jun 10, 2024
Merged

First step: Limit storage #352

merged 4 commits into from
Jun 10, 2024

Conversation

alexsnaps
Copy link
Member

@alexsnaps alexsnaps commented Jun 4, 2024

Slowly refactoring this, so the idea is that:

  • Limit definitions are now stored in Arc, so that they can be shared within the crate's boundaries (i.e. towards the (Async)CounterStorage d040c0d
  • Do not expose Counter as part of the lib's API, only as part of the SPI, i.e. (Async)CounterStorage eefd5d4
  • Have Counter.limit be an Arc coming from the Storage.limit's eefd5d4

I'll then move on to fixing #328

Comment on lines +288 to +289
fn get_counters(&self, limits: &HashSet<Arc<Limit>>) -> Result<HashSet<Counter>, StorageErr>; // todo revise typing here?
fn delete_counters(&self, limits: &HashSet<Arc<Limit>>) -> Result<(), StorageErr>; // todo revise typing here?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking of making these &[Arc<Limit>], and storing the limits in a ordered Vec<Limit>, where same namespace Limits would be adjacent to each other... Still running tests on this tho. I think having a slice here is acceptable, might not convey the contract as clearly as a HashSet wrt uniqueness, but would be acceptable as a tradeoff if the perf improvement is there... And for "other cases" one would need to create the Vec on the callsite.

Comment on lines +303 to +307
async fn get_counters(
&self,
limits: &HashSet<Arc<Limit>>,
) -> Result<HashSet<Counter>, StorageErr>;
async fn delete_counters(&self, limits: &HashSet<Arc<Limit>>) -> Result<(), StorageErr>;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the comment above on the sync version of the trait.

@@ -226,6 +226,49 @@ pub struct CheckResult {
pub limit_name: Option<String>,
}

impl CheckResult {
pub fn response_header(&mut self) -> HashMap<String, String> {
Copy link
Member Author

@alexsnaps alexsnaps Jun 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking this should return something other than String as keys to our Map here, but not a big deal (I think) for now as there is only one supported impl.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for refactoring this here.

Copy link
Contributor

@chirino chirino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alexsnaps alexsnaps merged commit 72c2b12 into main Jun 10, 2024
8 checks passed
@alexsnaps alexsnaps deleted the limit_storage branch June 10, 2024 12:31
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.

2 participants