-
Notifications
You must be signed in to change notification settings - Fork 54
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
Aws topic mapping #1739
Aws topic mapping #1739
Conversation
Signed-off-by: Marcel Guzik <marcel.guzik@inetum.com>
Robot Results
Passed Tests
|
docs/src/architecture/mapper.md
Outdated
@@ -160,7 +160,7 @@ sudo systemctl restart tedge-mapper-az.service | |||
|
|||
The AWS mapper takes messages formatted in the [Thin Edge JSON](thin-edge-json.md) as input. | |||
It validates if the incoming message is correctly formatted Thin Edge JSON, then outputs the message. | |||
The validated messages are published on the topic `aws/messages/` from where they are forwarded to AWS. | |||
The validated messages are published on the topic `aws/td/` from where they are forwarded to AWS. |
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.
is aws/td/
a valid topic?, Because there is a forward slash at the end.
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.
Right, that should probably say aws/td/#
.
dfb7661
to
ed2c6b3
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.
Approved
Added |
The mapping has to be specific to each cloud adopting idioms and good practices for that specific cloud end-point. So that's okay. @reubenmiller what's your point of view here? |
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.
You need to add an explicit filter to uniquely match measurements, alarms and events.
Also added |
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 - unfortunately this cannot be merged till fixed the (independent) integration test issues.
Signed-off-by: Marcel Guzik <marcel.guzik@inetum.com>
8d30603
to
5b83645
Compare
"tedge/alarms/+/+/+", | ||
] | ||
.try_into() | ||
.unwrap() |
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.
Replacing unwrap
with error handling is better.
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.
In this specific case, unwrap is okay as all the topics are correct and known at compile time.
@@ -44,13 +58,44 @@ impl Converter for AwsConverter { | |||
} | |||
|
|||
async fn try_convert(&mut self, input: &Message) -> Result<Vec<Message>, Self::Error> { | |||
let () = self.size_threshold.validate(input)?; | |||
self.size_threshold.validate(input)?; |
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.
Did not see a threshold value for the aws
defined here. I feel the validation here is against the aws
supported size.
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.
Moved size validation to the end, so that the message is validated after it's transformed by the mapper.
}; | ||
|
||
let mut topic_iter = input.topic.name.split('/'); | ||
let td_type = topic_iter.nth(1).unwrap(); |
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.
Better handle this unwrap
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.
Fixed
|
||
let mut topic_iter = input.topic.name.split('/'); | ||
let td_type = topic_iter.nth(1).unwrap(); | ||
let mut topic_suffix = topic_iter.collect::<Vec<_>>().join("/"); |
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 feel suffix /
is not needed here. Because the topic must be like aws/td/measurement
right?
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 intent was to handle things like tedge/alarms/<severity>/<alarm-type>/<child-id>
, etc. Then td_type
would be alarms
, and topic_suffix
would be /<severity>/<alarm-type>/<child-id>
, but you are correct that it seems to be needlessly complicated, I'm not sure why I did it like that, as just splitting on the first /
character and taking the string to the right would work. Will fix.
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 now realize that by "suffix /
" you meant that .join("/")
at the end, which does not actually add text to the end of the string, but is actually called on a slice, to concatenate the elements with some string in between. So there is no /
suffix there, but I've realized now that there is a better way to write it, so I'll change it
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.
@PradeepKiruvale should be fixed 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.
But if you do split_once on tedge/alarms/<severity>/<alarm-type>/<child-id>
then td_type
will be tedge
and topic_suffix
will be alarms/<severity>/<alarm-type>/<child-id>
. This does not address what you mentioned in your comment right?
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.
But if you do split_once on
tedge/alarms/<severity>/<alarm-type>/<child-id>
thentd_type
will betedge
andtopic_suffix
will bealarms/<severity>/<alarm-type>/<child-id>
.
I meant that it was needlessly complicated because it was splitting topic into td_type
and topic_sufix
, and then concatenating them anyway. So now, split_once
returns ("tedge", "alarms/<severity>/<alarm-type>/<child-id>")
and i just get the 2nd element of that tuple and use it to craft the final topic.
This PR has to be rebased to get the fix for test report generation. |
8ffb4c5
to
5b83645
Compare
Signed-off-by: Marcel Guzik <marcel.guzik@inetum.com>
Topics `tedge/alarms` and `tedge/events` were added to the input topic filter of the AWS mapper. These additional topics are currently not using Thin-Edge JSON, but are only parsed as regular JSON, and the mapper only adds the timestamp to the payload. Signed-off-by: Marcel Guzik <marcel.guzik@inetum.com>
Signed-off-by: Marcel Guzik <marcel.guzik@inetum.com>
47e4249
to
6cf9791
Compare
A test is failing: |
Signed-off-by: Marcel Guzik <marcel.guzik@inetum.com>
6cf9791
to
13592c1
Compare
Proposed changes
This PR fixes some bugs and inaccuracies concerning AWS support:
tedge/measurements
toaws/td/measurements
instead ofaws/td
Types of changes
Paste Link to the issue
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments