Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(starknet_sequencer_infra): warn on clients and servers being dropped #2743

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>());
}
}
Loading