From 79bb1624342ebda06aabb862da1b31af2c0808bf Mon Sep 17 00:00:00 2001 From: Michael Housh Date: Sat, 9 Nov 2024 01:16:57 -0500 Subject: [PATCH] feat: Updates for Sendable conformance --- Makefile | 2 +- Package.resolved | 32 +++++++++++++++---- Package.swift | 2 +- Sources/DewPointEnvironment/Environment.swift | 2 +- Sources/EnvVars/EnvVars.swift | 4 +-- Sources/Models/State.swift | 2 +- .../Models/TemperatureAndHumiditySensor.swift | 4 +-- Sources/Models/Topics.swift | 20 ++++++------ 8 files changed, 43 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index e791357..723185a 100755 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ bootstrap-topics: bootstrap: bootstrap-env bootstrap-topics build: - @swift build + @swift build -Xswiftc -strict-concurrency=complete clean: rm -rf .build diff --git a/Package.resolved b/Package.resolved index 3a1e32a..a5af3f9 100755 --- a/Package.resolved +++ b/Package.resolved @@ -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 diff --git a/Package.swift b/Package.swift index 72bc0b0..a18f0e8 100755 --- a/Package.swift +++ b/Package.swift @@ -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: [ diff --git a/Sources/DewPointEnvironment/Environment.swift b/Sources/DewPointEnvironment/Environment.swift index a522660..bbfbdf1 100755 --- a/Sources/DewPointEnvironment/Environment.swift +++ b/Sources/DewPointEnvironment/Environment.swift @@ -5,7 +5,7 @@ import MQTTNIO // TODO: Remove -public struct DewPointEnvironment { +public struct DewPointEnvironment: Sendable { public var envVars: EnvVars public var mqttClient: MQTTNIO.MQTTClient diff --git a/Sources/EnvVars/EnvVars.swift b/Sources/EnvVars/EnvVars.swift index 1927992..0297ebd 100755 --- a/Sources/EnvVars/EnvVars.swift +++ b/Sources/EnvVars/EnvVars.swift @@ -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 diff --git a/Sources/Models/State.swift b/Sources/Models/State.swift index 7753ebc..d3246da 100755 --- a/Sources/Models/State.swift +++ b/Sources/Models/State.swift @@ -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?? diff --git a/Sources/Models/TemperatureAndHumiditySensor.swift b/Sources/Models/TemperatureAndHumiditySensor.swift index b382be8..1fde3f7 100644 --- a/Sources/Models/TemperatureAndHumiditySensor.swift +++ b/Sources/Models/TemperatureAndHumiditySensor.swift @@ -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 } diff --git a/Sources/Models/Topics.swift b/Sources/Models/Topics.swift index 69e6dc3..ae750f3 100755 --- a/Sources/Models/Topics.swift +++ b/Sources/Models/Topics.swift @@ -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 public var postCoilSensor: TemperatureAndHumiditySensor public var returnAirSensor: TemperatureAndHumiditySensor @@ -52,7 +52,7 @@ public struct Topics: Codable, Equatable { self.supplyAirSensor = supplyAirSensor } - public struct TemperatureAndHumiditySensor: Codable, Equatable { + public struct TemperatureAndHumiditySensor: 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