pub trait ConfigCenter: Send + Sync {
// Required methods
fn get(&self, key: &str) -> Option<String>;
fn set(&mut self, key: &str, value: &str);
fn delete(&mut self, key: &str) -> bool;
fn exists(&self, key: &str) -> bool;
fn list(&self) -> Vec<String>;
fn watch(&self, key: &str) -> bool;
fn subscribe(&mut self, key: &str, callback: ConfigChangeCallback);
}Expand description
Configuration center abstraction (Consul/Nacos/etc).
Required Methods§
fn get(&self, key: &str) -> Option<String>
fn set(&mut self, key: &str, value: &str)
fn delete(&mut self, key: &str) -> bool
fn exists(&self, key: &str) -> bool
fn list(&self) -> Vec<String>
Sourcefn watch(&self, key: &str) -> bool
fn watch(&self, key: &str) -> bool
Returns true if a watch was successfully registered. In this in-memory implementation, registration always succeeds.
Sourcefn subscribe(&mut self, key: &str, callback: ConfigChangeCallback)
fn subscribe(&mut self, key: &str, callback: ConfigChangeCallback)
Registers a callback for changes to key.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".