feat: Prep for moving tests into single integration suite

This commit is contained in:
2024-11-16 01:42:29 -05:00
parent c84427a9b3
commit 3416ce1003
14 changed files with 182 additions and 376 deletions

View File

@@ -19,19 +19,22 @@ public struct MQTTConnectionService: Service {
/// to the MQTT broker and handles graceful shutdown of the
/// connection.
public func run() async throws {
try await mqtt.connect()
try await withGracefulShutdownHandler {
try await mqtt.connect()
for await event in try mqtt.connectionStream().cancelOnGracefulShutdown() {
// We don't really need to do anything with the events, so just logging
// for now. But we need to iterate on an async stream for the service to
// continue to run and handle graceful shutdowns.
logger?.trace("Received connection event: \(event)")
}
// when we reach here we are shutting down, so we shutdown
// the manager.
mqtt.shutdown()
} onGracefulShutdown: {
self.logger?.trace("Received graceful shutdown.")
shutdown()
}
}
public func shutdown() {
mqtt.shutdown()
}
}