Skip to content

Commit

Permalink
Add async_cleanup() method to ServerApp trait
Browse files Browse the repository at this point in the history
---
Refactor cleanup functions to use async/await

Includes-commit: 3cd52fe
Includes-commit: 58946a8
Replicated-from: #193
  • Loading branch information
YHM404 authored and eaufavor committed May 10, 2024
1 parent 2501d4a commit 42b0224
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .bleep
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0d6c0fbd55a4b0d8b5f2ae892a6602457dc61b7e
e21e3b7e97830f026794014cf1406dd544cac032
8 changes: 4 additions & 4 deletions pingora-core/src/apps/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub trait ServerApp {
) -> Option<Stream>;

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

/// This trait defines the interface of an HTTP application.
Expand All @@ -77,7 +77,7 @@ pub trait HttpServerApp {
None
}

fn http_cleanup(&self) {}
async fn http_cleanup(&self) {}
}

#[cfg_attr(not(doc_async_trait), async_trait)]
Expand Down Expand Up @@ -141,7 +141,7 @@ where
}
}

fn cleanup(&self) {
self.http_cleanup()
async fn cleanup(&self) {
self.http_cleanup().await;
}
}
2 changes: 1 addition & 1 deletion pingora-core/src/services/listening.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,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.cleanup().await;
}

fn name(&self) -> &str {
Expand Down
2 changes: 1 addition & 1 deletion pingora-proxy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ where
self.process_request(session, ctx).await
}

fn http_cleanup(&self) {
async fn http_cleanup(&self) {
// Notify all keepalived requests blocking on read_request() to abort
self.shutdown.notify_waiters();

Expand Down

0 comments on commit 42b0224

Please sign in to comment.