-
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
Cumulocity mapper using actors #1909 #1922
Cumulocity mapper using actors #1909 #1922
Conversation
9419294
to
c027b33
Compare
Robot Results
Passed Tests
|
81fdb7b
to
31ff3cb
Compare
cab723b
to
77b9c4e
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.
I still have to review the tests and actor.rs
. What I saw is great.
|
||
#[error(transparent)] | ||
FromC8YRestError(#[from] C8YRestError), |
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.
This error is specific to C8Y and should not be added to core::ConversionError
.
And, by the way, there is already a case for it in c8y::CumulocityMapperError
.
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.
Still here - but okay the issue being beyond the scope of this PR. The core::ConversionError
is already a mix of unrelated errors. This will have to be fix in a follow-up task.
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.
Oops, missed it. Will do it, as I'll have to resolve this anyway as part of moving the c8y-mapper into extensions/c8y_mapper_ext
.
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.
I ended up moving the Converter
trait and ConversionError
enum from core
to c8y_mapper_ext
as no other crate was using it so it didn't make sense to keep them as separate core
abstractions.
@@ -10,8 +10,10 @@ homepage = { workspace = true } | |||
repository = { workspace = true } | |||
|
|||
[dependencies] | |||
assert-json-diff = "2.0" |
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.
[follow-up task]
We need to add test-helpers
feature flag.
//HIPPO Rename EventId to String as there could be many other String responses as well and this macro doesn't allow another String variant | ||
fan_in_message_type!(C8YRestResponse[EventId, Unit, Bool]: Debug); |
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.
this macro doesn't allow another String variant
And cannot. If you receive pure String
s from different sources how can you distinguish them to process them appropriately?
fan_in_message_type!(C8YRestResponse[EventId, Unit, Bool]: Debug);
These response types are not really self contained. This is okayish for now as c8y_http_proxy
is systematically used with a request-response pattern. But if for some reason we start to send concurrently several requests to the proxy, then we will have to replace these types with specific ones that give the context of the response.
An event id for what? What is true / false?
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.
If you receive pure Strings from different sources how can you distinguish them to process them appropriately?
I was hoping to create a different alias like type JwtToken = String
and use that aliased name as another enum variant. But I guess, both EventId
and JwtToken
aliases are substituted to String
before the macro generates the variants, leading to the conflict. So I can either rename the existing EventId
alias to just String
so that it can be used everywhere or hand create the C8YRestResponse
enum as follows:
enum C8YRestResponse {
EventId(String),
JwtToke(String),
...
c2da0ab
to
5450cac
Compare
97bf553
to
1c85072
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.
So big efforts 👍 Left some questions.
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.
I have some comments - but see nothing really blocking and would be happy to approve.
SoftwareListRequest::topic_name(), | ||
"tedge/commands/req/software/list" | ||
SoftwareListRequest::topic(), | ||
Topic::new_unchecked("tedge/commands/req/software/list") |
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.
[unrelated] I really don't see the point of this kind of tests ...
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.
Happy to approve once done the final move to extensions/c8y_mapper_ext
.
There's further cleanup that can be done in the C8y mapper code, but haven't done that in this PR as it is out-of-scope for this refactoring work. But, they'd still be worth doing in follow-up PRs. Here are a few such improvements:
|
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. A great step forward!
@@ -2,6 +2,7 @@ pub mod file; | |||
pub mod fs; | |||
pub mod paths; | |||
pub mod signals; | |||
pub mod size_threshold; |
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.
[Note] This is typically the kind of code I see no point to abstract. This is just a size comparison but adds a coupling to the mqtt_channel
crate.
Proposed changes
Instead of moving the c8y mapper into
extensions
, I've updated the existing module itself just so that the diff is clear and easy to review. Once the changes are approved, I'll move it toextensions/c8y_mapper_ext
.CumulocityConverter
extensions/c8y_mapper_ext
.Types of changes
Paste Link to the issue
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments