feat: Updates for Sendable conformance

This commit is contained in:
2024-11-09 01:16:57 -05:00
parent 529b9b0bc5
commit 79bb162434
8 changed files with 43 additions and 25 deletions

View File

@@ -8,7 +8,7 @@ bootstrap-topics:
bootstrap: bootstrap-env bootstrap-topics
build:
@swift build
@swift build -Xswiftc -strict-concurrency=complete
clean:
rm -rf .build

View File

@@ -1,13 +1,13 @@
{
"originHash" : "869c04e4de5c59d3c7c00851dffa2bfde39aa29dc5be3cbbb759ad950fffd706",
"originHash" : "e3e70d8b34d7f35b238e03af18c08ca712051332cf3e429ae1c0ac2823ca2018",
"pins" : [
{
"identity" : "mqtt-nio",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swift-server-community/mqtt-nio.git",
"state" : {
"revision" : "ca8af7a30c4690456ce7de276cd0f037489ba707",
"version" : "2.5.3"
"revision" : "267b83ab5690d463ff00585a4fd6dc54b698e1d2",
"version" : "2.11.0"
}
},
{
@@ -19,6 +19,15 @@
"version" : "1.0.2"
}
},
{
"identity" : "swift-atomics",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-atomics.git",
"state" : {
"revision" : "cd142fd2f64be2100422d658e7411e39489da985",
"version" : "1.2.0"
}
},
{
"identity" : "swift-collections",
"kind" : "remoteSourceControl",
@@ -42,8 +51,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio",
"state" : {
"revision" : "6aa9347d9bc5bbfe6a84983aec955c17ffea96ef",
"version" : "2.33.0"
"revision" : "914081701062b11e3bb9e21accc379822621995e",
"version" : "2.76.1"
}
},
{
@@ -69,8 +78,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/swift-psychrometrics/swift-psychrometrics",
"state" : {
"revision" : "03573545c3750b406921eb22a9575c8062beef88",
"version" : "0.1.2"
"revision" : "158b9b12ecd14d36381f5bab8701c4e8eee2d011",
"version" : "0.1.0"
}
},
{
@@ -81,6 +90,15 @@
"revision" : "f70b838872863396a25694d8b19fe58bcd0b7903",
"version" : "2.6.2"
}
},
{
"identity" : "swift-system",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-system.git",
"state" : {
"revision" : "c8a44d836fe7913603e246acab7c528c2e780168",
"version" : "1.4.0"
}
}
],
"version" : 3

View File

@@ -20,7 +20,7 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/swift-server-community/mqtt-nio.git", from: "2.0.0"),
.package(url: "https://github.com/apple/swift-nio", from: "2.0.0"),
.package(url: "https://github.com/swift-psychrometrics/swift-psychrometrics", from: "0.1.0"),
.package(url: "https://github.com/swift-psychrometrics/swift-psychrometrics", exact: "0.1.0"),
.package(url: "https://github.com/swift-server/swift-service-lifecycle.git", from: "2.3.0")
],
targets: [

View File

@@ -5,7 +5,7 @@ import MQTTNIO
// TODO: Remove
public struct DewPointEnvironment {
public struct DewPointEnvironment: Sendable {
public var envVars: EnvVars
public var mqttClient: MQTTNIO.MQTTClient

View File

@@ -6,7 +6,7 @@ import Foundation
/// they can be loaded from the shell environment, or from a file located in the root directory.
///
/// This allows us to keep sensitve settings out of the repository.
public struct EnvVars: Codable, Equatable {
public struct EnvVars: Codable, Equatable, Sendable {
/// The current app environment.
public var appEnv: AppEnv
@@ -62,7 +62,7 @@ public struct EnvVars: Codable, Equatable {
}
/// Represents the different app environments.
public enum AppEnv: String, Codable {
public enum AppEnv: String, Codable, Sendable {
case development
case production
case staging

View File

@@ -1,5 +1,5 @@
import Foundation
import Psychrometrics
@preconcurrency import Psychrometrics
// TODO: Remove
// TODO: Make this a struct, then create a Store class that holds the state??

View File

@@ -1,9 +1,9 @@
import Psychrometrics
@preconcurrency import Psychrometrics
/// Represents a temperature and humidity sensor that can be used to derive
/// the dew-point temperature and enthalpy values.
///
public struct TemperatureAndHumiditySensor: Equatable, Hashable, Identifiable {
public struct TemperatureAndHumiditySensor: Equatable, Hashable, Identifiable, @unchecked Sendable {
/// The identifier of the sensor, same as the location.
public var id: Location { location }

View File

@@ -1,7 +1,7 @@
// TODO: Remove
/// A container for all the different MQTT topics that are needed by the application.
public struct Topics: Codable, Equatable {
public struct Topics: Codable, Equatable, Sendable {
/// The command topics the application can publish to.
public var commands: Commands
@@ -34,7 +34,7 @@ public struct Topics: Codable, Equatable {
}
/// Represents the sensor topics.
public struct Sensors: Codable, Equatable {
public struct Sensors: Codable, Equatable, Sendable {
public var mixedAirSensor: TemperatureAndHumiditySensor<State.Sensors.MixedAir>
public var postCoilSensor: TemperatureAndHumiditySensor<State.Sensors.PostCoil>
public var returnAirSensor: TemperatureAndHumiditySensor<State.Sensors.Return>
@@ -52,7 +52,7 @@ public struct Topics: Codable, Equatable {
self.supplyAirSensor = supplyAirSensor
}
public struct TemperatureAndHumiditySensor<Location>: Codable, Equatable {
public struct TemperatureAndHumiditySensor<Location>: Codable, Equatable, Sendable {
public var temperature: String
public var humidity: String
public var dewPoint: String
@@ -79,7 +79,7 @@ public struct Topics: Codable, Equatable {
}
/// A container for set point related topics used by the application.
public struct SetPoints: Codable, Equatable {
public struct SetPoints: Codable, Equatable, Sendable {
/// The topic for the humidify set point.
public var humidify: Humidify
@@ -100,7 +100,7 @@ public struct Topics: Codable, Equatable {
}
/// A container for the humidification set point topics used by the application.
public struct Humidify: Codable, Equatable {
public struct Humidify: Codable, Equatable, Sendable {
/// The topic for dew point control mode set point.
public var dewPoint: String
@@ -122,7 +122,7 @@ public struct Topics: Codable, Equatable {
}
/// A container for dehumidifcation set point topics.
public struct Dehumidify: Codable, Equatable {
public struct Dehumidify: Codable, Equatable, Sendable {
/// A low setting for dew point control modes.
public var lowDewPoint: String
@@ -157,7 +157,7 @@ public struct Topics: Codable, Equatable {
}
/// A container for control state topics used by the application.
public struct States: Codable, Equatable {
public struct States: Codable, Equatable, Sendable {
/// The topic for the control mode.
public var mode: String
@@ -177,7 +177,7 @@ public struct Topics: Codable, Equatable {
}
/// A container for reading the current state of a relay.
public struct Relays: Codable, Equatable {
public struct Relays: Codable, Equatable, Sendable {
/// The dehumidification stage-1 relay topic.
public var dehumdification1: String
@@ -206,7 +206,7 @@ public struct Topics: Codable, Equatable {
}
/// A container for commands topics that the application can publish to.
public struct Commands: Codable, Equatable {
public struct Commands: Codable, Equatable, Sendable {
/// The relay command topics.
public var relays: Relays
@@ -219,7 +219,7 @@ public struct Topics: Codable, Equatable {
}
/// A container for relay command topics used by the application.
public struct Relays: Codable, Equatable {
public struct Relays: Codable, Equatable, Sendable {
/// The dehumidification stage-1 relay topic.
public var dehumidification1: String