fix: Fixes sensor service test that was flaky and moves docker stuff into it's own directory.
Some checks failed
CI / Run Tests (push) Failing after 12s

This commit is contained in:
2024-11-14 21:24:23 -05:00
parent ec3cd40fef
commit d4b6f6ad2b
8 changed files with 23 additions and 73 deletions

View File

@@ -29,6 +29,9 @@ public actor SensorsService: Service {
/// values to publish back to the MQTT broker.
var sensors: [TemperatureAndHumiditySensor]
@_spi(Internal)
public var isListening: Bool = false
var topics: [String] {
sensors.reduce(into: [String]()) { array, sensor in
array.append(sensor.topics.temperature)
@@ -65,13 +68,16 @@ public actor SensorsService: Service {
switch event {
case .shuttingDown:
logger?.debug("Received shutdown event.")
isListening = false
try await self.shutdown()
case .disconnected:
logger?.debug("Received disconnected event.")
isListening = false
try await Task.sleep(for: .milliseconds(100))
case .connected:
logger?.debug("Received connected event.")
let stream = try await makeStream()
isListening = true
for await result in stream.cancelOnGracefulShutdown() {
logger?.debug("Received result for topic: \(result.topic)")
await self.handleResult(result)