Skip to content

Commit

Permalink
Add Fixed-Rate Polling Specifier To ReportCollector (#1492)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyurek authored Dec 12, 2024
1 parent 4f112ad commit 3438da1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
9 changes: 9 additions & 0 deletions ipa-core/src/bin/report_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ enum ReportCollectorCommand {
/// Number of records to aggregate
#[clap(long, short = 'n')]
count: u32,

// If set, use the specified fixed polling interval when running a query.
// Otherwise, use exponential backoff.
#[clap(long)]
set_fixed_polling_ms: Option<u64>,
},
}

Expand Down Expand Up @@ -264,13 +269,15 @@ async fn main() -> Result<(), Box<dyn Error>> {
ref encrypted_inputs,
hybrid_query_config,
count,
set_fixed_polling_ms,
} => {
hybrid(
&args,
hybrid_query_config,
clients,
encrypted_inputs,
count.try_into().expect("u32 should fit into usize"),
set_fixed_polling_ms,
)
.await?
}
Expand Down Expand Up @@ -421,6 +428,7 @@ async fn hybrid(
helper_clients: Vec<[IpaHttpClient<Helper>; 3]>,
encrypted_inputs: &EncryptedInputs,
count: usize,
set_fixed_polling_ms: Option<u64>,
) -> Result<(), Box<dyn Error>> {
let query_type = QueryType::MaliciousHybrid(hybrid_query_config);

Expand Down Expand Up @@ -471,6 +479,7 @@ async fn hybrid(
helper_clients,
query_id,
hybrid_query_config,
set_fixed_polling_ms,
)
.await;

Expand Down
11 changes: 9 additions & 2 deletions ipa-core/src/cli/playbook/hybrid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub async fn run_hybrid_query_and_validate<HV>(
clients: Vec<[IpaHttpClient<Helper>; 3]>,
query_id: QueryId,
query_config: HybridQueryParams,
set_fixed_polling_ms: Option<u64>,
) -> HybridQueryResult
where
HV: SharedValue + U128Conversions,
Expand All @@ -56,7 +57,11 @@ where

let leader_clients = &clients[0];

let mut delay = Duration::from_millis(125);
let (exponential_backoff, mut delay) = match set_fixed_polling_ms {
Some(specified_delay) => (false, Duration::from_millis(specified_delay)),
None => (true, Duration::from_millis(125)),
};

loop {
if try_join_all(
leader_clients
Expand All @@ -72,7 +77,9 @@ where
}

sleep(delay).await;
delay = min(Duration::from_secs(5), delay * 2);
if exponential_backoff {
delay = min(Duration::from_secs(5), delay * 2);
}
// TODO: Add a timeout of some sort. Possibly, add some sort of progress indicator to
// the status API so we can check whether the query is making progress.
}
Expand Down

0 comments on commit 3438da1

Please sign in to comment.