Xline icon indicating copy to clipboard operation
Xline copied to clipboard

refactor: split config into multiple modules

Open Harsh1s opened this issue 11 months ago β€’ 15 comments

  • what problem are you trying to solve? (or if there's no problem, what's the motivation for this change?) -> Fixes #604 -> Currently all configurations are in a single file, utils/src/config.rs,It also contains a lot of parse_xxx, xxx_format, default_xxx methods, It's messy and difficult to manage. This PR organizes these configurations into modules, each containing the configuration itself, its parse method, and default values.

  • what changes does this pull request make? -> It adds a different folder structure and splits every config struct into a separate module. I plan on replacing new method with a more flexible builder method.

  • are there any non-obvious implications of these changes? (does it break compatibility with previous versions, etc) -> Not yet, although a builder refactor could mean little rewrites in curp

Harsh1s avatar Mar 06 '24 22:03 Harsh1s

I'll refactor the new methods into builder methods into another commit. Before doing that just some wanted feedback if possible.

Harsh1s avatar Mar 06 '24 22:03 Harsh1s

@Harsh1s Convert your pr to draft since CI failed

mergify[bot] avatar Apr 18 '24 06:04 mergify[bot]

@Harsh1s Your PR is in conflict and cannot be merged.

mergify[bot] avatar Apr 18 '24 06:04 mergify[bot]

Hi, @Harsh1s ! This pr has been stalled for 2 months. Would you like to update it? πŸ˜„

Phoenix500526 avatar May 10 '24 01:05 Phoenix500526

Hi, @Harsh1s ! This pr has been stalled for 2 months. Would you like to update it? πŸ˜„

I am so very sorry, I assure you I'll update it within a day.

Harsh1s avatar May 10 '24 09:05 Harsh1s

@Phoenix500526 I redid the refactor with latest changes, I still have to rewrite new methods into builder pattern which I'll do by EOD. Could you please review if current refactor is fine? I'll do the builder rewrite in the meantime.

Harsh1s avatar May 14 '24 08:05 Harsh1s

@Harsh1s Convert your pr to draft since CI failed

mergify[bot] avatar May 14 '24 08:05 mergify[bot]

Codecov Report

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

Project coverage is 75.54%. Comparing base (e35b35a) to head (3482952). Report is 84 commits behind head on master.

:exclamation: Current head 3482952 differs from pull request most recent head 93f0429

Please upload reports for the commit 93f0429 to get more accurate results.

Files Patch % Lines
crates/utils/src/config/metrics.rs 57.62% 22 Missing and 3 partials :warning:
crates/utils/src/config/log.rs 60.37% 17 Missing and 4 partials :warning:
crates/utils/src/config/compact.rs 57.57% 11 Missing and 3 partials :warning:
crates/utils/src/config/curp.rs 85.93% 7 Missing and 2 partials :warning:
crates/utils/src/config/client.rs 95.16% 1 Missing and 2 partials :warning:
crates/utils/src/config/cluster.rs 94.44% 0 Missing and 3 partials :warning:
crates/utils/src/config/mod.rs 99.40% 1 Missing and 1 partial :warning:
crates/utils/src/config/server.rs 95.12% 0 Missing and 2 partials :warning:
crates/utils/src/config/auth.rs 85.71% 0 Missing and 1 partial :warning:
crates/utils/src/config/engine.rs 75.00% 0 Missing and 1 partial :warning:
... and 3 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #676      +/-   ##
==========================================
- Coverage   75.55%   75.54%   -0.02%     
==========================================
  Files         180      198      +18     
  Lines       26938    27496     +558     
  Branches    26938    27496     +558     
==========================================
+ Hits        20353    20771     +418     
- Misses       5366     5446      +80     
- Partials     1219     1279      +60     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar May 16 '24 09:05 codecov[bot]

Hi, @Harsh1s I've rebased this pr and modify the code to pass the ci process.

Phoenix500526 avatar May 16 '24 12:05 Phoenix500526

Thanks for the help @Phoenix500526 , I've pulled the changes and I'll address all your reviews now. I also started working on builder patterns for all the structs, I'll make commits one by one.

Harsh1s avatar May 17 '24 09:05 Harsh1s

@Harsh1s Convert your pr to draft since CI failed

mergify[bot] avatar May 17 '24 09:05 mergify[bot]

Hi, @Harsh1s! IMO, to implement the builder pattern for all these XXConfig structures may not be a good practice. I only recommend implementing the builder pattern for those XXConfig structures with too many arguments in their constructor. BTW, to pass the commit message validation ci task, please use "refactor(config)" or "refactor" to replace the "refactor-config" in your commit message. πŸ˜„

Phoenix500526 avatar May 17 '24 09:05 Phoenix500526

Hi, @Harsh1s! IMO, to implement the builder pattern for all these XXConfig structures may not be a good practice. I only recommend implementing the builder pattern for those XXConfig structures with too many arguments in their constructor. BTW, to pass the commit message validation ci task, please use "refactor(config)" or "refactor" to replace the "refactor-config" in your commit message. πŸ˜„

Understood, thank you so much for all the help and being so patient with me!

Harsh1s avatar May 17 '24 09:05 Harsh1s

We also provide the .pre-commit-config.yaml in our project root. You can execute the pre-commit install command at the project root to install the git hook. It will automatically run the cargo fmt, cargo clippy and validate the commit message for you before you commit your code modifications. I think it's helpful.

Phoenix500526 avatar May 17 '24 09:05 Phoenix500526

We also provide the .pre-commit-config.yaml in our project root. You can execute the pre-commit install command at the project root to install the git hook. It will automatically run the cargo fmt, cargo clippy and validate the commit message for you before you commit your code modifications. I think it's helpful.

Okay, will do. Thanks!

Harsh1s avatar May 17 '24 10:05 Harsh1s

It has been a while since there was any activity on this pull request. Unfortunately, we have decided to close this PR for now.

If you're still interested in contributing this change, please reopen this pr. Alternatively, if you could provide an update or a status on your end, that would also be very helpful.

Thank you for your contribution!

lxl66566 avatar Aug 08 '24 00:08 lxl66566