pub struct Config {
pub profile: HashMap<String, Profile>,
pub cluster: HashMap<String, FluvioConfig>,
/* private fields */
}
Fields§
§profile: HashMap<String, Profile>
§cluster: HashMap<String, FluvioConfig>
Implementations§
source§impl Config
impl Config
pub fn new() -> Self
sourcepub fn new_with_local_cluster(domain: String) -> Self
pub fn new_with_local_cluster(domain: String) -> Self
create new config with a single local cluster
sourcepub fn add_cluster(&mut self, cluster: FluvioConfig, name: String)
pub fn add_cluster(&mut self, cluster: FluvioConfig, name: String)
add new cluster
pub fn add_profile(&mut self, profile: Profile, name: String)
pub fn version(&self) -> &str
sourcepub fn current_profile_name(&self) -> Option<&str>
pub fn current_profile_name(&self) -> Option<&str>
current profile
sourcepub fn set_current_profile(&mut self, profile_name: &str) -> bool
pub fn set_current_profile(&mut self, profile_name: &str) -> bool
set current profile, if profile doesn’t exists return false
pub fn rename_profile(&mut self, from: &str, to: String) -> bool
sourcepub fn delete_profile(&mut self, profile_name: &str) -> bool
pub fn delete_profile(&mut self, profile_name: &str) -> bool
delete profile
sourcepub fn delete_cluster(&mut self, cluster_name: &str) -> Option<FluvioConfig>
pub fn delete_cluster(&mut self, cluster_name: &str) -> Option<FluvioConfig>
Deletes the named cluster, whether it is being used or not.
You may want to check if the named cluster is active or not using
delete_cluster_check
. Otherwise, you may remove a cluster that
is being used by the active profile.
§Example
let mut config = Config::new();
let cluster = FluvioConfig::new("https://cloud.fluvio.io".to_string());
config.add_cluster(cluster, "fluvio-cloud".to_string());
let profile = Profile::new("fluvio-cloud".to_string());
config.add_profile(profile, "fluvio-cloud".to_string());
config.delete_cluster("fluvio-cloud").unwrap();
assert!(config.cluster("fluvio-cloud").is_none());
sourcepub fn delete_cluster_check(
&mut self,
cluster_name: &str
) -> Result<(), Vec<&str>>
pub fn delete_cluster_check( &mut self, cluster_name: &str ) -> Result<(), Vec<&str>>
Checks whether it’s safe to delete the named cluster
If there are any profiles that reference the named cluster,
they are considered conflicts and the cluster is unsafe to delete.
When conflicts exist, the conflicting profile names are returned
in the Err()
return value.
If there are no profile conflicts, this returns with Ok(())
.
§Example
let mut config = Config::new();
let cluster = FluvioConfig::new("https://cloud.fluvio.io".to_string());
config.add_cluster(cluster, "fluvio-cloud".to_string());
let profile = Profile::new("fluvio-cloud".to_string());
config.add_profile(profile, "fluvio-cloud".to_string());
let conflicts = config.delete_cluster_check("fluvio-cloud").unwrap_err();
assert_eq!(conflicts, vec!["fluvio-cloud"]);
sourcepub fn current_profile(&self) -> Result<&Profile, FluvioError>
pub fn current_profile(&self) -> Result<&Profile, FluvioError>
Returns a reference to the current Profile if there is one.
sourcepub fn profile(&self, profile_name: &str) -> Option<&Profile>
pub fn profile(&self, profile_name: &str) -> Option<&Profile>
Returns a reference to the current Profile if there is one.
sourcepub fn profile_mut(&mut self, profile_name: &str) -> Option<&mut Profile>
pub fn profile_mut(&mut self, profile_name: &str) -> Option<&mut Profile>
Returns a mutable reference to the current Profile if there is one.
sourcepub fn current_cluster(&self) -> Result<&FluvioConfig, FluvioError>
pub fn current_cluster(&self) -> Result<&FluvioConfig, FluvioError>
Returns the FluvioConfig belonging to the current profile.
sourcepub fn current_cluster_mut(&mut self) -> Result<&mut FluvioConfig, FluvioError>
pub fn current_cluster_mut(&mut self) -> Result<&mut FluvioConfig, FluvioError>
Returns the mutable reference to FluvioConfig belonging to the current profile.
sourcepub fn cluster_with_profile(&self, profile_name: &str) -> Option<&FluvioConfig>
pub fn cluster_with_profile(&self, profile_name: &str) -> Option<&FluvioConfig>
Returns the FluvioConfig belonging to the named profile.
sourcepub fn cluster(&self, cluster_name: &str) -> Option<&FluvioConfig>
pub fn cluster(&self, cluster_name: &str) -> Option<&FluvioConfig>
Returns a reference to the named FluvioConfig.
sourcepub fn cluster_mut(&mut self, cluster_name: &str) -> Option<&mut FluvioConfig>
pub fn cluster_mut(&mut self, cluster_name: &str) -> Option<&mut FluvioConfig>
Returns a mutable reference to the named FluvioConfig.
sourcepub fn resolve_replica_config(
&self,
_topic_name: &str,
_partition: i32
) -> Replica
pub fn resolve_replica_config( &self, _topic_name: &str, _partition: i32 ) -> Replica
look up replica config this will iterate and find all configuration that can resolve config
- match all config that matches criteria including asterisk
- apply in terms of precedent