Skip to content

Commit

Permalink
Clean up PostgresClientService
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-fowler committed Jan 9, 2024
1 parent 1eed921 commit b7a5f6b
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions todos-postgres-tutuorial/Sources/PostgresClientService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,12 @@ import Hummingbird
import ServiceLifecycle

/// Manage the lifecycle of a PostgresClient
actor PostgresClientService: Service {
struct PostgresClientService: Service {
let client: PostgresClient

init(client: PostgresClient) {
self.client = client
}

func run() async throws {
await withTaskGroup(of: Void.self) { group in
group.addTask {
await self.client.run()
}
// wait until graceful shutdown and then cancel all tasks
await GracefulShutdownWaiter().wait()
group.cancelAll()
print("Shutdown postgres")
func run() async {
await cancelOnGracefulShutdown {
await self.client.run()
}
}
}

0 comments on commit b7a5f6b

Please sign in to comment.