feat: Prep for moving tests into single integration suite
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user