Skip to main content

MultiCloudMultiRegionConfiguration

Struct MultiCloudMultiRegionConfiguration 

Source
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 in ProviderRegion.
  • T: The type of per-topology configuration data stored in Topology.

§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: RegionName

The 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>

Source

pub fn preferred_region(&self) -> Option<&ProviderRegion<R>>

Returns the preferred region, if found.

Source

pub fn lookup_region(&self, name: &RegionName) -> Option<ProviderRegion<R>>

Returns the named region or None if nothing.

Source

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>

Source

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

pub fn preferred(&self) -> &RegionName

Returns the preferred region for operations with region affinity.

Source

pub fn regions(&self) -> &[ProviderRegion<R>]

Returns the set of provider regions available in this configuration.

Source

pub fn topologies(&self) -> &[Topology<T>]

Returns the set of topologies defined over the provider regions.

Source

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.

Source

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

pub fn cast<R2, T2, FR, FT>( self, region_fn: FR, topology_fn: FT, ) -> MultiCloudMultiRegionConfiguration<R2, T2>
where R2: Clone + Debug, T2: Clone + Debug, FR: Fn(R) -> R2, FT: Fn(T) -> 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);
Source

pub fn try_cast<R2, T2, E, FR, FT>( self, region_fn: FR, topology_fn: FT, ) -> Result<MultiCloudMultiRegionConfiguration<R2, T2>, E>
where R2: Clone + Debug, T2: Clone + Debug, FR: Fn(R) -> Result<R2, E>, FT: Fn(T) -> Result<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");
Source

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>
where R2: Clone + Debug, T2: Clone + Debug, FR: Fn(R) -> FUT1, FT: Fn(T) -> FUT2, FUT1: Future<Output = Result<R2, E>> + Send, FUT2: Future<Output = Result<T2, E>> + Send,

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>

Source§

fn clone(&self) -> MultiCloudMultiRegionConfiguration<R, T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<R: Debug + Clone + Debug, T: Debug + Clone + Debug> Debug for MultiCloudMultiRegionConfiguration<R, T>

Source§

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

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

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>,

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

impl<R: PartialEq + Clone + Debug, T: PartialEq + Clone + Debug> PartialEq for MultiCloudMultiRegionConfiguration<R, T>

Source§

fn eq(&self, other: &MultiCloudMultiRegionConfiguration<R, T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<R, T> Serialize for MultiCloudMultiRegionConfiguration<R, T>
where R: Clone + Debug + Serialize, T: Clone + Debug + Serialize,

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

impl<R: Eq + Clone + Debug, T: Eq + Clone + Debug> Eq for MultiCloudMultiRegionConfiguration<R, T>

Source§

impl<R: Clone + Debug, T: Clone + Debug> StructuralPartialEq for MultiCloudMultiRegionConfiguration<R, T>

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

unsafe fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T