-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(mempool_infra): rename generic parameter in empty server
commit-id:f037fa74
- Loading branch information
1 parent
16bbc91
commit 9945314
Showing
1 changed file
with
12 additions
and
6 deletions.
There are no files selected for viewing
18 changes: 12 additions & 6 deletions
18
crates/mempool_infra/src/component_server/empty_component_server.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |