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 serve_packet into IO and non IO parts #1151

Merged
merged 25 commits into from
Oct 26, 2023
Merged

Conversation

tdittr
Copy link
Contributor

@tdittr tdittr commented Oct 24, 2023

This decouples the IO during packet handling from the actual logic. This allows easier writing of tests,

This PR also flattens a lot of nested matches to make them more readable.

folkertdev and others added 11 commits October 18, 2023 16:59
This removes redundancy by moving out all serialization and IO from the
match arms and only do them once.
This makes testing and reading easier.
This decouples the counters from the response generation, making for
better readable code.
This reduces the methods in server, since stat counting only really
needs the stats and the result and none of the other fields of Server.
@codecov
Copy link

codecov bot commented Oct 24, 2023

Codecov Report

Attention: 52 lines in your changes are missing coverage. Please review.

Comparison is base (3584fdc) 85.06% compared to head (2f04b0e) 85.25%.
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1151      +/-   ##
==========================================
+ Coverage   85.06%   85.25%   +0.18%     
==========================================
  Files          57       57              
  Lines       15437    15506      +69     
==========================================
+ Hits        13132    13219      +87     
+ Misses       2305     2287      -18     
Files Coverage Δ
ntpd/src/daemon/server.rs 86.84% <78.86%> (+6.68%) ⬆️

... and 3 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@folkertdev folkertdev force-pushed the serve-packet-refactor branch from 89312cc to cf5a6f9 Compare October 24, 2023 12:19
@tdittr tdittr requested a review from davidv1992 October 24, 2023 14:12
@tdittr tdittr marked this pull request as ready for review October 24, 2023 18:09
Copy link
Member

@davidv1992 davidv1992 left a comment

Choose a reason for hiding this comment

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

Two minor points, but otherwise looking very good.

ntpd/src/daemon/server.rs Outdated Show resolved Hide resolved
ntpd/src/daemon/server.rs Outdated Show resolved Hide resolved
This ensures we can not even create a response that was longer than the
original request.
@tdittr tdittr changed the title Refctor serve_packet into IO and non IO parts Refactor serve_packet into IO and non IO parts Oct 26, 2023
@tdittr tdittr requested a review from davidv1992 October 26, 2023 07:09
@davidv1992 davidv1992 merged commit 0840493 into main Oct 26, 2023
22 checks passed
@davidv1992 davidv1992 deleted the serve-packet-refactor branch October 26, 2023 08:09
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.

4 participants