-
Notifications
You must be signed in to change notification settings - Fork 76
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: split config into multiple modules #676
Conversation
I'll refactor the new methods into builder methods into another commit. Before doing that just some wanted feedback if possible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some code style problems, please format the code. BTW, please comment on the issue #604, so I can assign this issue to you.
@Harsh1s Convert your pr to draft since CI failed |
@Harsh1s Your PR is in conflict and cannot be merged. |
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. |
@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 Convert your pr to draft since CI failed |
Signed-off-by: Harsh1s <[email protected]>
Signed-off-by: Harsh1s <[email protected]>
Signed-off-by: Harsh1s <[email protected]>
33a8026
to
cb9497b
Compare
Signed-off-by: Phoeniix Zhao <[email protected]>
9c1aaa9
to
d1904bd
Compare
Signed-off-by: Phoeniix Zhao <[email protected]>
d1904bd
to
3482952
Compare
Codecov ReportAttention: Patch coverage is
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 ☔ View full report in Codecov by Sentry. |
Hi, @Harsh1s I've rebased this pr and modify the code to pass the ci process. |
use getset::Getters; | ||
use serde::Deserialize; | ||
|
||
use crate::config::{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better use use self::{auth::AuthConfig, .....}
/// Generates a new `XlineServerConfig` object | ||
#[must_use] | ||
#[inline] | ||
#[allow(clippy::too_many_arguments)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we use a builder pattern to refactor it?
@@ -0,0 +1,442 @@ | |||
/// Xline auth configuration module |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can provide a prelude here or publicly use those XXConfig here. In doing so, we can use use utils::config::prelude::{AuthConfig, ClientConfig}
or use utils::config::{AuthConfig, ClientConfig}
instead of use utils::config::{auth::AuthConfig, client::ClientConfig}
.
/// Enable or not | ||
#[getset(get = "pub")] | ||
#[serde(default = "default_metrics_enable")] | ||
pub enable: bool, | ||
/// The http port to expose | ||
#[getset(get = "pub")] | ||
#[serde(default = "default_metrics_port")] | ||
pub port: u16, | ||
/// The http path to expose | ||
#[getset(get = "pub")] | ||
#[serde(default = "default_metrics_path")] | ||
pub path: String, | ||
/// Enable push or not | ||
#[getset(get = "pub")] | ||
#[serde(default = "default_metrics_push")] | ||
pub push: bool, | ||
/// Push endpoint | ||
#[getset(get = "pub")] | ||
#[serde(default = "default_metrics_push_endpoint")] | ||
pub push_endpoint: String, | ||
/// Push protocol | ||
#[getset(get = "pub")] | ||
#[serde(with = "protocol_format", default = "default_metrics_push_protocol")] | ||
pub push_protocol: MetricsPushProtocol, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you change the visibility of these fields when you already have their public getter methods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I prefer to change the visibility of fields rather than use a public getter in that both achieve the same result, but the getter method introduces additional dependencies.
/// The public key file | ||
#[getset(get = "pub")] | ||
pub auth_public_key: Option<PathBuf>, | ||
/// The private key file | ||
#[getset(get = "pub")] | ||
pub auth_private_key: Option<PathBuf>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
@@ -422,7 +422,7 @@ impl TestCE { | |||
after_sync_sender: mpsc::UnboundedSender<(TestCommand, LogIndex)>, | |||
engine_cfg: EngineConfig, | |||
) -> Self { | |||
let engine_type = match engine_cfg { | |||
let engine_type: EngineType = match engine_cfg { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: please remove this EngineType
.
#[getset(get = "pub")] | ||
pub auth_public_key: Option<PathBuf>, | ||
/// The private key file | ||
#[getset(get = "pub")] | ||
pub auth_private_key: Option<PathBuf>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
#[getset(get = "pub")] | ||
pub peer_ca_cert_path: Option<PathBuf>, | ||
/// The public key file used by peer | ||
#[getset(get = "pub")] | ||
pub peer_cert_path: Option<PathBuf>, | ||
/// The private key file used by peer | ||
#[getset(get = "pub")] | ||
pub peer_key_path: Option<PathBuf>, | ||
/// The CA certificate file used by client to verify peer certificates | ||
#[getset(get = "pub")] | ||
pub client_ca_cert_path: Option<PathBuf>, | ||
/// The public key file used by client | ||
#[getset(get = "pub")] | ||
pub client_cert_path: Option<PathBuf>, | ||
/// The private key file used by client | ||
#[getset(get = "pub")] | ||
pub client_key_path: Option<PathBuf>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
Signed-off-by: Harsh1s <[email protected]>
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 Convert your pr to draft since CI failed |
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! |
We also provide the |
Okay, will do. Thanks! |
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! |
what problem are you trying to solve? (or if there's no problem, what's the motivation for this change?)
-> Fixes [Refactor]: config #604
-> Currently all configurations are in a single file,
utils/src/config.rs
,It also contains a lot ofparse_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