Optimize graph relation filtering and fix concurrent connection storms
This commit is contained in:
1 parent
cbd3d5801c
commit
ed42f738f1
2 files changed
+6
-21
No files matched your search
+2
-13
@@ -511,19 +511,8 @@ impl MemoryHandler {
|
||||
"delete_relations" => {
|
||||
let req = parse_tool!(args.clone(), id, DeleteRelationsTool);
|
||||
self.state.modify_graph(|master| {
|
||||
let mut to_rem = HashSet::new();
|
||||
for r in req.relations {
|
||||
to_rem.insert(format!(
|
||||
"{}|{}|{}|{}",
|
||||
r.from, r.to, r.relation_type, r.namespace
|
||||
));
|
||||
}
|
||||
master.relations.retain(|r| {
|
||||
!to_rem.contains(&format!(
|
||||
"{}|{}|{}|{}",
|
||||
r.from, r.to, r.relation_type, r.namespace
|
||||
))
|
||||
});
|
||||
let to_rem: HashSet<_> = req.relations.into_iter().collect();
|
||||
master.relations.retain(|r| !to_rem.contains(r));
|
||||
});
|
||||
Ok("Relations deleted".to_string())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user