#[non_exhaustive]pub struct TrafficSplit {
pub shard_by: ShardBy,
pub allocations: HashMap<String, f64>,
/* private fields */
}Expand description
Traffic routing configuration for versions within a single service. Traffic splits define how traffic directed to the service is assigned to versions.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.shard_by: ShardByMechanism used to determine which version a request is sent to. The traffic selection algorithm will be stable for either type until allocations are changed.
allocations: HashMap<String, f64>Mapping from version IDs within the service to fractional (0.000, 1] allocations of traffic for that version. Each version can be specified only once, but some versions in the service may not have any traffic allocation. Services that have traffic allocated cannot be deleted until either the service is deleted or their traffic allocation is removed. Allocations must sum to 1. Up to two decimal place precision is supported for IP-based splits and up to three decimal places is supported for cookie-based splits.
Implementations§
Source§impl TrafficSplit
impl TrafficSplit
Sourcepub fn set_shard_by<T: Into<ShardBy>>(self, v: T) -> Self
pub fn set_shard_by<T: Into<ShardBy>>(self, v: T) -> Self
Sourcepub fn set_allocations<T, K, V>(self, v: T) -> Self
pub fn set_allocations<T, K, V>(self, v: T) -> Self
Sets the value of allocations.
§Example
let x = TrafficSplit::new().set_allocations([
("key0", 123.5),
("key1", 456.5),
]);Trait Implementations§
Source§impl Clone for TrafficSplit
impl Clone for TrafficSplit
Source§fn clone(&self) -> TrafficSplit
fn clone(&self) -> TrafficSplit
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TrafficSplit
impl Debug for TrafficSplit
Source§impl Default for TrafficSplit
impl Default for TrafficSplit
Source§fn default() -> TrafficSplit
fn default() -> TrafficSplit
Source§impl Message for TrafficSplit
impl Message for TrafficSplit
Source§impl PartialEq for TrafficSplit
impl PartialEq for TrafficSplit
impl StructuralPartialEq for TrafficSplit
Auto Trait Implementations§
impl Freeze for TrafficSplit
impl RefUnwindSafe for TrafficSplit
impl Send for TrafficSplit
impl Sync for TrafficSplit
impl Unpin for TrafficSplit
impl UnsafeUnpin for TrafficSplit
impl UnwindSafe for TrafficSplit
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> 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::Request