/** * Canary / A-B routing for federation remotes. * * Map a remote name to several `FederationRemote` variants with weights; * `pickWeightedRemote()` resolves a single variant per request. Sticky-by-key * mode (default) makes a given user/session land on the same variant across * navigations — required for cache-busting and progressive rollouts. */ import type { FederationRemote } from './remote-loader.js'; export interface WeightedVariant { /** A `FederationRemote` plus its share of traffic. */ remote: FederationRemote; /** Relative weight. Must be > 0. Variants are normalized to sum to 1. */ weight: number; /** Optional label exposed via telemetry (e.g. 'v1', 'canary', 'rollout'). */ label?: string; } export interface WeightedRemoteEntry { /** Logical remote name (matches the host route table). */ name: string; variants: WeightedVariant[]; } export interface PickOptions { /** * Stable key per user/session. When provided, the same key always lands on * the same variant for the same `WeightedRemoteEntry`. Default: random. */ key?: string; /** Override the RNG (tests). Returns a number in [0, 1). */ random?: () => number; } export interface PickResult { remote: FederationRemote; variant: WeightedVariant; /** Hash bucket in [0, 1). Useful for logging. */ bucket: number; } /** Resolve a single variant for the entry. Throws on empty / invalid entries. */ export declare function pickWeightedRemote(entry: WeightedRemoteEntry, opts?: PickOptions): PickResult; /** * Resolve a whole `Record` into a flat * `Record` suitable for `RemoteOutlet` / `prefetchRoute`. * * Pass the same `key` you'd use in CDN cache-busting to keep a user pinned * across navigations. */ export declare function resolveWeightedRemotes(entries: Record, opts?: PickOptions): { remotes: Record; picks: Record; }; //# sourceMappingURL=weighted-remotes.d.ts.map