Repository navigation
fix(proxy): use log targets for connection events #533
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
Changes from all commits
0f73f57
f3b7652
d739dba
e10abc1
eef4292
52017f8
b761ac7
9a887b0
372ee5b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,57 +90,38 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { | |
| } | ||
| } | ||
|
|
||
| loop { | ||
| tokio::select! { | ||
| _ = sigint() => { | ||
| info!(msg = "Received SIGINT"); | ||
| break; | ||
| }, | ||
| _ = sighup() => { | ||
| info!(msg = "Received SIGHUP. Reloading application configuration"); | ||
| proxy = reload_application_config(&proxy.config, &args).await.unwrap_or(proxy); | ||
| }, | ||
| _ = sigterm() => { | ||
| info!(msg = "Received SIGTERM"); | ||
| break; | ||
| }, | ||
| Ok(client_stream) = connect::accept(&listener) => { | ||
|
|
||
| loop { | ||
| tokio::select! { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minor Only Source: standards review, spec review (mattpocock code-review) · claude-opus-5-5 Generated by Claude Code |
||
| _ = sigint() => { | ||
| info!(msg = "Received SIGINT"); | ||
| break; | ||
| }, | ||
| _ = sighup() => { | ||
| info!(msg = "Received SIGHUP. Reloading application configuration"); | ||
| proxy = reload_application_config(&proxy.config, &args).await.unwrap_or(proxy); | ||
| }, | ||
| _ = sigterm() => { | ||
| info!(msg = "Received SIGTERM"); | ||
| break; | ||
| }, | ||
| Ok(client_stream) = connect::accept(&listener) => { | ||
| client_id += 1; | ||
|
|
||
| let context = proxy.context(client_id); | ||
|
|
||
| tracker.spawn(async move { | ||
|
|
||
| gauge!(CLIENTS_ACTIVE_CONNECTIONS).increment(1); | ||
| // Decrements even if the handler panics or the task | ||
| // is dropped, so the gauge cannot drift upwards. | ||
| let active_connection = DropGuard::new((), |()| { | ||
| gauge!(CLIENTS_ACTIVE_CONNECTIONS).decrement(1); | ||
| }); | ||
|
|
||
| let result = pg::handler(client_stream,context).await; | ||
| let result = pg::handler(client_stream, context).await; | ||
| drop(active_connection); | ||
|
|
||
| match result { | ||
| Ok(_) => (), | ||
| Err(err) => { | ||
| match err { | ||
| Error::ConnectionClosed => { | ||
| info!(msg = "Database connection closed by client"); | ||
| } | ||
| Error::CancelRequest => { | ||
| info!(msg = "Database connection closed after cancel request"); | ||
| } | ||
| Error::ConnectionTimeout{..} => { | ||
| // No message moved either way for the connection timeout, usually a pool's idle connection | ||
| info!(target: log::PROTOCOL, msg = "Database connection timeout", error = err.to_string()); | ||
| } | ||
| _ => { | ||
| error!(msg = "Database connection error", error = %ErrorChain(&err)); | ||
| } | ||
| } | ||
| }, | ||
| if let Err(err) = result { | ||
| pg::connection_events::connection_ended(&err, client_id); | ||
| } | ||
| }); | ||
| }, | ||
|
|
||
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.
minor The message text also changes, from
Connection error: <chain>toEncryption Migrator connection error, and the chain moves into anerrorfield. The CHANGELOG only says the target changed, so a log search or alert on the old text stops matching without warning. Add the new message name to the CHANGELOG entry. Line 288 has the same change.Source: spec review (mattpocock code-review) · claude-opus-5-5
Generated by Claude Code