-
-
Notifications
You must be signed in to change notification settings - Fork 216
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
Added validate function to PgConfig and invoked it in finalize and pool initialization #1546
Conversation
…ol initialization
@nyurik Kindly refer to the latest commit I have made. |
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.
a few minor things, and this will be ready to go! :)
martin/src/pg/config.rs
Outdated
Ok(res) | ||
} | ||
|
||
pub async fn resolve(&mut self, id_resolver: IdResolver) -> MartinResult<TileInfoSources> { | ||
self.validate()?; |
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 we need to validate it in so many places - here, in the pool, and in finalize? I don't remember for sure which codepath always executes, but we should probably limit it to just one. Probably finalize? Please check. Thx!
martin/src/pg/errors.rs
Outdated
@@ -69,4 +69,7 @@ pub enum PgError { | |||
|
|||
#[error(r#"Unable to get tile {2:#} with {:?} params from {1}: {0}"#, query_to_json(.3.as_ref()))] | |||
GetTileWithQueryError(#[source] TokioPgError, String, TileCoord, Option<UrlQuery>), | |||
|
|||
#[error("Validation error: {0}")] | |||
ValidationError(String), |
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.
Lets call this ConfigError
. Also, at least for now, all errors are &'static str
- so we don't need to call .into()
on them to convert str into an allocated String.
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.
thanks!!
@nyurik Thanks for merging! Could you please add the "hacktoberfest-accepted" label? Thanks for considering! |
@Saru2003 adding labels is only nessesary if a PR is not accepted via an approving review or merged. |
i'm a bit confused - what labeling are you talking about? We only add labels relevant to the Martin project, e.g. which subsystem the PR applies to, or things like "help needed", etc. |
This PR addresses issue #1542, which states that the PostgreSQL pool size should not be allowed to be set to less than 1.
Changes:
Updated the finalize and resolve methods to call the validate method. This ensures that the configuration is validated before proceeding with further processing.
Updated pool.rs, ensures the validation process is integrated when creating a new pool by calling the validate method from the PgConfig instance.
Please review my implementation and provide feedback.