-
Notifications
You must be signed in to change notification settings - Fork 55
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
fix: Collect multiple smartrest messages from c8y devicecontrol topic #3301
fix: Collect multiple smartrest messages from c8y devicecontrol topic #3301
Conversation
1ef4041
to
5ad5345
Compare
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.
Some renaming required.
Codecov ReportAttention: Patch coverage is Additional details and impacted files📢 Thoughts on this report? Let us know! |
…icecontrol topic c8y/devicecontrol/notifications topic, as many others, can contain in its smartrest payload multiple records. For now ensure that multiple records are parsed from this topic in particular, as C8y sends multiple operations in a single message if e.g. device is offline, multiple operations are started, and then the device connects, it then receives all those operations in a single MQTT message. But a longer term solution would be to refactor the code to ensure that we're supporting collecting multiple smartrest messages from all the possible MQTT topics. Signed-off-by: Marcel Guzik <[email protected]>
5ad5345
to
1592ea6
Compare
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.
LGTM
.await; | ||
let result = self.handle_c8y_operation_result(&result, Some(operation.op_id)); | ||
output.extend(result); | ||
} | ||
|
||
Ok(output) |
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.
My opinion for the future development.
What I don't like from the current way (due to the converter design) is, this return value Ok(output) is a vector of MQTT messages that will be published later at the same time. If 5 operations are included in one message from c8y, 5 of 504 messages will be sent together. But it's definitely out of scope to fix now.
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.
What I don't like from the current way (due to the converter design) is, this return value Ok(output) is a vector of MQTT messages that will be published later at the same time. If 5 operations are included in one message from c8y, 5 of 504 messages will be sent together.
What don't you like in the current design? That the value returned by this method is a vector of MQTT messages or that the five 504 messages are not packed into a single MQTT message? The later can be implemented using the former method signature.
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.
504
changes an operation state to executing in c8y.
Let's say there are 3 operation (Op_A, Op_B, Op_C) are delivered at the same.
Ideally,
Op_A
start proceeding -> Publish504
forOp_A
Op_B
start proceeding -> Publish504
forOp_B
Op_C
start proceeding -> Publish504
forOp_C
However, with the current design, when all of Op_A
, Op_B
, and Op_C
start proceeding, mapper publishes three 504
messages for these 3 operations.
In short, what I don't like is the timing the 504
message is published by mapper. Not critical, but minor point.
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.
Though this doesn't occur for operations being processed by a workflow right (as the workflow execution is controlled by the tedge-agent, and currently only processes one type of operation at a time of the same type).
Robot Results
|
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.
Approved
1592ea6
to
0df75f0
Compare
As this function can be used for JSON over MQTT as well, updating the name. Signed-off-by: Marcel Guzik <[email protected]>
0df75f0
to
6748f0e
Compare
Proposed changes
c8y/devicecontrol/notifications topic, as many others, can contain in its smartrest payload multiple records. For now ensure that multiple records are parsed from this topic in particular, as C8y sends multiple operations in a single message if e.g. device is offline, multiple operations are started, and then the device connects, it then receives all those operations in a single MQTT message.
But a longer term solution would be to refactor the code to ensure that we're supporting collecting multiple smartrest messages from all the possible MQTT topics.
Types of changes
Paste Link to the issue
#3297
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments