Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3255323

Browse filesBrowse files
authored
Adds option to log which parameter status is changed by the client (#550)
1 parent bb27586 commit 3255323
Copy full SHA for 3255323

File tree

Expand file treeCollapse file tree

4 files changed

+25
-0
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+25
-0
lines changed

‎src/config.rs

Copy file name to clipboardExpand all lines: src/config.rs
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,9 @@ pub struct Pool {
547547
#[serde(default = "Pool::default_cleanup_server_connections")]
548548
pub cleanup_server_connections: bool,
549549

550+
#[serde(default)] // False
551+
pub log_client_parameter_status_changes: bool,
552+
550553
pub plugins: Option<Plugins>,
551554
pub shards: BTreeMap<String, Shard>,
552555
pub users: BTreeMap<String, User>,
@@ -696,6 +699,7 @@ impl Default for Pool {
696699
server_lifetime: None,
697700
plugins: None,
698701
cleanup_server_connections: true,
702+
log_client_parameter_status_changes: false,
699703
}
700704
}
701705
}
@@ -1157,6 +1161,10 @@ impl Config {
11571161
"[pool: {}] Cleanup server connections: {}",
11581162
pool_name, pool_config.cleanup_server_connections
11591163
);
1164+
info!(
1165+
"[pool: {}] Log client parameter status changes: {}",
1166+
pool_name, pool_config.log_client_parameter_status_changes
1167+
);
11601168
info!(
11611169
"[pool: {}] Plugins: {}",
11621170
pool_name,

‎src/mirrors.rs

Copy file name to clipboardExpand all lines: src/mirrors.rs
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ impl MirroredClient {
4141
Arc::new(RwLock::new(None)),
4242
None,
4343
true,
44+
false,
4445
);
4546

4647
Pool::builder()

‎src/pool.rs

Copy file name to clipboardExpand all lines: src/pool.rs
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ impl ConnectionPool {
371371
None => config.plugins.clone(),
372372
},
373373
pool_config.cleanup_server_connections,
374+
pool_config.log_client_parameter_status_changes,
374375
);
375376

376377
let connect_timeout = match pool_config.connect_timeout {
@@ -956,6 +957,9 @@ pub struct ServerPool {
956957

957958
/// Should we clean up dirty connections before putting them into the pool?
958959
cleanup_connections: bool,
960+
961+
/// Log client parameter status changes
962+
log_client_parameter_status_changes: bool,
959963
}
960964

961965
impl ServerPool {
@@ -967,6 +971,7 @@ impl ServerPool {
967971
auth_hash: Arc<RwLock<Option<String>>>,
968972
plugins: Option<Plugins>,
969973
cleanup_connections: bool,
974+
log_client_parameter_status_changes: bool,
970975
) -> ServerPool {
971976
ServerPool {
972977
address,
@@ -976,6 +981,7 @@ impl ServerPool {
976981
auth_hash,
977982
plugins,
978983
cleanup_connections,
984+
log_client_parameter_status_changes,
979985
}
980986
}
981987
}
@@ -1005,6 +1011,7 @@ impl ManageConnection for ServerPool {
10051011
stats.clone(),
10061012
self.auth_hash.clone(),
10071013
self.cleanup_connections,
1014+
self.log_client_parameter_status_changes,
10081015
)
10091016
.await
10101017
{

‎src/server.rs

Copy file name to clipboardExpand all lines: src/server.rs
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,9 @@ pub struct Server {
322322
/// Should clean up dirty connections?
323323
cleanup_connections: bool,
324324

325+
/// Log client parameter status changes
326+
log_client_parameter_status_changes: bool,
327+
325328
/// Prepared statements
326329
prepared_statements: BTreeSet<String>,
327330
}
@@ -337,6 +340,7 @@ impl Server {
337340
stats: Arc<ServerStats>,
338341
auth_hash: Arc<RwLock<Option<String>>>,
339342
cleanup_connections: bool,
343+
log_client_parameter_status_changes: bool,
340344
) -> Result<Server, Error> {
341345
let cached_resolver = CACHED_RESOLVER.load();
342346
let mut addr_set: Option<AddrSet> = None;
@@ -825,6 +829,7 @@ impl Server {
825829
)),
826830
},
827831
cleanup_connections,
832+
log_client_parameter_status_changes,
828833
prepared_statements: BTreeSet::new(),
829834
};
830835

@@ -1009,6 +1014,9 @@ impl Server {
10091014

10101015
if let Some(client_server_parameters) = client_server_parameters.as_mut() {
10111016
client_server_parameters.set_param(key.clone(), value.clone(), false);
1017+
if self.log_client_parameter_status_changes {
1018+
info!("Client parameter status change: {} = {}", key, value)
1019+
}
10121020
}
10131021

10141022
self.server_parameters.set_param(key, value, false);
@@ -1382,6 +1390,7 @@ impl Server {
13821390
Arc::new(ServerStats::default()),
13831391
Arc::new(RwLock::new(None)),
13841392
true,
1393+
false,
13851394
)
13861395
.await?;
13871396
debug!("Connected!, sending query.");

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.