pub struct MultiCloudMultiRegionConfiguration<R: Clone + Debug, T: Clone + Debug> {
pub preferred: RegionName,
pub regions: Vec<ProviderRegion<R>>,
pub topologies: Vec<Topology<T>>,
}Expand description
Configuration for multi-cloud, multi-region deployments.
This type validates its invariants both during construction via new
and during deserialization. Invalid configurations will fail with a ValidationError.
The type has two generic parameters:
R: The type of per-region configuration data stored inProviderRegion.T: The type of per-topology configuration data stored inTopology.
§Example
use chroma_types::{
MultiCloudMultiRegionConfiguration, ProviderRegion, Topology,
RegionName, TopologyName,
};
let config = MultiCloudMultiRegionConfiguration::<(), ()>::new(
RegionName::new("aws-us-east-1").unwrap(),
vec![ProviderRegion::new(
RegionName::new("aws-us-east-1").unwrap(),
"aws",
"us-east-1",
(),
)],
vec![],
).expect("valid configuration");
assert_eq!(config.preferred().as_str(), "aws-us-east-1");Fields§
§preferred: RegionNameThe name of the preferred region for operations with region affinity.
regions: Vec<ProviderRegion<R>>The set of provider regions available in this configuration.
topologies: Vec<Topology<T>>The set of topologies defined over the provider regions.
Implementations§
Source§impl<R: Clone + Debug, T: Clone + Debug> MultiCloudMultiRegionConfiguration<R, T>
impl<R: Clone + Debug, T: Clone + Debug> MultiCloudMultiRegionConfiguration<R, T>
Sourcepub fn preferred_region(&self) -> Option<&ProviderRegion<R>>
pub fn preferred_region(&self) -> Option<&ProviderRegion<R>>
Returns the preferred region, if found.
Sourcepub fn lookup_region(&self, name: &RegionName) -> Option<ProviderRegion<R>>
pub fn lookup_region(&self, name: &RegionName) -> Option<ProviderRegion<R>>
Returns the named region or None if nothing.
Sourcepub fn lookup_topology(
&self,
name: &TopologyName,
) -> Option<(Vec<ProviderRegion<R>>, Topology<T>)>
pub fn lookup_topology( &self, name: &TopologyName, ) -> Option<(Vec<ProviderRegion<R>>, Topology<T>)>
Returns the regions for a configured topology or None if it doesn’t exist or references a non-existent region.
Source§impl<R: Clone + Debug, T: Clone + Debug> MultiCloudMultiRegionConfiguration<R, T>
impl<R: Clone + Debug, T: Clone + Debug> MultiCloudMultiRegionConfiguration<R, T>
Sourcepub fn new(
preferred: RegionName,
regions: Vec<ProviderRegion<R>>,
topologies: Vec<Topology<T>>,
) -> Result<Self, ValidationError>
pub fn new( preferred: RegionName, regions: Vec<ProviderRegion<R>>, topologies: Vec<Topology<T>>, ) -> Result<Self, ValidationError>
Creates and validates a new multi-cloud, multi-region configuration.
Returns an error if validation fails.
§Example
use chroma_types::{
MultiCloudMultiRegionConfiguration, ProviderRegion, Topology,
RegionName, TopologyName,
};
// Valid configuration
let config = MultiCloudMultiRegionConfiguration::new(
RegionName::new("aws-us-east-1").unwrap(),
vec![ProviderRegion::new(
RegionName::new("aws-us-east-1").unwrap(),
"aws",
"us-east-1",
(),
)],
vec![Topology::new(
TopologyName::new("default").unwrap(),
vec![RegionName::new("aws-us-east-1").unwrap()],
(),
)],
);
assert!(config.is_ok());
// Invalid configuration - preferred region doesn't exist
let config = MultiCloudMultiRegionConfiguration::<(), ()>::new(
RegionName::new("nonexistent").unwrap(),
vec![ProviderRegion::new(
RegionName::new("aws-us-east-1").unwrap(),
"aws",
"us-east-1",
(),
)],
vec![],
);
assert!(config.is_err());Sourcepub fn preferred(&self) -> &RegionName
pub fn preferred(&self) -> &RegionName
Returns the preferred region for operations with region affinity.
Sourcepub fn regions(&self) -> &[ProviderRegion<R>]
pub fn regions(&self) -> &[ProviderRegion<R>]
Returns the set of provider regions available in this configuration.
Sourcepub fn topologies(&self) -> &[Topology<T>]
pub fn topologies(&self) -> &[Topology<T>]
Returns the set of topologies defined over the provider regions.
Sourcepub fn validate(&self) -> Result<(), ValidationError>
pub fn validate(&self) -> Result<(), ValidationError>
Validates the configuration against the invariants.
Returns Ok(()) if validation passes, or a ValidationError describing any violations.
Each unique error is reported only once, even if it occurs multiple times.
Sourcepub fn preferred_region_config(&self) -> Option<&R>
pub fn preferred_region_config(&self) -> Option<&R>
Returns the configuration for the preferred region, if found.
Since the configuration validates that the preferred region exists during construction,
this method returns Some for valid configurations. It returns None only if the
internal state is inconsistent, which should not occur with properly constructed instances.
§Example
use chroma_types::{
MultiCloudMultiRegionConfiguration, ProviderRegion, RegionName,
};
let config = MultiCloudMultiRegionConfiguration::<String, ()>::new(
RegionName::new("aws-us-east-1").unwrap(),
vec![ProviderRegion::new(
RegionName::new("aws-us-east-1").unwrap(),
"aws",
"us-east-1",
"custom-config".to_string(),
)],
vec![],
).expect("valid configuration");
assert_eq!(config.preferred_region_config(), Some(&"custom-config".to_string()));Sourcepub fn cast<R2, T2, FR, FT>(
self,
region_fn: FR,
topology_fn: FT,
) -> MultiCloudMultiRegionConfiguration<R2, T2>
pub fn cast<R2, T2, FR, FT>( self, region_fn: FR, topology_fn: FT, ) -> MultiCloudMultiRegionConfiguration<R2, T2>
Transforms this configuration into a new type by applying functions to the region and topology configs.
This method consumes the configuration and produces a new one with different generic type parameters. The transformation functions are applied to each region config and topology config respectively.
§Example
use chroma_types::{
MultiCloudMultiRegionConfiguration, ProviderRegion, Topology,
RegionName, TopologyName,
};
let config = MultiCloudMultiRegionConfiguration::<i32, &str>::new(
RegionName::new("aws-us-east-1").unwrap(),
vec![ProviderRegion::new(
RegionName::new("aws-us-east-1").unwrap(),
"aws",
"us-east-1",
42,
)],
vec![Topology::new(
TopologyName::new("default").unwrap(),
vec![RegionName::new("aws-us-east-1").unwrap()],
"topology-config",
)],
).expect("valid configuration");
let transformed = config.cast(
|r| r.to_string(),
|t| t.len(),
);
assert_eq!(transformed.preferred_region_config(), Some(&"42".to_string()));
assert_eq!(transformed.topologies()[0].config(), &15);Sourcepub fn try_cast<R2, T2, E, FR, FT>(
self,
region_fn: FR,
topology_fn: FT,
) -> Result<MultiCloudMultiRegionConfiguration<R2, T2>, E>
pub fn try_cast<R2, T2, E, FR, FT>( self, region_fn: FR, topology_fn: FT, ) -> Result<MultiCloudMultiRegionConfiguration<R2, T2>, E>
Transforms this configuration into a new type by applying fallible functions to the region and topology configs.
This method consumes the configuration and produces a new one with different generic type parameters. The transformation functions are applied to each region config and topology config respectively. If any transformation fails, the error is returned immediately.
§Errors
Returns an error if any region or topology transformation function returns an error.
§Example
use chroma_types::{
MultiCloudMultiRegionConfiguration, ProviderRegion, Topology,
RegionName, TopologyName,
};
let config = MultiCloudMultiRegionConfiguration::<&str, i32>::new(
RegionName::new("aws-us-east-1").unwrap(),
vec![ProviderRegion::new(
RegionName::new("aws-us-east-1").unwrap(),
"aws",
"us-east-1",
"42",
)],
vec![Topology::new(
TopologyName::new("default").unwrap(),
vec![RegionName::new("aws-us-east-1").unwrap()],
100,
)],
).expect("valid configuration");
let result: Result<_, std::num::ParseIntError> = config.try_cast(
|r| r.parse::<i32>(),
|t| Ok(t.to_string()),
);
let transformed = result.expect("transformation should succeed");
assert_eq!(transformed.preferred_region_config(), Some(&42));
assert_eq!(transformed.topologies()[0].config(), "100");Sourcepub async fn try_cast_async<R2, T2, E, FR, FT, FUT1, FUT2>(
self,
region_fn: FR,
topology_fn: FT,
) -> Result<MultiCloudMultiRegionConfiguration<R2, T2>, E>
pub async fn try_cast_async<R2, T2, E, FR, FT, FUT1, FUT2>( self, region_fn: FR, topology_fn: FT, ) -> Result<MultiCloudMultiRegionConfiguration<R2, T2>, E>
Transforms this configuration into a new type by applying async fallible functions to the region and topology configs.
§Errors
Returns an error if any region or topology transformation function returns an error.
Trait Implementations§
Source§impl<R: Clone + Clone + Debug, T: Clone + Clone + Debug> Clone for MultiCloudMultiRegionConfiguration<R, T>
impl<R: Clone + Clone + Debug, T: Clone + Clone + Debug> Clone for MultiCloudMultiRegionConfiguration<R, T>
Source§fn clone(&self) -> MultiCloudMultiRegionConfiguration<R, T>
fn clone(&self) -> MultiCloudMultiRegionConfiguration<R, T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<R: Debug + Clone + Debug, T: Debug + Clone + Debug> Debug for MultiCloudMultiRegionConfiguration<R, T>
impl<R: Debug + Clone + Debug, T: Debug + Clone + Debug> Debug for MultiCloudMultiRegionConfiguration<R, T>
Source§impl<'de, R: Clone + Debug + Serialize + DeserializeOwned, T: Clone + Debug + Serialize + DeserializeOwned> Deserialize<'de> for MultiCloudMultiRegionConfiguration<R, T>
impl<'de, R: Clone + Debug + Serialize + DeserializeOwned, T: Clone + Debug + Serialize + DeserializeOwned> Deserialize<'de> for MultiCloudMultiRegionConfiguration<R, T>
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<R: PartialEq + Clone + Debug, T: PartialEq + Clone + Debug> PartialEq for MultiCloudMultiRegionConfiguration<R, T>
impl<R: PartialEq + Clone + Debug, T: PartialEq + Clone + Debug> PartialEq for MultiCloudMultiRegionConfiguration<R, T>
Source§fn eq(&self, other: &MultiCloudMultiRegionConfiguration<R, T>) -> bool
fn eq(&self, other: &MultiCloudMultiRegionConfiguration<R, T>) -> bool
self and other values to be equal, and is used by ==.Source§impl<R, T> Serialize for MultiCloudMultiRegionConfiguration<R, T>
impl<R, T> Serialize for MultiCloudMultiRegionConfiguration<R, T>
impl<R: Eq + Clone + Debug, T: Eq + Clone + Debug> Eq for MultiCloudMultiRegionConfiguration<R, T>
impl<R: Clone + Debug, T: Clone + Debug> StructuralPartialEq for MultiCloudMultiRegionConfiguration<R, T>
Auto Trait Implementations§
impl<R, T> Freeze for MultiCloudMultiRegionConfiguration<R, T>
impl<R, T> RefUnwindSafe for MultiCloudMultiRegionConfiguration<R, T>where
R: RefUnwindSafe,
T: RefUnwindSafe,
impl<R, T> Send for MultiCloudMultiRegionConfiguration<R, T>
impl<R, T> Sync for MultiCloudMultiRegionConfiguration<R, T>
impl<R, T> Unpin for MultiCloudMultiRegionConfiguration<R, T>
impl<R, T> UnwindSafe for MultiCloudMultiRegionConfiguration<R, T>where
R: UnwindSafe,
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.