pub struct AbTestManager { /* private fields */ }Expand description
Manages multi-variant A/B experiments.
Implementations§
Source§impl AbTestManager
impl AbTestManager
Sourcepub fn create_experiment(&mut self, experiment: Experiment)
pub fn create_experiment(&mut self, experiment: Experiment)
Register a new experiment.
Sourcepub fn assign(&self, experiment_id: &str, user_id: &str) -> Option<Assignment>
pub fn assign(&self, experiment_id: &str, user_id: &str) -> Option<Assignment>
Deterministically assign a user to a variant using weighted FNV hash.
Returns None if the experiment doesn’t exist or is not Running.
Sourcepub fn record_outcome(
&mut self,
assignment: &Assignment,
success: bool,
cost: f64,
latency_ms: u64,
)
pub fn record_outcome( &mut self, assignment: &Assignment, success: bool, cost: f64, latency_ms: u64, )
Record an outcome for a previously made assignment.
Sourcepub fn results(&self, experiment_id: &str) -> Vec<ExperimentResult>
pub fn results(&self, experiment_id: &str) -> Vec<ExperimentResult>
Return aggregated results for all variants in an experiment.
Sourcepub fn statistical_significance(
r_a: &ExperimentResult,
r_b: &ExperimentResult,
) -> f64
pub fn statistical_significance( r_a: &ExperimentResult, r_b: &ExperimentResult, ) -> f64
Two-proportion z-test significance.
Returns p-value approximation using erfc: p = erfc(|z| / sqrt(2)).
Sourcepub fn winner(&self, experiment_id: &str) -> Option<String>
pub fn winner(&self, experiment_id: &str) -> Option<String>
Return the variant ID with the highest conversion rate if statistically significant (z > 1.96 for p < 0.05), or None.
Sourcepub fn auto_complete(&mut self, experiment_id: &str, now: u64) -> bool
pub fn auto_complete(&mut self, experiment_id: &str, now: u64) -> bool
Check end condition and mark experiment completed if met. Returns true if completed.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AbTestManager
impl RefUnwindSafe for AbTestManager
impl Send for AbTestManager
impl Sync for AbTestManager
impl Unpin for AbTestManager
impl UnsafeUnpin for AbTestManager
impl UnwindSafe for AbTestManager
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
Wrap the input message
T in a tonic::Request