OxL Справочник OxL
РусскийEnglish

module std.ab

std.ab — A/B experiments (§18.5, D-6850..D-6862).

A test ab "name" { variant a = current; variant b = candidate; split by .User 50/50; … } declares an experiment. The code that serves the experiment asks which variant the current request belongs to:

oxl
match ab.variant("search v2") {
  "b" => newSearch(q)
  _ => oldSearch(q)
}
  • under oxl test --kind ab the recorded traffic is replayed and every request is put into a variant by the hash of its split key;
  • in a cluster oxl ab start "name" creates the dynamic Flag oxl.ab.<name> (percent = share of the second variant, by = the split): the same key always lands in the same variant, and the handler's latency and outcome count for that variant; a violated guard turns the flag off (audited);
  • without a running experiment every request gets the control (the first variant).

Intrinsic: runtime/src/ab/ab_live.cpp.

Example:

oxl✓ проверяется в CI
use std.ab { ab }

fn search(q: str) -> str io {
  match ab.variant("search v2") {
    "b" => "new engine for {q}"
    _ => "old engine for {q}"
  }
}

fn main() io {
  // without a running experiment every request gets the control variant
  print(search("shoes"))
}
Вывод
old engine for shoes

Типы

data abNamespace of the experiment functions.

См. также