-
Notifications
You must be signed in to change notification settings - Fork 11
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: delta cache manager #760
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Files |
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.
Yeah the Rust looks good
|
||
#[derive(Debug, Clone)] | ||
pub enum DeltaCacheUpdate { | ||
Full(String), // environment with a newly inserted cache |
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.
Might be asking for too much here, but it's not possible for the Full
to just be a special case of Update
? Be cool to only have two cases here but I really dunno if that's possible with your future plans
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.
I am considering dropping it altogether after I confirm it's not needed in the next PR
server/src/delta_cache_manager.rs
Outdated
self.caches.get(env).map(|entry| entry.value().clone()) | ||
} | ||
|
||
pub fn insert_cache(&self, env: String, cache: DeltaCache) { |
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.
Can I suggest taking a &str here? It usually makes for a nicer API when working with literals and since you're cloning it anyway in the body, there's no real hit to memory
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.
Absolutely
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.
Except for Simon's comment on taking a &str instead of a String when inserting the cache, this LGTM
About the changes
We used store delta cache per environment:
let delta_cache: DashMap<String, DeltaCache> = DashMap::default();
After this change we will be able to use:
let delta_cache_manager = DeltaCacheManager::new();
The manager will hide the dash map but also handle updates broadcasting for streaming purposes.
This API is symmetrical to how we handle FeatureCache. As a result switching streaming code from full updates to deltas will be almost a drop-in replacement.
Important files
Discussion points
Calling something a manager is controversial. I'm open to changing this name it but after this code is merged and used in another PR that I've been working on.