Added some documentation strings.
This commit is contained in:
@@ -56,6 +56,7 @@ extension MQTTClient {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - TODO it feels like the subscriptions should happen in the `bootstrap` process.
|
||||||
fileprivate func fetchTemperature(
|
fileprivate func fetchTemperature(
|
||||||
sensor: TemperatureSensor,
|
sensor: TemperatureSensor,
|
||||||
units: PsychrometricEnvironment.Units?
|
units: PsychrometricEnvironment.Units?
|
||||||
@@ -85,6 +86,7 @@ extension MQTTClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - TODO it feels like the subscriptions should happen in the `bootstrap` process.
|
||||||
fileprivate func fetchHumidity(sensor: HumiditySensor) -> EventLoopFuture<RelativeHumidity> {
|
fileprivate func fetchHumidity(sensor: HumiditySensor) -> EventLoopFuture<RelativeHumidity> {
|
||||||
logger.debug("Adding listener for humidity sensor...")
|
logger.debug("Adding listener for humidity sensor...")
|
||||||
let subscription = MQTTSubscribeInfoV5.init(
|
let subscription = MQTTSubscribeInfoV5.init(
|
||||||
|
|||||||
@@ -1,14 +1,38 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
/// Holds common settings for connecting to your MQTT broker. The default values can be used,
|
||||||
|
/// 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 {
|
||||||
|
|
||||||
|
/// The current app environment.
|
||||||
public var appEnv: AppEnv
|
public var appEnv: AppEnv
|
||||||
|
|
||||||
|
/// The MQTT host.
|
||||||
public var host: String
|
public var host: String
|
||||||
|
|
||||||
|
/// The MQTT port.
|
||||||
public var port: String?
|
public var port: String?
|
||||||
|
|
||||||
|
/// The identifier to use when connecting to the MQTT broker.
|
||||||
public var identifier: String
|
public var identifier: String
|
||||||
|
|
||||||
|
/// The MQTT user name.
|
||||||
public var userName: String?
|
public var userName: String?
|
||||||
|
|
||||||
|
/// The MQTT user password.
|
||||||
public var password: String?
|
public var password: String?
|
||||||
|
|
||||||
|
/// Create a new ``EnvVars``
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - appEnv: The current application environment
|
||||||
|
/// - host: The MQTT host.
|
||||||
|
/// - port: The MQTT port.
|
||||||
|
/// - identifier: The identifier to use when connecting to the MQTT broker.
|
||||||
|
/// - userName: The MQTT user name to connect to the broker with.
|
||||||
|
/// - password: The MQTT user password to connect to the broker with.
|
||||||
public init(
|
public init(
|
||||||
appEnv: AppEnv = .development,
|
appEnv: AppEnv = .development,
|
||||||
host: String = "127.0.0.1",
|
host: String = "127.0.0.1",
|
||||||
@@ -25,6 +49,7 @@ public struct EnvVars: Codable, Equatable {
|
|||||||
self.password = password
|
self.password = password
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Custom coding keys.
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
case appEnv = "APP_ENV"
|
case appEnv = "APP_ENV"
|
||||||
case host = "MQTT_HOST"
|
case host = "MQTT_HOST"
|
||||||
@@ -34,6 +59,7 @@ public struct EnvVars: Codable, Equatable {
|
|||||||
case password = "MQTT_PASSWORD"
|
case password = "MQTT_PASSWORD"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Represents the different app environments.
|
||||||
public enum AppEnv: String, Codable {
|
public enum AppEnv: String, Codable {
|
||||||
case development
|
case development
|
||||||
case production
|
case production
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import Logging
|
|||||||
import Models
|
import Models
|
||||||
import MQTTNIO
|
import MQTTNIO
|
||||||
import NIO
|
import NIO
|
||||||
import RelayClient
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
var logger = Logger(label: "dewPoint-logger")
|
var logger = Logger(label: "dewPoint-logger")
|
||||||
|
|||||||
Reference in New Issue
Block a user