-
Notifications
You must be signed in to change notification settings - Fork 202
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 a Plugin
trait
#536
Added a Plugin
trait
#536
Conversation
Looks great! Just going to tag @drdrsh for the address logging change, since I remember him parsing the |
@mdashti thank you for the PR. Let me check how the output looks. |
The change to how I think for logging we need two modes
and we can control this using a startup flag. What do you guys think? |
@drdrsh I think it makes sense. I can revert the |
Hi, any update on this PR? |
@levkk Is there specific changes needed for this PR? Currently, the |
src/client.rs
Outdated
@@ -531,7 +531,7 @@ where | |||
error_response( | |||
&mut write, | |||
&format!( | |||
"No pool configured for database: {:?}, user: {:?}", | |||
"No pool configured for database: {:?}, user: {:?} (in startup)", |
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.
This is debug level messaging we should not be returning to the client.
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.
Good point. Reverted this.
@@ -763,15 +763,26 @@ pub struct Plugins { | |||
pub prewarmer: Option<Prewarmer>, | |||
} | |||
|
|||
pub trait Plugin { |
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.
Nice to have a trait, but don't think you need it for this particular fix. We should discuss what trait we should have for a Plugin to implement, so we can get on our way to a real plugin system.
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.
Second thought I see why you added it here.
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.
I'm also thinking about the plugin system. I should write down my thoughts and share it with you. Please do the same if you have such notes.
src/client.rs
Outdated
@@ -1354,7 +1354,7 @@ where | |||
// Sync | |||
// Frontend (client) is asking for the query result now. | |||
'S' => { | |||
debug!("Sending query to server"); | |||
debug!("Sending query to server (in Sync mode)"); |
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.
No such thing as "sync" mode, this is the extended protocol. Maybe make the debug line something like:
Sending query to server with extended protocol
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.
Reverted this.
src/client.rs
Outdated
@@ -1241,7 +1241,7 @@ where | |||
let _ = query_router.infer(&ast); | |||
} | |||
} | |||
debug!("Sending query to server"); | |||
debug!("Sending query to server (in Query mode)"); |
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 comment as below.
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.
Reverted this.
impl std::fmt::Display for Plugins { | ||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
fn is_enabled<T: Plugin>(arg: Option<&T>) -> bool { |
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.
Cleaner and safer to write it this way:
if let Some(arg) = arg {
arg.is_enabled()
} else {
false
}
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.
That's a valid suggestion. Thanks. Done.
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.
LGTM. Let me know if it's ready to merge, I'm happy to accept this as-is. Just going to let the CI run first.
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.
@levkk Thanks for the review.
src/client.rs
Outdated
@@ -531,7 +531,7 @@ where | |||
error_response( | |||
&mut write, | |||
&format!( | |||
"No pool configured for database: {:?}, user: {:?}", | |||
"No pool configured for database: {:?}, user: {:?} (in startup)", |
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.
Good point. Reverted this.
src/client.rs
Outdated
@@ -1354,7 +1354,7 @@ where | |||
// Sync | |||
// Frontend (client) is asking for the query result now. | |||
'S' => { | |||
debug!("Sending query to server"); | |||
debug!("Sending query to server (in Sync mode)"); |
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.
Reverted this.
impl std::fmt::Display for Plugins { | ||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
fn is_enabled<T: Plugin>(arg: Option<&T>) -> bool { |
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.
That's a valid suggestion. Thanks. Done.
src/client.rs
Outdated
@@ -1241,7 +1241,7 @@ where | |||
let _ = query_router.infer(&ast); | |||
} | |||
} | |||
debug!("Sending query to server"); | |||
debug!("Sending query to server (in Query mode)"); |
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.
Reverted this.
This PR applies the following improvements:
Address
implements thestd::fmt::Display
trait, we'd better use{}
formatter instead of{:?}
to make the logs more readable.