summaryrefslogtreecommitdiffstats
path: root/crates/core/tedge_api/examples/heartbeat.rs
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@ifm.com>2022-03-04 07:58:14 +0100
committerMarcel Müller <m.mueller@ifm.com>2022-03-15 11:52:47 +0100
commit87975a97fe504576475b2719dfd53c7c1c99547d (patch)
tree4979a6f7098928675c830bae1638e51421fd39a9 /crates/core/tedge_api/examples/heartbeat.rs
parent805350e19e1efd9b28e2c93cfe9e62920451b05a (diff)
Adapt example to new interface
`Message::new()` was made private, so we must use `Comms::new_message()` now. This change was missing in the commit that changed that interface. Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com> Fixes: ca5672eebbbdf61ee1994dd0ea13346d117cb755 ("Add Comms::new_message()") Signed-off-by: Marcel Müller <m.mueller@ifm.com> Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
Diffstat (limited to 'crates/core/tedge_api/examples/heartbeat.rs')
-rw-r--r--crates/core/tedge_api/examples/heartbeat.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/crates/core/tedge_api/examples/heartbeat.rs b/crates/core/tedge_api/examples/heartbeat.rs
index f6415897..5c96a0fc 100644
--- a/crates/core/tedge_api/examples/heartbeat.rs
+++ b/crates/core/tedge_api/examples/heartbeat.rs
@@ -58,12 +58,10 @@ impl Plugin for HeartbeatService {
async fn handle_message(&self, message: Message) -> Result<(), PluginError> {
match message.kind() {
MessageKind::CheckReadyness => {
- let msg = Message::new(
- message.origin().clone(),
- MessageKind::SignalPluginState {
- state: String::from("Ok"),
- },
- );
+ let kind = MessageKind::SignalPluginState {
+ state: String::from("Ok"),
+ };
+ let msg = self.comms.new_message(message.origin().clone(), kind);
self.comms.send(msg).await?;
}
msg => println!("Does not handle: {:#?}", msg),
@@ -92,15 +90,17 @@ async fn main() {
)
.unwrap();
- let mut heartbeat = hsb.instantiate(config, comms).await.unwrap();
+ let mut heartbeat = hsb.instantiate(config, comms.clone()).await.unwrap();
heartbeat.setup().await.unwrap();
let handle = tokio::task::spawn(async move {
let hb = heartbeat;
- hb.handle_message(Message::new(
- Address::new(EndpointKind::Core),
+ hb.handle_message(comms.new_message(
+ Address::new(EndpointKind::Plugin {
+ id: "heartbeat-service".to_string(),
+ }),
MessageKind::CheckReadyness,
))
.await