pub struct ExposureTracker { /* private fields */ }Expand description
Best-effort, deduped experiment-exposure reporter. Reads stay non-blocking: the POST runs on a spawned thread and only marks the persistent dedup ledger on success, so a failed report is retried on the next read.
pending is an in-memory set of "scope\0experiment_id\0variant_id" keys
that are currently in-flight or already persisted. It prevents spawning
duplicate threads for rapid back-to-back reads before the first thread’s
HTTP round-trip has completed.
Implementations§
Source§impl ExposureTracker
impl ExposureTracker
pub fn new( repo: ExposureRepo, http: Option<Arc<HttpClient>>, clock: Option<Arc<dyn Clock>>, identity: Arc<IdentityManager>, ) -> Arc<Self>
Sourcepub fn maybe_track(self: &Arc<Self>, assignment: &ExperimentAssignment)
pub fn maybe_track(self: &Arc<Self>, assignment: &ExperimentAssignment)
Fire-and-forget exposure report for assignment. If http or clock are
absent (unconfigured SDK), does nothing. Deduplicates via the persistent
ExposureRepo ledger (checked synchronously before spawning) and via an
in-memory pending set (blocks duplicate spawns for the same triple
while the first thread’s POST is in flight).