-
Notifications
You must be signed in to change notification settings - Fork 5
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
chore(mds): Refactor the master's masterconn #299
Open
lgsilva3087
wants to merge
14
commits into
dev
Choose a base branch
from
chore-mds-refactor-masterconn
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+974
−832
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62376f9
to
72e9b22
Compare
bf5e646
to
b483a4d
Compare
Shadows and Metaloggers use the struct masterconn to represent a connection to the active Master server in the current architecture. This commit, partially refactors the masterconn.cc file. The main changes are: - Improve readability. - Semi camel case variable names. - Rename variables to be more consistent with their real usage. - Add documentation. - Reduce enums size. - Remove some clang-tidy warnings (will continue). - Prepare the struct to be split later into .h and .cc files, for better separation between interface and implementation. The change was limited to only affect masterconn.cc to ease the review. Next commits will continue improving the related files. Signed-off-by: guillex <[email protected]>
The function masterconn_findlastlogversion does a very specific work related to the metadata backend (metadata and changelogs). This commit moves the responsibility to the correct place (MetadataBackendFile). Signed-off-by: guillex <[email protected]>
The previous version was reimplementing a queue based on raw pointers to outputHead and outputTail. This commit replaces the hand made queue by a std::queue. Signed-off-by: guillex <[email protected]>
This commit uses a std::vector to hold the packet buffer. The previous version was using a raw uint_8 * approach. The new way allows to: - Better readability. - Avoid calling malloc and free directly. - Reduce allocations in some scenarios (resize instead of free+malloc). - Better RAII. Signed-off-by: guillex <[email protected]>
The function masterconn_stats was never called, making unused also the variables stats_bytesout and stats_bytesin. This commit removes the function and the variables. Signed-off-by: guillex <[email protected]>
Signed-off-by: guillex <[email protected]>
The functions associated with the MasterConn struct are now member funtions, removing the need to pass the pointer to the object every time, and making easier to have multiple connections in the future. The funcions were also renamed to be semi camel case. The global functions were grouped and moved to the anonymous namespace. Signed-off-by: guillex <[email protected]>
The following line was duplicated in the masterconn_init function: eventloop_pollregister(masterconn_desc, masterconn_serve); This commit removes the duplicated line. Signed-off-by: guillex <[email protected]>
This commit introduces some constants in MasterConn to: - Initialize all members (including cfg defaults). - Remove magic constants in cfg loading. - Remove clang-tidy warnings. Signed-off-by: guillex <[email protected]>
Prevents the direct usage of new and delete. Signed-off-by: guillex <[email protected]>
Most of the logging in MasterConn now uses the safs:: like style (C++), instead of the legacy C-like functions (safs_pretty_syslog, etc.). The change aims to improve the readability and the expresiveness of spdlog + fmt. The log messages that need 'errno' or 'silent' variants, were not touched. Signed-off-by: guillex <[email protected]>
Clang-tidy was complaining about some initializations of std::string at compile time (may throw and can not be catched). This commit removes the warnings by creating static inline functions returning the correct values for Metalogger and Shadow. The change uses static storage and const references to be as efficient as the previous approach. Signed-off-by: guillex <[email protected]>
Signed-off-by: guillex <[email protected]>
3e66373
to
d01db60
Compare
The file now aligns with the defined .clang-format style. Signed-off-by: guillex <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR partially refactors masterconn.cc, which is used by Shadows and Metaloggers to represent a connection to the active Master server. The main changes include:
Key Improvements
Additional Enhancements
Next Steps (Future PRs)
This PR focuses solely on masterconn.cc to keep the changes manageable for review. More refinements will follow in subsequent PRs.