-
Notifications
You must be signed in to change notification settings - Fork 178
feat(smg): cluster-wide rate limiting via epoch-windowed mesh counters #1715
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
Changes from all commits
f47b837
6b6ef9e
3f07286
bb61f72
3602bdb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -169,6 +169,39 @@ impl CrdtOrMap { | |
| all | ||
| } | ||
|
|
||
| /// Live keys under `prefix`, consulting only the engine the prefix | ||
| /// routes to. Readers on request paths use this instead of | ||
| /// [`Self::keys`], which scans and clones every key of every engine. | ||
| /// A `prefix` shorter than a registered prefix could span engines and | ||
| /// falls back to the full scan. | ||
| pub fn keys_with_prefix(&self, prefix: &str) -> Vec<String> { | ||
| let engines = self.engines_snapshot(); | ||
| for (registered, engine) in engines.iter() { | ||
| if prefix.starts_with(registered.as_str()) { | ||
| return engine | ||
| .keys() | ||
| .into_iter() | ||
| .filter(|key| key.starts_with(prefix)) | ||
| .collect(); | ||
| } | ||
| } | ||
| if engines | ||
| .iter() | ||
| .any(|(registered, _)| registered.starts_with(prefix)) | ||
| { | ||
| return self | ||
| .keys() | ||
| .into_iter() | ||
| .filter(|key| key.starts_with(prefix)) | ||
| .collect(); | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| self.default_engine | ||
| .keys() | ||
| .into_iter() | ||
| .filter(|key| key.starts_with(prefix)) | ||
| .collect() | ||
| } | ||
|
Comment on lines
+177
to
+203
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of adding complex routing logic in Please add an assertion in the engine registration path to prevent duplicate/overlapping prefixes, which allows pub fn keys_with_prefix(&self, prefix: &str) -> Vec<String> {
let engines = self.engines_snapshot();
if let Some((_, engine)) = engines.iter().find(|(registered, _)| prefix.starts_with(registered.as_str())) {
engine.keys().into_iter().filter(|key| key.starts_with(prefix)).collect()
} else {
self.default_engine.keys().into_iter().filter(|key| key.starts_with(prefix)).collect()
}
}References
|
||
|
|
||
| pub fn all(&self) -> BTreeMap<String, Vec<u8>> { | ||
| let mut all = BTreeMap::new(); | ||
| for engine in self.all_engines() { | ||
|
|
||
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.
Because the engine table is longest-prefix sorted, an overlapping setup such as registered prefixes
foo:bar:andfoo:makeskeys_with_prefix("foo:")return as soon as it reaches thefoo:engine, so it never scans thefoo:bar:engine even though those keys also match the requested prefix.configure_crdt_prefixonly rejects exact duplicates, so this regressesCrdtNamespace::keys("")for parent namespaces that overlap child namespaces from the previous all-engine scan and silently omits live keys.Useful? React with 👍 / 👎.