Trait rocketmq_common::common::config_manager::ConfigManager
source · pub trait ConfigManager {
// Required methods
fn config_file_path(&self) -> String;
fn encode_pretty(&self, pretty_format: bool) -> String;
fn decode(&self, json_string: &str);
// Provided methods
fn load(&self) -> bool { ... }
fn load_bak(&self) -> bool { ... }
fn persist_with_topic<T>(&mut self, _topic_name: &str, _t: T) { ... }
fn persist_map<T>(&mut self, _m: &HashMap<String, T>) { ... }
fn persist(&self) { ... }
fn decode0(&mut self, _key: &[u8], _body: &[u8]) { ... }
fn stop(&mut self) -> bool { ... }
fn encode(&mut self) -> String { ... }
}Required Methods§
sourcefn config_file_path(&self) -> String
fn config_file_path(&self) -> String
Returns the path of the configuration file.
This method is a placeholder for returning the path of the configuration file. The actual implementation should be provided by the implementer of the trait.
sourcefn encode_pretty(&self, pretty_format: bool) -> String
fn encode_pretty(&self, pretty_format: bool) -> String
Encodes the configuration with pretty format.
This method is a placeholder for encoding the configuration with pretty format. The actual implementation should be provided by the implementer of the trait.
Provided Methods§
sourcefn load(&self) -> bool
fn load(&self) -> bool
Loads the configuration from a file.
This method attempts to load the configuration from a file whose path is returned by
config_file_path. If the file content is empty, it attempts to load from a backup
file. If the file content is not empty, it decodes the content and logs a success
message.
§Returns
trueif the configuration is successfully loaded and decoded.falseif the configuration loading fails.
sourcefn load_bak(&self) -> bool
fn load_bak(&self) -> bool
Loads the configuration from a backup file.
This method attempts to load the configuration from a backup file whose path is returned by
config_file_path with “.bak” appended. If the file content is not empty, it decodes
the content and logs a success message.
§Returns
trueif the configuration is successfully loaded and decoded.falseif the configuration loading fails.
sourcefn persist_with_topic<T>(&mut self, _topic_name: &str, _t: T)
fn persist_with_topic<T>(&mut self, _topic_name: &str, _t: T)
Persists the configuration with a topic.
This method persists the configuration with a given topic.
The actual implementation is delegated to the persist method.
sourcefn persist_map<T>(&mut self, _m: &HashMap<String, T>)
fn persist_map<T>(&mut self, _m: &HashMap<String, T>)
Persists the configuration with a map.
This method persists the configuration with a given map.
The actual implementation is delegated to the persist method.
sourcefn persist(&self)
fn persist(&self)
Persists the configuration.
This method persists the configuration to a file whose path is returned by
config_file_path. If the encoded configuration is not empty, it writes the
configuration to the file.
sourcefn decode0(&mut self, _key: &[u8], _body: &[u8])
fn decode0(&mut self, _key: &[u8], _body: &[u8])
Decodes the configuration.
This method is a placeholder for decoding the configuration. The actual implementation should be provided by the implementer of the trait.