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

Handle request atomically #249

Merged
merged 9 commits into from
Apr 27, 2023
Merged

Conversation

estringana
Copy link
Collaborator

Description

Handle request atomically

Motivation

Additional Notes

Describe how to test your changes

Readiness checklist

  • Unit tests have been updated and pass
  • If known, an appropriate milestone has been selected
  • All new source files include the required notice

Release checklist

  • The CHANGELOG.md has been updated

@codecov-commenter
Copy link

codecov-commenter commented Apr 24, 2023

Codecov Report

Merging #249 (af589b7) into master (c8a7a7c) will decrease coverage by 10.46%.
The diff coverage is 74.07%.

@@             Coverage Diff             @@
##           master     #249       +/-   ##
===========================================
- Coverage   63.83%   53.38%   -10.46%     
===========================================
  Files          94       69       -25     
  Lines        5649     2424     -3225     
  Branches     1807     1087      -720     
===========================================
- Hits         3606     1294     -2312     
+ Misses        973      432      -541     
+ Partials     1070      698      -372     
Flag Coverage Δ
extension ?
helper 53.38% <74.07%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/helper/client.hpp 70.00% <ø> (ø)
src/helper/exception.hpp 46.42% <40.00%> (-1.40%) ⬇️
src/helper/client.cpp 41.19% <81.81%> (+0.90%) ⬆️

... and 25 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@estringana estringana marked this pull request as ready for review April 25, 2023 07:41
@estringana estringana requested a review from Anilm3 April 25, 2023 07:41
Copy link
Collaborator

@Anilm3 Anilm3 left a comment

Choose a reason for hiding this comment

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

It looks good, although I the change suggested would be better as if we have a client that somehow fails to perform a request_init due to a protocol error (oversized message, msgpack beyond limits, etc), we would never update the request_enabled_ value

src/helper/client.cpp Outdated Show resolved Hide resolved
src/helper/client.cpp Show resolved Hide resolved
src/helper/client.cpp Outdated Show resolved Hide resolved
@estringana estringana force-pushed the estringana/handle-request-atomicaly branch 2 times, most recently from f14c17a to 1680666 Compare April 26, 2023 14:12
src/helper/client.cpp Outdated Show resolved Hide resolved
src/helper/client.cpp Outdated Show resolved Hide resolved
src/helper/client.cpp Show resolved Hide resolved
@estringana estringana force-pushed the estringana/handle-request-atomicaly branch from 1680666 to 31f0e71 Compare April 27, 2023 10:17
return false;
static constexpr auto client_init_timeout{std::chrono::milliseconds{500}};
return handle_message<network::client_init>(
*this, *broker_, client_init_timeout, false);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why would you want to ignore unexpected messages here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Basically what happen is that client_init will handle unexpected messages differently from the rest. Client_init will disconnect client(according to existing tests added by you) while the rest of command won't. Since you asked to move the handling of unexpected commands to handle_message, somehow I need to let it know what to do when unexpected_command exception is thrown

Copy link
Collaborator

Choose a reason for hiding this comment

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

I completely read this the other way around for some reason, I guess that's fine then.

@@ -73,7 +67,7 @@ bool send_error_response(const network::base_broker &broker)
template <typename... Ms>
// NOLINTNEXTLINE(google-runtime-references)
bool handle_message(client &client, const network::base_broker &broker,
std::chrono::milliseconds initial_timeout)
std::chrono::milliseconds initial_timeout, bool ignore_unexpected_messages)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is textbook boolean-trap :-(

}

return true;
// TODO: figure out how to handle errors which require sending an error
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can probably remove this TODO now...

@estringana estringana merged commit f9fb3c7 into master Apr 27, 2023
22 checks passed
@estringana estringana deleted the estringana/handle-request-atomicaly branch April 27, 2023 13:20
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.

None yet

3 participants