Skip to content

Commit

Permalink
Add async_cleanup() method to ServerApp trait
Browse files Browse the repository at this point in the history
  • Loading branch information
YHM404 committed Apr 9, 2024
1 parent acee67f commit 58946a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pingora-core/src/apps/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ pub trait ServerApp {

/// This callback will be called once after the service stops listening to its endpoints.
fn cleanup(&self) {}

/// This callback will be called once after the service stops listening to its endpoints.
///
/// Used for async cleanup tasks.
async fn async_cleanup(&self) {}
}

/// This trait defines the interface of an HTTP application.
Expand Down
1 change: 1 addition & 0 deletions pingora-core/src/services/listening.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ impl<A: ServerApp + Send + Sync + 'static> ServiceTrait for Service<A> {
futures::future::join_all(handlers).await;
self.listeners.cleanup();
self.app_logic.cleanup();
self.app_logic.async_cleanup().await;
}

fn name(&self) -> &str {
Expand Down

0 comments on commit 58946a8

Please sign in to comment.