Skip to content

Commit 0453d80

Browse files
committed
Deduplicate MQTT messages forwarded to a given actor
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
1 parent 7533f44 commit 0453d80

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

  • crates/extensions/tedge_mqtt_ext/src

crates/extensions/tedge_mqtt_ext/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use mqtt_channel::StreamExt;
1414
use mqtt_channel::SubscriberOps;
1515
pub use mqtt_channel::Topic;
1616
pub use mqtt_channel::TopicFilter;
17+
use std::collections::HashSet;
1718
use std::convert::Infallible;
1819
use std::sync::Arc;
1920
use std::time::Duration;
@@ -356,10 +357,10 @@ impl TrieService {
356357
}
357358

358359
#[cfg(feature = "test-helpers")]
359-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
360+
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
360361
pub struct ClientId(pub usize);
361362
#[cfg(not(feature = "test-helpers"))]
362-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
363+
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
363364
pub struct ClientId(usize);
364365

365366
type MatchRequest = String;
@@ -627,7 +628,7 @@ impl ToPeers {
627628
let TrieResponse::Matched(matches) = subscribed else {
628629
unreachable!("MatchRequest always returns Matched")
629630
};
630-
for client in matches {
631+
for client in HashSet::<ClientId>::from_iter(matches) {
631632
self.sender_by_id(client).send(message.clone()).await?;
632633
}
633634
Ok(())

0 commit comments

Comments
 (0)