-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding empty server and refactoring ComponentServer
commit-id:689882a6
- Loading branch information
1 parent
d4af508
commit 67df29a
Showing
10 changed files
with
77 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use async_trait::async_trait; | ||
|
||
use crate::component_runner::ComponentRunner; | ||
use crate::component_server::CommunicationServer; | ||
|
||
pub struct EmptyServer<T: ComponentRunner + Send> { | ||
component: T, | ||
} | ||
|
||
impl<T: ComponentRunner + Send + Sync> EmptyServer<T> { | ||
pub fn new(component: T) -> Self { | ||
Self { component } | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl<T: ComponentRunner + Send + Sync> CommunicationServer for EmptyServer<T> { | ||
async fn start(&mut self) { | ||
match self.component.start().await { | ||
Ok(_) => println!("ComponentServer::start() completed."), | ||
Err(err) => println!("ComponentServer::start() failed: {:?}", err), | ||
} | ||
} | ||
} | ||
|
||
pub fn create_empty_server<T: ComponentRunner + Send + Sync>(component: T) -> EmptyServer<T> { | ||
EmptyServer::new(component) | ||
} |
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
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
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
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