Skip to content

Commit

Permalink
chore(infra_utils): apply short name throughout
Browse files Browse the repository at this point in the history
commit-id:fe72f3a3
  • Loading branch information
Itay-Tsabary-Starkware committed Dec 15, 2024
1 parent 2279521 commit 504d06a
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 24 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/starknet_consensus_manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ workspace = true
[dependencies]
async-trait.workspace = true
futures.workspace = true
infra_utils.workspace = true
papyrus_config.workspace = true
papyrus_consensus.workspace = true
papyrus_consensus_orchestrator.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions crates/starknet_consensus_manager/src/consensus_manager.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::any::type_name;
use std::sync::Arc;

use async_trait::async_trait;
use infra_utils::type_name::short_type_name;
use papyrus_consensus::stream_handler::StreamHandler;
use papyrus_consensus::types::ConsensusError;
use papyrus_consensus_orchestrator::sequencer_consensus_context::SequencerConsensusContext;
Expand Down Expand Up @@ -112,7 +112,7 @@ pub fn create_consensus_manager(
#[async_trait]
impl ComponentStarter for ConsensusManager {
async fn start(&mut self) -> Result<(), ComponentError> {
info!("Starting component {}.", type_name::<Self>());
info!("Starting component {}.", short_type_name::<Self>());
self.run().await.map_err(|e| {
error!("Error running component ConsensusManager: {:?}", e);
ComponentError::InternalComponentError
Expand Down
1 change: 1 addition & 0 deletions crates/starknet_http_server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ workspace = true
[dependencies]
axum.workspace = true
hyper.workspace = true
infra_utils.workspace = true
papyrus_config.workspace = true
reqwest = { workspace = true, optional = true }
serde.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions crates/starknet_http_server/src/http_server.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::any::type_name;
use std::clone::Clone;
use std::net::SocketAddr;

use axum::extract::State;
use axum::routing::post;
use axum::{async_trait, Json, Router};
use infra_utils::type_name::short_type_name;
use starknet_api::rpc_transaction::RpcTransaction;
use starknet_api::transaction::TransactionHash;
use starknet_gateway_types::communication::SharedGatewayClient;
Expand Down Expand Up @@ -89,7 +89,7 @@ pub fn create_http_server(
#[async_trait]
impl ComponentStarter for HttpServer {
async fn start(&mut self) -> Result<(), ComponentError> {
info!("Starting component {}.", type_name::<Self>());
info!("Starting component {}.", short_type_name::<Self>());
self.run().await.map_err(|_| ComponentError::InternalComponentError)
}
}
4 changes: 2 additions & 2 deletions crates/starknet_monitoring_endpoint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ repository.workspace = true
license-file.workspace = true

[features]
testing = ["infra_utils", "tokio", "tower"]
testing = ["tokio", "tower"]

[lints]
workspace = true

[dependencies]
axum.workspace = true
hyper = { workspace = true }
infra_utils = { workspace = true, optional = true }
infra_utils.workspace = true
metrics-exporter-prometheus.workspace = true
papyrus_config.workspace = true
serde.workspace = true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::any::type_name;
use std::net::SocketAddr;

use axum::http::StatusCode;
use axum::response::{IntoResponse, Response};
use axum::routing::get;
use axum::{async_trait, Router, Server};
use hyper::Error;
use infra_utils::type_name::short_type_name;
use metrics_exporter_prometheus::{PrometheusBuilder, PrometheusHandle};
use starknet_sequencer_infra::component_definitions::ComponentStarter;
use starknet_sequencer_infra::errors::ComponentError;
Expand Down Expand Up @@ -95,7 +95,7 @@ pub fn create_monitoring_endpoint(
#[async_trait]
impl ComponentStarter for MonitoringEndpoint {
async fn start(&mut self) -> Result<(), ComponentError> {
info!("Starting component {}.", type_name::<Self>());
info!("Starting component {}.", short_type_name::<Self>());
self.run().await.map_err(|_| ComponentError::InternalComponentError)
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/starknet_sequencer_infra/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ workspace = true
[dependencies]
async-trait.workspace = true
hyper = { workspace = true, features = ["client", "http2", "server", "tcp"] }
infra_utils.workspace = true
papyrus_config.workspace = true
rstest.workspace = true
serde = { workspace = true, features = ["derive"] }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::any::type_name;

use async_trait::async_trait;
use infra_utils::type_name::short_type_name;
use serde::de::DeserializeOwned;
use serde::Serialize;
use tokio::sync::mpsc::{channel, Sender};
Expand Down Expand Up @@ -103,7 +102,7 @@ where
Response: Send + Sync,
{
fn drop(&mut self) {
info!("Dropping LocalComponentClient {}.", type_name::<Self>());
info!("Dropping local client {}.", short_type_name::<Self>());
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/starknet_sequencer_infra/src/component_definitions.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::any::type_name;
use std::collections::BTreeMap;
use std::fmt::Debug;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};

use async_trait::async_trait;
use infra_utils::type_name::short_type_name;
use papyrus_config::dumping::{ser_param, SerializeConfig};
use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam};
use serde::de::DeserializeOwned;
Expand Down Expand Up @@ -39,7 +39,7 @@ where
#[async_trait]
pub trait ComponentStarter {
async fn start(&mut self) -> Result<(), ComponentError> {
info!("Starting component {} with the default starter.", type_name::<Self>());
info!("Starting component {} with the default starter.", short_type_name::<Self>());
Ok(())
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::any::type_name;

use async_trait::async_trait;
use infra_utils::type_name::short_type_name;
use tracing::info;

use crate::component_definitions::ComponentStarter;
Expand All @@ -20,9 +19,9 @@ impl<Component: Send> WrapperServer<Component> {
#[async_trait]
impl<Component: ComponentStarter + Send> ComponentServerStarter for WrapperServer<Component> {
async fn start(&mut self) -> Result<(), ComponentServerError> {
info!("Starting WrapperServer for {}.", type_name::<Component>());
info!("Starting WrapperServer for {}.", short_type_name::<Component>());
let res = self.component.start().await.map_err(ComponentServerError::ComponentError);
info!("Finished running WrapperServer for {}.", type_name::<Component>());
info!("Finished running WrapperServer for {}.", short_type_name::<Component>());
res
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::any::type_name;
use std::fmt::Debug;
use std::marker::PhantomData;

use async_trait::async_trait;
use infra_utils::type_name::short_type_name;
use tokio::sync::mpsc::Receiver;
use tracing::{debug, error, info};

Expand Down Expand Up @@ -126,10 +126,10 @@ where
Response: Send + Sync + Debug,
{
async fn start(&mut self) -> Result<(), ComponentServerError> {
info!("Starting LocalComponentServer for {}.", type_name::<Component>());
info!("Starting LocalComponentServer for {}.", short_type_name::<Component>());
self.component.start().await?;
request_response_loop(&mut self.rx, &mut self.component).await;
info!("Finished LocalComponentServer for {}.", type_name::<Component>());
info!("Finished LocalComponentServer for {}.", short_type_name::<Component>());
Ok(())
}
}
Expand Down Expand Up @@ -211,20 +211,20 @@ async fn request_response_loop<Request, Response, Component>(
Request: Send + Sync + Debug,
Response: Send + Sync + Debug,
{
info!("Starting server for component {}", type_name::<Component>());
info!("Starting server for component {}", short_type_name::<Component>());

while let Some(request_and_res_tx) = rx.recv().await {
let request = request_and_res_tx.request;
let tx = request_and_res_tx.tx;
debug!("Component {} received request {:?}", type_name::<Component>(), request);
debug!("Component {} received request {:?}", short_type_name::<Component>(), request);

let response = component.handle_request(request).await;
debug!("Component {} is sending response {:?}", type_name::<Component>(), response);
debug!("Component {} is sending response {:?}", short_type_name::<Component>(), response);

// Send the response to the client. This might result in a panic if the client has closed
// the response channel, which is considered a bug.
tx.send(response).await.expect("Response connection should be open.");
}

info!("Stopping server for component {}", type_name::<Component>());
info!("Stopping server for component {}", short_type_name::<Component>());
}

0 comments on commit 504d06a

Please sign in to comment.