Skip to content
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: Deprecate unused actor methods and types #2784

Conversation

didier-wenzek
Copy link
Contributor

@didier-wenzek didier-wenzek commented Mar 15, 2024

Proposed changes

  • Deprecate MessageReceiver::recv_message()
  • Deprecate enum WrappedInput
  • Deprecate enum RuntimeEvent (from the public API - still used internally)
  • Deprecate trait ServiceConsumerExt and the with_probe() test helper
  • Deprecate trait ServiceProviderExt and the new_client_box() test helper

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (general improvements like code refactoring that doesn't explicitly fix a bug or add any new functionality)
  • Documentation Update (if none of the other choices apply)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Paste Link to the issue


Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA (in all commits with git commit -s)
  • I ran cargo fmt as mentioned in CODING_GUIDELINES
  • I used cargo clippy as mentioned in CODING_GUIDELINES
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

Copy link

codecov bot commented Mar 15, 2024

Codecov Report

Attention: Patch coverage is 85.29412% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 77.2%. Comparing base (19773d6) to head (e508f11).
Report is 5 commits behind head on main.

Additional details and impacted files
Files Coverage Δ
crates/common/batcher/src/driver.rs 79.0% <100.0%> (+0.3%) ⬆️
crates/core/tedge_actors/src/actors.rs 78.8% <100.0%> (+0.5%) ⬆️
crates/core/tedge_actors/src/message_boxes.rs 72.4% <100.0%> (+7.2%) ⬆️
...tes/core/tedge_actors/src/servers/message_boxes.rs 90.9% <100.0%> (+0.4%) ⬆️
crates/core/tedge_actors/src/servers/mod.rs 85.0% <100.0%> (+8.0%) ⬆️
crates/core/tedge_actors/src/test_helpers.rs 72.3% <ø> (+3.4%) ⬆️
crates/core/tedge_actors/src/tests.rs 81.0% <ø> (ø)
crates/core/tedge_agent/src/agent.rs 0.0% <ø> (ø)
crates/extensions/c8y_mapper_ext/src/tests.rs 92.7% <100.0%> (ø)
crates/extensions/tedge_mqtt_ext/src/lib.rs 72.1% <ø> (+2.0%) ⬆️
... and 3 more

... and 3 files with indirect coverage changes

Copy link
Contributor

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
422 0 3 422 100 0s

Comment on lines 183 to 185
let mut test_box = SimpleMessageBoxBuilder::new("Test box", 16);
test_box.connect_sink(NoConfig, &builder.connect_client(test_box.get_sender()));
let mut test_box = test_box.build();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not the former variant itself, which is the same but simpler?

Suggested change
let mut test_box = SimpleMessageBoxBuilder::new("Test box", 16);
test_box.connect_sink(NoConfig, &builder.connect_client(test_box.get_sender()));
let mut test_box = test_box.build();
let mut test_box = builder.new_client_box();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a residue of my attempt to fully remove the new_client_box() test helper.

Reverted.

Comment on lines 289 to 294
let mut test_box = SimpleMessageBoxBuilder::new("Test box", 16);
test_box.connect_sink(
NoConfig,
&self.box_builder.connect_client(test_box.get_sender()),
);
test_box.build()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a residue of my attempt to fully remove the new_client_box() test helper.

Reverted.

@@ -151,6 +156,9 @@ pub trait Service<Request: Message, Response: Message>:
/// The client provides a `response_sender` on which it wants to response to be sent to.
/// In exchange the client is returned a request sender on which its requests will have to be sent.
fn connect_client(&mut self, response_sender: DynSender<Response>) -> DynSender<Request>;

/// Create a simple message box connected to a server box under construction.
fn new_client_box(&mut self) -> SimpleMessageBox<Response, Request>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if this function should this be hidden behind a test feature flag to make the intent clear?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hidden behind #[cfg(feature = "test-helpers")]

This method was only used in a test.

Also deprecate `WrappedInput` type. Which was adding little compared to
Result<Option<Input>, RuntimeRequest>.

Signed-off-by: Didier Wenzek <[email protected]>
My plan was to fully deprecate the RuntimeEvent type.
However, these events are actually useful to test the runtime.
So let this unchanged for now.

Signed-off-by: Didier Wenzek <[email protected]>
I'm proud of this Probe abstraction which really demonstrate the
flexibility of the actor builder traits. However, this abstraction is
used by not even a single test. Aiming to reduce the number of concepts
introduce by this crate, I prefer to remove it.

Signed-off-by: Didier Wenzek <[email protected]>
The new_client_box method has not been fully deprecated but moved to the
Service trait. This makes this trait a bit more contrieved (with 3 ways
to connect clients) and will have to be fixed.
However, I prefer this temporary situation because moving
the method in a trait Ext was only hidding the issue.
I will address that in a following step.

Signed-off-by: Didier Wenzek <[email protected]>
@didier-wenzek didier-wenzek force-pushed the refactor/deprecate-unused-actor-methods branch from b144b96 to e508f11 Compare March 21, 2024 08:55
@didier-wenzek didier-wenzek added this pull request to the merge queue Mar 21, 2024
Merged via the queue into thin-edge:main with commit fd7a532 Mar 21, 2024
32 checks passed
@didier-wenzek didier-wenzek deleted the refactor/deprecate-unused-actor-methods branch March 21, 2024 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants