Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
Signed-off-by: Yashash H L <[email protected]>
  • Loading branch information
yhl25 committed Jun 21, 2024
1 parent 9d87efd commit 9a9e622
Show file tree
Hide file tree
Showing 7 changed files with 209 additions and 159 deletions.
10 changes: 5 additions & 5 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ impl<T> Server<T> {
/// Starts the gRPC server. When message is received on the `shutdown` channel, graceful shutdown of the gRPC server will be initiated.
pub async fn start_with_shutdown(
&mut self,
shutdown_rx: Option<oneshot::Receiver<()>>,
shutdown_rx: oneshot::Receiver<()>,
) -> Result<(), Box<dyn std::error::Error + Send + Sync>>
where
T: Mapper + Send + Sync + 'static,
Expand All @@ -297,7 +297,7 @@ impl<T> Server<T> {
.add_service(map_svc)
.serve_with_incoming_shutdown(
listener,
shutdown_signal(internal_shutdown_rx, shutdown_rx),
shutdown_signal(internal_shutdown_rx, Some(shutdown_rx)),
)
.await
.map_err(Into::into)
Expand All @@ -308,7 +308,8 @@ impl<T> Server<T> {
where
T: Mapper + Send + Sync + 'static,
{
self.start_with_shutdown(None).await
let (_shutdown_tx, shutdown_rx) = oneshot::channel();
self.start_with_shutdown(shutdown_rx).await
}
}

Expand All @@ -323,7 +324,6 @@ mod tests {
use tonic::transport::Uri;
use tower::service_fn;


#[tokio::test]
async fn map_server() -> Result<(), Box<dyn Error>> {
struct Cat;
Expand Down Expand Up @@ -352,7 +352,7 @@ mod tests {
assert_eq!(server.socket_file(), sock_file);

let (shutdown_tx, shutdown_rx) = oneshot::channel();
let task = tokio::spawn(async move { server.start_with_shutdown(Some(shutdown_rx)).await });
let task = tokio::spawn(async move { server.start_with_shutdown(shutdown_rx).await });

tokio::time::sleep(Duration::from_millis(50)).await;

Expand Down
Loading

0 comments on commit 9a9e622

Please sign in to comment.