Add builder header timeout flag (#5857)

* fix bitvector test random impl

* add a new flag that allows for configuring the timeout for get builder header api calls

* make cli

* add upper limit check, changes based on feedback

* update cli

* capitalization

* cli fix
This commit is contained in:
Eitan Seri-Levi
2024-05-31 05:35:57 +02:00
committed by GitHub
parent bbe9242811
commit fbc230e118
7 changed files with 80 additions and 8 deletions

View File

@@ -29,10 +29,13 @@ pub struct Timeouts {
get_builder_status: Duration,
}
impl Default for Timeouts {
fn default() -> Self {
impl Timeouts {
fn new(get_header_timeout: Option<Duration>) -> Self {
let get_header =
get_header_timeout.unwrap_or(Duration::from_millis(DEFAULT_GET_HEADER_TIMEOUT_MILLIS));
Self {
get_header: Duration::from_millis(DEFAULT_GET_HEADER_TIMEOUT_MILLIS),
get_header,
post_validators: Duration::from_millis(DEFAULT_TIMEOUT_MILLIS),
post_blinded_blocks: Duration::from_millis(DEFAULT_TIMEOUT_MILLIS),
get_builder_status: Duration::from_millis(DEFAULT_TIMEOUT_MILLIS),
@@ -49,13 +52,17 @@ pub struct BuilderHttpClient {
}
impl BuilderHttpClient {
pub fn new(server: SensitiveUrl, user_agent: Option<String>) -> Result<Self, Error> {
pub fn new(
server: SensitiveUrl,
user_agent: Option<String>,
builder_header_timeout: Option<Duration>,
) -> Result<Self, Error> {
let user_agent = user_agent.unwrap_or(DEFAULT_USER_AGENT.to_string());
let client = reqwest::Client::builder().user_agent(&user_agent).build()?;
Ok(Self {
client,
server,
timeouts: Timeouts::default(),
timeouts: Timeouts::new(builder_header_timeout),
user_agent,
})
}