Install (create-or-replace) a replicated policy into the in-memory registry. Called from the `CatalogEntry::PutRlsPolicy` post-apply side effect on every node.
(&self, policy: RlsPolicy)
| 16 | /// in-memory registry. Called from the `CatalogEntry::PutRlsPolicy` |
| 17 | /// post-apply side effect on every node. |
| 18 | pub fn install_replicated_policy(&self, policy: RlsPolicy) { |
| 19 | let key = policy_key(policy.tenant_id, &policy.collection); |
| 20 | let mut policies = self.lock_write(); |
| 21 | let list = policies.entry(key).or_default(); |
| 22 | if let Some(existing) = list.iter_mut().find(|p| p.name == policy.name) { |
| 23 | *existing = policy; |
| 24 | } else { |
| 25 | list.push(policy); |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | /// Remove a replicated policy from the in-memory registry. |
| 30 | /// Returns `true` if a policy was removed. |