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
Some checks failed
CI / Run Tests (push) Failing after 12s
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user