use super::*;
#[derive(Clone, Debug, Eq, Getter, PartialEq)]
pub struct VariantWeight {
pub(crate) name: String,
#[get(type(copy))]
pub(crate) weight_bps: u16,
}
#[derive(Clone, Data, Debug, Eq, PartialEq)]
pub struct ExperimentRule {
pub(crate) name: String,
pub(crate) path_prefix: String,
pub(crate) variants: Vec<VariantWeight>,
pub(crate) default_variant: String,
}
#[derive(Clone, Debug, Eq, Getter, PartialEq)]
pub struct CanaryDecision {
pub(crate) experiment: String,
pub(crate) variant: String,
#[get(type(copy))]
pub(crate) bucket: u16,
#[get(type(copy))]
pub(crate) overridden: bool,
}
#[derive(Clone, Data, Debug, Eq, PartialEq)]
pub struct CanaryConfig {
pub(crate) experiments: Vec<ExperimentRule>,
pub(crate) sticky_header: String,
pub(crate) sticky_cookie: Option<String>,
pub(crate) override_header: Option<String>,
pub(crate) variant_response_header: String,
#[get(type(copy))]
pub(crate) emit_vary: bool,
}
#[derive(Clone, Debug)]
pub(crate) struct CompiledExperiment {
pub(crate) name: String,
pub(crate) prefix: String,
pub(crate) cumulative: Box<[(u16, String)]>,
pub(crate) default_variant: String,
}
#[derive(Clone, Debug)]
pub struct CanaryPlugin {
pub(crate) config: CanaryConfig,
pub(crate) rules: Box<[CompiledExperiment]>,
pub(crate) sticky_header_lower: String,
pub(crate) override_header_lower: Option<String>,
pub(crate) variant_header_lower: String,
}
#[derive(Clone, Copy, Debug, Default)]
#[hyperlane::request_middleware(-88)]
pub struct CanaryRequestHook;
#[derive(Clone, Copy, Debug, Default)]
#[hyperlane::response_middleware(-68)]
pub struct CanaryResponseHook;