Expand description
A DAP-PPM collector
This library implements the collector role of the DAP-PPM protocol. It works in concert with two DAP-PPM aggregator servers to compute a statistical aggregate over data from many clients, while preserving the privacy of each client’s data.
§Examples
Initialize an instance of Collector.
use std::{fs::File, str::FromStr};
use janus_collector::{Collector, PrivateCollectorCredential};
use janus_messages::{Duration, FixedSizeQuery, Interval, Query, TaskId, Time};
use prio::vdaf::prio3::Prio3;
use url::Url;
let task_id = TaskId::from_str("[your DAP task ID here]").unwrap();
let collector_credential: PrivateCollectorCredential =
serde_json::from_reader(File::open("[path to JSON encoded collector credential]").unwrap())
.unwrap();
let leader_url =
Url::from_str("[absolute URI to the DAP leader, e.g. https://leader.dap.example.com/]")
.unwrap();
// Supply a VDAF implementation, corresponding to this task.
let vdaf = Prio3::new_count(2).unwrap();
let collector = Collector::new(
task_id,
leader_url,
collector_credential.authentication_token(),
collector_credential.hpke_keypair(),
vdaf,
)
.unwrap();
// If this is a time interval task, specify the time interval over which the aggregation
// should be calculated.
let interval = Interval::new(
Time::from_seconds_since_epoch(1_656_000_000),
Duration::from_seconds(3600),
)
.unwrap();
// Make the requests and retrieve the aggregated statistic.
let aggregation_result = collector
.collect(Query::new_time_interval(interval), &())
.await
.unwrap();
// Or if this is a fixed size task, make a fixed size query.
let query = Query::new_fixed_size(FixedSizeQuery::CurrentBatch);
let aggregation_result = collector.collect(query, &()).await.unwrap();Re-exports§
pub use retry_after;
Structs§
- Collection
- The result of a collection operation.
- Collection
Job - Collector state related to a collection job that is in progress.
- Collector
- A DAP collector.
- Collector
Builder - Builder for configuring a
Collector. - Private
Collector Credential - Serializable representation of a private collector credential, which contains all secrets a collector uses to interact with an aggregator.
Enums§
- Authentication
Token - Different modes of authentication supported by Janus for either sending requests (e.g., leader to helper) or receiving them (e.g., collector to leader).
- Error
- Errors that may occur when performing collections.
- Poll
Result - The result of a collection request poll operation. This will either provide the collection result or indicate that the collection is still being processed.
Functions§
- default_
http_ client - Construct a
reqwest::Clientsuitable for use in a DAPCollector.
Type Aliases§
- Exponential
Backoff - Exponential backoff policy with system’s clock.