Skip to content

Commit 01336a1

Browse files
committed
feat: add timeout config for RAV request
Signed-off-by: Alexis Asseman <[email protected]>
1 parent 692bf46 commit 01336a1

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

tap-agent/src/config.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,14 @@ pub struct Tap {
231231
default_value_t = 1_000_000_000 // 1 second
232232
)]
233233
pub rav_request_timestamp_buffer_ns: u64,
234+
#[clap(
235+
long,
236+
value_name = "rav-request-timeout",
237+
env = "RAV_REQUEST_TIMEOUT",
238+
help = "Timeout (in seconds) for RAV requests.",
239+
default_value_t = 5
240+
)]
241+
pub rav_request_timeout_secs: u64,
234242

235243
// TODO: Remove this whenever the the gateway registry is ready
236244
#[clap(

tap-agent/src/tap/sender_allocation_relationship.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2023-, GraphOps and Semiotic Labs.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
use std::{collections::HashMap, sync::Arc};
4+
use std::{collections::HashMap, sync::Arc, time::Duration};
55

66
use alloy_primitives::Address;
77
use alloy_sol_types::Eip712Domain;
@@ -295,9 +295,12 @@ impl SenderAllocationRelationship {
295295
.await?;
296296

297297
// TODO: Request compression and response decompression. Also a fancy user agent?
298-
let client = HttpClientBuilder::default().build(&inner.sender_aggregator_endpoint)?;
298+
let client = HttpClientBuilder::default()
299+
.request_timeout(Duration::from_secs(
300+
inner.config.tap.rav_request_timeout_secs,
301+
))
302+
.build(&inner.sender_aggregator_endpoint)?;
299303

300-
// TODO: Add a timeout.
301304
let response: JsonRpcResponse<EIP712SignedMessage<ReceiptAggregateVoucher>> = client
302305
.request(
303306
"aggregate_receipts",
@@ -440,6 +443,7 @@ mod tests {
440443
tap: config::Tap {
441444
rav_request_trigger_value: 100,
442445
rav_request_timestamp_buffer_ns: 1000,
446+
rav_request_timeout_secs: 5,
443447
..Default::default()
444448
},
445449
..Default::default()

0 commit comments

Comments
 (0)