Skip to content

Commit

Permalink
chore(mempool_infra): rename generic parameter in empty server
Browse files Browse the repository at this point in the history
commit-id:f037fa74
  • Loading branch information
Itay-Tsabary-Starkware committed Sep 26, 2024
1 parent 16bbc91 commit 9945314
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
use std::any::type_name;

use async_trait::async_trait;
use tracing::info;

use super::definitions::ComponentServerStarter;
use crate::errors::{ComponentError, ComponentServerError};
use crate::starters::Startable;

pub struct EmptyServer<T> {
component: T,
pub struct EmptyServer<Component> {
component: Component,
}

impl<T: Send + Sync> EmptyServer<T> {
pub fn new(component: T) -> Self {
impl<Component: Send + Sync> EmptyServer<Component> {
pub fn new(component: Component) -> Self {
Self { component }
}
}

#[async_trait]
impl<T: Startable<ComponentError> + Send + Sync> ComponentServerStarter for EmptyServer<T> {
impl<Component: Startable<ComponentError> + Send + Sync> ComponentServerStarter
for EmptyServer<Component>
{
async fn start(&mut self) -> Result<(), ComponentServerError> {
info!("Starting empty component server for {}.", type_name::<Component>());
self.component.start().await.map_err(ComponentServerError::ComponentError)
}
}

pub fn create_empty_server<T: Send + Sync>(component: T) -> EmptyServer<T> {
pub fn create_empty_server<Component: Send + Sync>(component: Component) -> EmptyServer<Component> {
EmptyServer::new(component)
}

0 comments on commit 9945314

Please sign in to comment.