Skip to content

Commit

Permalink
fix(mempool_infra): change idle_timeout type from duarion to u64 (#1211)
Browse files Browse the repository at this point in the history
commit-id:6121cd39
  • Loading branch information
Itay-Tsabary-Starkware authored Oct 6, 2024
1 parent 43dd5d0 commit b912ed4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 35 deletions.
35 changes: 10 additions & 25 deletions config/mempool/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,9 @@
"value": 18446744073709551615
},
"components.batcher.remote_config.idle_timeout": {
"description": "The duration to keep an idle connection open before closing.",
"description": "The duration in seconds to keep an idle connection open before closing.",
"privacy": "Public",
"value": {
"nanos": 0,
"secs": 90
}
"value": 90
},
"components.batcher.remote_config.retries": {
"description": "The max number of retries for sending a message.",
Expand Down Expand Up @@ -138,12 +135,9 @@
"value": 18446744073709551615
},
"components.consensus_manager.remote_config.idle_timeout": {
"description": "The duration to keep an idle connection open before closing.",
"description": "The duration in seconds to keep an idle connection open before closing.",
"privacy": "Public",
"value": {
"nanos": 0,
"secs": 90
}
"value": 90
},
"components.consensus_manager.remote_config.retries": {
"description": "The max number of retries for sending a message.",
Expand Down Expand Up @@ -186,12 +180,9 @@
"value": 18446744073709551615
},
"components.gateway.remote_config.idle_timeout": {
"description": "The duration to keep an idle connection open before closing.",
"description": "The duration in seconds to keep an idle connection open before closing.",
"privacy": "Public",
"value": {
"nanos": 0,
"secs": 90
}
"value": 90
},
"components.gateway.remote_config.retries": {
"description": "The max number of retries for sending a message.",
Expand Down Expand Up @@ -234,12 +225,9 @@
"value": 18446744073709551615
},
"components.http_server.remote_config.idle_timeout": {
"description": "The duration to keep an idle connection open before closing.",
"description": "The duration in seconds to keep an idle connection open before closing.",
"privacy": "Public",
"value": {
"nanos": 0,
"secs": 90
}
"value": 90
},
"components.http_server.remote_config.retries": {
"description": "The max number of retries for sending a message.",
Expand Down Expand Up @@ -282,12 +270,9 @@
"value": 18446744073709551615
},
"components.mempool.remote_config.idle_timeout": {
"description": "The duration to keep an idle connection open before closing.",
"description": "The duration in seconds to keep an idle connection open before closing.",
"privacy": "Public",
"value": {
"nanos": 0,
"secs": 90
}
"value": 90
},
"components.mempool.remote_config.retries": {
"description": "The max number of retries for sending a message.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::fmt::Debug;
use std::marker::PhantomData;
use std::net::IpAddr;
use std::sync::Arc;
use std::time::Duration;

use hyper::body::to_bytes;
use hyper::header::CONTENT_TYPE;
Expand Down Expand Up @@ -30,8 +31,6 @@ use crate::serde_utils::BincodeSerdeWrapper;
/// ```rust
/// // Example usage of the RemoteComponentClient
///
/// use std::time::Duration;
///
/// use serde::{Deserialize, Serialize};
///
/// use crate::starknet_mempool_infra::component_client::RemoteComponentClient;
Expand Down Expand Up @@ -59,7 +58,7 @@ use crate::serde_utils::BincodeSerdeWrapper;
/// socket,
/// retries: 3,
/// idle_connections: usize::MAX,
/// idle_timeout: Duration::from_secs(90),
/// idle_timeout: 90,
/// };
/// let client = RemoteComponentClient::<MyRequest, MyResponse>::new(config);
///
Expand Down Expand Up @@ -104,7 +103,7 @@ where
let client = Client::builder()
.http2_only(true)
.pool_max_idle_per_host(config.idle_connections)
.pool_idle_timeout(config.idle_timeout)
.pool_idle_timeout(Duration::from_secs(config.idle_timeout))
.build_http();
Self { uri, client, config, _req: PhantomData, _res: PhantomData }
}
Expand Down
7 changes: 3 additions & 4 deletions crates/mempool_infra/src/component_definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::any::type_name;
use std::collections::BTreeMap;
use std::fmt::Debug;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use std::time::Duration;

use async_trait::async_trait;
use papyrus_config::dumping::{ser_param, SerializeConfig};
Expand All @@ -19,7 +18,7 @@ pub const APPLICATION_OCTET_STREAM: &str = "application/octet-stream";
const DEFAULT_CHANNEL_BUFFER_SIZE: usize = 32;
const DEFAULT_RETRIES: usize = 3;
const DEFAULT_IDLE_CONNECTIONS: usize = usize::MAX;
const DEFAULT_IDLE_TIMEOUT: Duration = Duration::from_secs(90);
const DEFAULT_IDLE_TIMEOUT: u64 = 90;

#[async_trait]
pub trait ComponentRequestHandler<Request, Response> {
Expand Down Expand Up @@ -97,7 +96,7 @@ pub struct RemoteComponentCommunicationConfig {
pub socket: SocketAddr,
pub retries: usize,
pub idle_connections: usize,
pub idle_timeout: Duration,
pub idle_timeout: u64,
}

impl SerializeConfig for RemoteComponentCommunicationConfig {
Expand All @@ -124,7 +123,7 @@ impl SerializeConfig for RemoteComponentCommunicationConfig {
ser_param(
"idle_timeout",
&self.idle_timeout,
"The duration to keep an idle connection open before closing.",
"The duration in seconds to keep an idle connection open before closing.",
ParamPrivacyInput::Public,
),
])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::fmt::Debug;
use std::net::SocketAddr;
use std::sync::Arc;
use std::time::Duration;

use async_trait::async_trait;
use hyper::body::to_bytes;
Expand Down Expand Up @@ -55,7 +54,7 @@ type ComponentAClient = RemoteComponentClient<ComponentARequest, ComponentARespo
type ComponentBClient = RemoteComponentClient<ComponentBRequest, ComponentBResponse>;

const MAX_IDLE_CONNECTION: usize = usize::MAX;
const IDLE_TIMEOUT: Duration = Duration::from_secs(90);
const IDLE_TIMEOUT: u64 = 90;
const MOCK_SERVER_ERROR: &str = "mock server error";
const ARBITRARY_DATA: &str = "arbitrary data";
// ServerError::RequestDeserializationFailure error message.
Expand Down

0 comments on commit b912ed4

Please sign in to comment.