-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Abstract thin-edge MQTT topic schema #2189
Abstract thin-edge MQTT topic schema #2189
Conversation
Codecov Report
Additional details and impacted files
|
Robot Results
|
#[async_trait] | ||
pub trait Converter: Send + Sync { | ||
type Error: Display; | ||
|
||
fn get_mapper_config(&self) -> &MapperConfig; | ||
|
||
async fn try_convert(&mut self, input: &Message) -> Result<Vec<Message>, Self::Error>; | ||
|
||
async fn convert(&mut self, input: &Message) -> Vec<Message> { | ||
impl CumulocityConverter { | ||
pub async fn convert(&mut self, input: &Message) -> Vec<Message> { | ||
let messages_or_err = self.try_convert(input).await; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Converter
trait has been removed as implemented only once.
There are now several impl CumulocityConverter { ... }
parts in this file. This has been done on purpose to ease this PR review. It would be good to reorganize this later.
match self.mqtt_schema.entity_channel_of(&message.topic) { | ||
Ok((source, channel)) => self.try_convert_te_topics(source, channel, message).await, | ||
Err(_) => self.try_convert_tedge_topics(message).await, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To ease the transition there is now two separate methods, each used for a specific topic schema.
The end goal is to get rid of try_convert_tedge_topics
.
ca1e1ec
to
9a7924f
Compare
The aim of this module is to abstract the MQTT topics used by thin-edge. Entities, such as devices and services, have to be described by the `entity_store` module. Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
This is just a sketch of the API. The implementation is done using the former `EntityTopic` concept. The latter will be deprecated in the following steps. Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
To ease the transition phase where messages are sent over `tedge/#` while others use `te/#`, the c8y converter main conversion method has been broken in two parts: te vs tedge. Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
EntityId is confusing when used for devices which already have an id. Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
a341a31
to
5d28f11
Compare
Proposed changes
struct MqttSchema
abstracting all topic definitionsstruct EntityTopic
Channel
type to abstract away all topic parsing.Types of changes
Paste Link to the issue
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments