Skip to main content

ConfigCenter

Trait ConfigCenter 

Source
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§

Source

fn get(&self, key: &str) -> Option<String>

Source

fn set(&mut self, key: &str, value: &str)

Source

fn delete(&mut self, key: &str) -> bool

Source

fn exists(&self, key: &str) -> bool

Source

fn list(&self) -> Vec<String>

Source

fn watch(&self, key: &str) -> bool

Returns true if a watch was successfully registered. In this in-memory implementation, registration always succeeds.

Source

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".

Implementors§