Struct fluvio::config::Config

source ·
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

source

pub fn new() -> Self

source

pub fn new_with_local_cluster(domain: String) -> Self

create new config with a single local cluster

source

pub fn add_cluster(&mut self, cluster: FluvioConfig, name: String)

add new cluster

source

pub fn add_profile(&mut self, profile: Profile, name: String)

source

pub fn version(&self) -> &str

source

pub fn current_profile_name(&self) -> Option<&str>

current profile

source

pub fn set_current_profile(&mut self, profile_name: &str) -> bool

set current profile, if profile doesn’t exists return false

source

pub fn rename_profile(&mut self, from: &str, to: String) -> bool

source

pub fn delete_profile(&mut self, profile_name: &str) -> bool

delete profile

source

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());
source

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"]);
source

pub fn current_profile(&self) -> Result<&Profile, FluvioError>

Returns a reference to the current Profile if there is one.

source

pub fn profile(&self, profile_name: &str) -> Option<&Profile>

Returns a reference to the current Profile if there is one.

source

pub fn profile_mut(&mut self, profile_name: &str) -> Option<&mut Profile>

Returns a mutable reference to the current Profile if there is one.

source

pub fn current_cluster(&self) -> Result<&FluvioConfig, FluvioError>

Returns the FluvioConfig belonging to the current profile.

source

pub fn current_cluster_mut(&mut self) -> Result<&mut FluvioConfig, FluvioError>

Returns the mutable reference to FluvioConfig belonging to the current profile.

source

pub fn cluster_with_profile(&self, profile_name: &str) -> Option<&FluvioConfig>

Returns the FluvioConfig belonging to the named profile.

source

pub fn cluster(&self, cluster_name: &str) -> Option<&FluvioConfig>

Returns a reference to the named FluvioConfig.

source

pub fn cluster_mut(&mut self, cluster_name: &str) -> Option<&mut FluvioConfig>

Returns a mutable reference to the named FluvioConfig.

source

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

  1. match all config that matches criteria including asterisk
  2. apply in terms of precedent

Trait Implementations§

source§

impl Debug for Config

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Config

source§

fn default() -> Config

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Config

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Serialize for Config

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<S> SaveLoadConfig for S

source§

fn save_to<T>(&self, path: T) -> Result<(), Error>
where T: AsRef<Path>,

source§

fn load_from<T>(path: T) -> Result<S, LoadConfigError>
where T: AsRef<Path>,

source§

fn load_str(config: &str) -> Result<S, LoadConfigError>

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> AsyncConnector for T
where T: Send + Sync,

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,