pub struct VariantManager { /* private fields */ }Expand description
Manages A/B test configurations and variants
Implementations§
Source§impl VariantManager
impl VariantManager
Sourcepub async fn register_test(&self, config: ABTestConfig) -> Result<()>
pub async fn register_test(&self, config: ABTestConfig) -> Result<()>
Register an A/B test configuration
Sourcepub async fn get_test(&self, method: &str, path: &str) -> Option<ABTestConfig>
pub async fn get_test(&self, method: &str, path: &str) -> Option<ABTestConfig>
Get A/B test configuration for an endpoint
Sourcepub async fn list_tests(&self) -> Vec<ABTestConfig>
pub async fn list_tests(&self) -> Vec<ABTestConfig>
List all registered A/B tests
Sourcepub async fn remove_test(&self, method: &str, path: &str) -> Result<()>
pub async fn remove_test(&self, method: &str, path: &str) -> Result<()>
Remove an A/B test configuration
Sourcepub async fn get_variant(
&self,
method: &str,
path: &str,
variant_id: &str,
) -> Option<MockVariant>
pub async fn get_variant( &self, method: &str, path: &str, variant_id: &str, ) -> Option<MockVariant>
Get a variant by ID for an endpoint
Sourcepub async fn record_request(
&self,
method: &str,
path: &str,
variant_id: &str,
status_code: u16,
response_time_ms: f64,
)
pub async fn record_request( &self, method: &str, path: &str, variant_id: &str, status_code: u16, response_time_ms: f64, )
Record analytics for a variant request
Sourcepub async fn get_variant_analytics(
&self,
method: &str,
path: &str,
variant_id: &str,
) -> Option<VariantAnalytics>
pub async fn get_variant_analytics( &self, method: &str, path: &str, variant_id: &str, ) -> Option<VariantAnalytics>
Get analytics for a variant
Sourcepub async fn get_endpoint_analytics(
&self,
method: &str,
path: &str,
) -> HashMap<String, VariantAnalytics>
pub async fn get_endpoint_analytics( &self, method: &str, path: &str, ) -> HashMap<String, VariantAnalytics>
Get all analytics for an endpoint
Sourcepub async fn get_round_robin_index(&self, method: &str, path: &str) -> usize
pub async fn get_round_robin_index(&self, method: &str, path: &str) -> usize
Get round-robin counter for an endpoint
Sourcepub async fn increment_round_robin(
&self,
method: &str,
path: &str,
max: usize,
) -> usize
pub async fn increment_round_robin( &self, method: &str, path: &str, max: usize, ) -> usize
Increment round-robin counter for an endpoint
Sourcepub fn consistent_hash(attribute: &str, num_variants: usize) -> usize
pub fn consistent_hash(attribute: &str, num_variants: usize) -> usize
Generate a consistent hash for a request attribute
This is used for consistent hashing strategy to ensure the same request attribute (e.g., user ID) always gets the same variant.
Trait Implementations§
Source§impl Clone for VariantManager
impl Clone for VariantManager
Source§fn clone(&self) -> VariantManager
fn clone(&self) -> VariantManager
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for VariantManager
impl Debug for VariantManager
Auto Trait Implementations§
impl Freeze for VariantManager
impl !RefUnwindSafe for VariantManager
impl Send for VariantManager
impl Sync for VariantManager
impl Unpin for VariantManager
impl !UnwindSafe for VariantManager
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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