Skip to content

Commit

Permalink
Applying CR suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
zajko committed Jan 29, 2025
1 parent abe3a1a commit 9f7de56
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion metrics/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static RECONNECT_TIMES_MS: Lazy<Histogram> = Lazy::new(|| {
static MISMATCHED_IDS: Lazy<IntGauge> = Lazy::new(|| {
let counter = IntGauge::new(
"rpc_server_mismatched_ids",
"Number of mismathced id events observed in responses from binary port",
"Number of mismatched ID events observed in responses from binary port",
)
.expect("rpc_server_mismatched_ids metric can't be created");
REGISTRY
Expand Down
6 changes: 3 additions & 3 deletions rpc_sidecar/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const DEFAULT_EXPONENTIAL_BACKOFF_COEFFICIENT: u64 = 2;
/// Default keep alive timeout milliseconds.
const DEFAULT_KEEPALIVE_TIMEOUT_MS: u64 = 1_000;
/// Default max attempts
const DEFAULT_MAX_ATTEMPTS: u32 = 3;
const DEFAULT_EXPONENTIAL_BACKOFF_MAX_ATTEMPTS: u32 = 3;

/// Node client configuration.
#[derive(Clone, DataSize, Debug, Deserialize, PartialEq, Eq)]
Expand Down Expand Up @@ -134,7 +134,7 @@ impl NodeClientConfig {
initial_delay_ms: DEFAULT_EXPONENTIAL_BACKOFF_BASE_MS,
max_delay_ms: DEFAULT_EXPONENTIAL_BACKOFF_MAX_MS,
coefficient: DEFAULT_EXPONENTIAL_BACKOFF_COEFFICIENT,
max_attempts: DEFAULT_MAX_ATTEMPTS,
max_attempts: DEFAULT_EXPONENTIAL_BACKOFF_MAX_ATTEMPTS,
},
}
}
Expand All @@ -154,7 +154,7 @@ impl NodeClientConfig {
initial_delay_ms: DEFAULT_EXPONENTIAL_BACKOFF_BASE_MS,
max_delay_ms: DEFAULT_EXPONENTIAL_BACKOFF_MAX_MS,
coefficient: DEFAULT_EXPONENTIAL_BACKOFF_COEFFICIENT,
max_attempts: DEFAULT_MAX_ATTEMPTS,
max_attempts: DEFAULT_EXPONENTIAL_BACKOFF_MAX_ATTEMPTS,
},
}
}
Expand Down
3 changes: 1 addition & 2 deletions rpc_sidecar/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ use anyhow::Error;
use casper_binary_port::{BinaryRequest, BinaryRequestHeader};
use casper_types::bytesrepr::ToBytes;
use casper_types::{bytesrepr, ProtocolVersion};
pub use config::{FieldParseError, RpcServerConfig};
pub use config::{NodeClientConfig, RpcConfig};
pub use config::{FieldParseError, NodeClientConfig, RpcConfig, RpcServerConfig};
use futures::future::BoxFuture;
use futures::FutureExt;
pub use http_server::run as run_rpc_server;
Expand Down
9 changes: 4 additions & 5 deletions rpc_sidecar/src/node_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1034,9 +1034,10 @@ impl FramedNodeClient {
client.send(payload),
)
.await
.map_err(|_| Error::RequestFailed("timeout".to_owned()))?
{
.map_err(|_| {
register_timeout("sending_payload");
Error::RequestFailed("timeout".to_owned())
})? {
return Err(Error::RequestFailed(err.to_string()));
};

Expand Down Expand Up @@ -1162,8 +1163,6 @@ impl FramedNodeClient {
#[async_trait]
impl NodeClient for FramedNodeClient {
async fn send_request(&self, req: BinaryRequest) -> Result<BinaryResponseAndRequest, Error> {
// TODO: Use queue instead of individual timeouts. Currently it is possible to go pass the
// semaphore and the immediately wait for the client to become available.
let mut client = match tokio::time::timeout(
Duration::from_secs(self.config.client_access_timeout_secs),
self.client.write(),
Expand All @@ -1184,7 +1183,7 @@ impl NodeClient for FramedNodeClient {
err = display_error(&err),
"binary port client handler error"
);
// attempt to reconnect once in case the node was restarted and connection broke
// attempt to reconnect in case the node was restarted and connection broke
client.close().await.ok();
let ip_address = &self.config.ip_address;

Expand Down
2 changes: 1 addition & 1 deletion sidecar/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use tokio::{
};
use tracing::{error, info};

const MAX_COMPONENT_STARTUP_TIMEOUT_SECS: u64 = 120;
const MAX_COMPONENT_STARTUP_TIMEOUT_SECS: u64 = 30;

pub async fn run(config: SidecarConfig) -> Result<ExitCode, Error> {
let maybe_database = config
Expand Down

0 comments on commit 9f7de56

Please sign in to comment.