-
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
refactor: Simplify entity registration code flow #2884
refactor: Simplify entity registration code flow #2884
Conversation
@@ -3176,28 +3188,6 @@ pub(crate) mod tests { | |||
} | |||
} | |||
|
|||
#[tokio::test] | |||
async fn try_auto_registration_on_custom_topic() -> Result<(), anyhow::Error> { |
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 test isn't valid anymore, since caching of unregistered entity data as "pending entity data" was implemented.
Robot Results
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files
|
Err(anyhow!( | ||
"Invalid entity registration message received on topic: {}", | ||
message.topic.name | ||
) | ||
.into()) |
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.
Instead of this, I'd like to update EntityRegistrationMessage::try_from
to return a proper error. It is currently returning ()
as the error type, which is weird. Not quite sure it was done like that in the past. I'm assuming there was some concrete reason behind 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.
I'd like to update EntityRegistrationMessage::try_from to return a proper error.
I vote for it.
The current error is translated to ConversionError::UnexpectedError
eventually, but I think receiving invalid entity registration message is not really "unexpected". For example, if someone publishes to the topic te/custom/four/segments/topic
, the current code goes to this error.
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'd like to update EntityRegistrationMessage::try_from to return a proper error.
Indeed, 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.
Thanks Albin, looks very good. Now much easier to understand.
Err(anyhow!( | ||
"Invalid entity registration message received on topic: {}", | ||
message.topic.name | ||
) | ||
.into()) |
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'd like to update EntityRegistrationMessage::try_from to return a proper error.
I vote for it.
The current error is translated to ConversionError::UnexpectedError
eventually, but I think receiving invalid entity registration message is not really "unexpected". For example, if someone publishes to the topic te/custom/four/segments/topic
, the current code goes to this error.
1ea5b8f
to
6cbe758
Compare
6cbe758
to
c53e14a
Compare
Proposed changes
Refactor the entity registration and auto registration code for simplicity and improved readability.
Types of changes
Paste Link to the issue
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments