Skip to content

Commit 083959e

Browse files
authored
Merge pull request #41 from kate-goldenring/fix-metadata-parsing
fix: deserialize all trigger metadata as strings
2 parents 4c76e52 + 30f7bdd commit 083959e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,9 @@ impl MqttTrigger {
128128

129129
// Receive the messages here from the specific topic in mqtt broker.
130130
let mut client = AsyncClient::new(self.metadata.address.as_str())?;
131+
let keep_alive_interval = self.metadata.keep_alive_interval.parse::<u64>()?;
131132
let conn_opts = paho_mqtt::ConnectOptionsBuilder::new()
132-
.keep_alive_interval(Duration::from_secs(self.metadata.keep_alive_interval))
133+
.keep_alive_interval(Duration::from_secs(keep_alive_interval))
133134
.user_name(&self.metadata.username)
134135
.password(&self.metadata.password)
135136
.finalize();
@@ -138,8 +139,9 @@ impl MqttTrigger {
138139
.connect(conn_opts)
139140
.await
140141
.context(format!("failed to connect to '{}'", self.metadata.address))?;
142+
let qos = config.qos.parse::<i32>()?;
141143
client
142-
.subscribe(&topic, config.qos)
144+
.subscribe(&topic, qos)
143145
.await
144146
.context(format!("failed to subscribe to '{topic}'"))?;
145147

@@ -191,7 +193,7 @@ struct TriggerMetadata {
191193
address: String,
192194
username: String,
193195
password: String,
194-
keep_alive_interval: u64,
196+
keep_alive_interval: String,
195197
}
196198

197199
impl TriggerMetadata {
@@ -219,7 +221,7 @@ pub struct ComponentConfig {
219221
/// The topic
220222
topic: String,
221223
/// The QoS level
222-
qos: i32,
224+
qos: String,
223225
}
224226

225227
/// Resolve variables in an expression against the variables in the provided trigger app.

0 commit comments

Comments
 (0)