From e43d797afab54221cc8d9ef88ce07a2455f41a3d Mon Sep 17 00:00:00 2001 From: Itay Tsabary Date: Wed, 18 Dec 2024 07:51:23 +0200 Subject: [PATCH] chore(starknet_sequencer_infra): warn on clients and servers being dropped commit-id:98e56d1a --- .../component_client/local_component_client.rs | 4 ++-- .../component_server/local_component_server.rs | 15 ++++++++++++++- .../component_server/remote_component_server.rs | 13 +++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/crates/starknet_sequencer_infra/src/component_client/local_component_client.rs b/crates/starknet_sequencer_infra/src/component_client/local_component_client.rs index 4724f85b05c..bcc5e5159b2 100644 --- a/crates/starknet_sequencer_infra/src/component_client/local_component_client.rs +++ b/crates/starknet_sequencer_infra/src/component_client/local_component_client.rs @@ -4,7 +4,7 @@ use async_trait::async_trait; use serde::de::DeserializeOwned; use serde::Serialize; use tokio::sync::mpsc::{channel, Sender}; -use tracing::info; +use tracing::warn; use crate::component_client::ClientResult; use crate::component_definitions::{ComponentClient, ComponentRequestAndResponseSender}; @@ -103,7 +103,7 @@ where Response: Send + Sync, { fn drop(&mut self) { - info!("Dropping LocalComponentClient {}.", type_name::()); + warn!("Dropping {}.", type_name::()); } } diff --git a/crates/starknet_sequencer_infra/src/component_server/local_component_server.rs b/crates/starknet_sequencer_infra/src/component_server/local_component_server.rs index eeb4f02597e..9781c5e9d7d 100644 --- a/crates/starknet_sequencer_infra/src/component_server/local_component_server.rs +++ b/crates/starknet_sequencer_infra/src/component_server/local_component_server.rs @@ -4,7 +4,7 @@ use std::marker::PhantomData; use async_trait::async_trait; use tokio::sync::mpsc::Receiver; -use tracing::{debug, error, info}; +use tracing::{debug, error, info, warn}; use crate::component_definitions::{ ComponentRequestAndResponseSender, @@ -203,6 +203,19 @@ where } } +// TODO(Tsabary): Replace with `type_name` with `short_type_name`. +impl Drop + for BaseLocalComponentServer +where + Component: ComponentRequestHandler, + Request: Send + Sync, + Response: Send + Sync, +{ + fn drop(&mut self) { + warn!("Dropping {}.", type_name::()); + } +} + async fn request_response_loop( rx: &mut Receiver>, component: &mut Component, diff --git a/crates/starknet_sequencer_infra/src/component_server/remote_component_server.rs b/crates/starknet_sequencer_infra/src/component_server/remote_component_server.rs index 7c16b9a05a9..8dc69610519 100644 --- a/crates/starknet_sequencer_infra/src/component_server/remote_component_server.rs +++ b/crates/starknet_sequencer_infra/src/component_server/remote_component_server.rs @@ -1,3 +1,4 @@ +use std::any::type_name; use std::fmt::Debug; use std::net::SocketAddr; use std::sync::Arc; @@ -9,6 +10,7 @@ use hyper::service::{make_service_fn, service_fn}; use hyper::{Body, Request as HyperRequest, Response as HyperResponse, Server, StatusCode}; use serde::de::DeserializeOwned; use serde::Serialize; +use tracing::warn; use crate::component_client::{ClientError, LocalComponentClient}; use crate::component_definitions::{ @@ -191,3 +193,14 @@ where Ok(()) } } + +// TODO(Tsabary): Replace with `type_name` with `short_type_name`. +impl Drop for RemoteComponentServer +where + Request: Serialize + DeserializeOwned + Send + Sync + 'static, + Response: Serialize + DeserializeOwned + Send + Sync + 'static, +{ + fn drop(&mut self) { + warn!("Dropping {}.", type_name::()); + } +}