Skip to content

Commit

Permalink
chore(starknet_sequencer_infra): warn on clients and servers being dr…
Browse files Browse the repository at this point in the history
…opped

commit-id:98e56d1a
  • Loading branch information
Itay-Tsabary-Starkware committed Dec 19, 2024
1 parent b77abf4 commit 6383355
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use infra_utils::type_name::short_type_name;
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};
Expand Down Expand Up @@ -102,7 +102,7 @@ where
Response: Send + Sync,
{
fn drop(&mut self) {
info!("Dropping local client {}.", short_type_name::<Self>());
warn!("Dropping {}.", short_type_name::<Self>());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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};
use tracing::{debug, error, info, warn};

use crate::component_definitions::{
ComponentRequestAndResponseSender,
Expand Down Expand Up @@ -203,6 +203,18 @@ where
}
}

impl<Component, Request, Response, LocalServerType> Drop
for BaseLocalComponentServer<Component, Request, Response, LocalServerType>
where
Component: ComponentRequestHandler<Request, Response>,
Request: Send + Sync,
Response: Send + Sync,
{
fn drop(&mut self) {
warn!("Dropping {}.", short_type_name::<Self>());
}
}

async fn request_response_loop<Request, Response, Component>(
rx: &mut Receiver<ComponentRequestAndResponseSender<Request, Response>>,
component: &mut Component,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ use hyper::body::to_bytes;
use hyper::header::CONTENT_TYPE;
use hyper::service::{make_service_fn, service_fn};
use hyper::{Body, Request as HyperRequest, Response as HyperResponse, Server, StatusCode};
use infra_utils::type_name::short_type_name;
use serde::de::DeserializeOwned;
use serde::Serialize;
use tracing::warn;

use crate::component_client::{ClientError, LocalComponentClient};
use crate::component_definitions::{
Expand Down Expand Up @@ -191,3 +193,13 @@ where
Ok(())
}
}

impl<Request, Response> Drop for RemoteComponentServer<Request, Response>
where
Request: Serialize + DeserializeOwned + Send + Sync + 'static,
Response: Serialize + DeserializeOwned + Send + Sync + 'static,
{
fn drop(&mut self) {
warn!("Dropping {}.", short_type_name::<Self>());
}
}

0 comments on commit 6383355

Please sign in to comment.