feat: Begins using swift argument parser and creating cli client dependency
All checks were successful
CI / Run Tests (push) Successful in 4m27s

This commit is contained in:
2024-11-16 22:32:32 -05:00
parent 3416ce1003
commit 6472d3cd1e
19 changed files with 657 additions and 342 deletions

View File

@@ -5,13 +5,14 @@ import MQTTManager
import ServiceLifecycle
public struct MQTTConnectionService: Service {
@Dependency(\.mqtt) var mqtt
private let logger: Logger?
public init(
logger: Logger? = nil
) {
var logger = logger
logger?[metadataKey: "type"] = "mqtt-connection-service"
self.logger = logger
}
@@ -19,6 +20,7 @@ public struct MQTTConnectionService: Service {
/// to the MQTT broker and handles graceful shutdown of the
/// connection.
public func run() async throws {
@Dependency(\.mqtt) var mqtt
try await mqtt.connect()
try await withGracefulShutdownHandler {
@@ -30,11 +32,7 @@ public struct MQTTConnectionService: Service {
}
} onGracefulShutdown: {
self.logger?.trace("Received graceful shutdown.")
shutdown()
mqtt.shutdown()
}
}
public func shutdown() {
mqtt.shutdown()
}
}