proxy: refactor some error handling and shutdowns (#4684)

## Problem

It took me a while to understand the purpose of all the tasks spawned in
the main functions.

## Summary of changes

Utilising the type system and less macros, plus much more comments,
document the shutdown procedure of each task in detail
This commit is contained in:
Conrad Ludgate
2023-07-13 11:03:37 +01:00
committed by GitHub
parent 444d6e337f
commit 0626e0bfd3
7 changed files with 80 additions and 52 deletions

View File

@@ -6,7 +6,7 @@ use anyhow::Context;
use once_cell::sync::Lazy;
use postgres_backend::{self, AuthType, PostgresBackend, PostgresBackendTCP, QueryError};
use pq_proto::{BeMessage, SINGLE_COL_ROWDESC};
use std::future;
use std::{convert::Infallible, future};
use tokio::net::{TcpListener, TcpStream};
use tracing::{error, info, info_span, Instrument};
@@ -31,7 +31,7 @@ pub fn notify(psql_session_id: &str, msg: ComputeReady) -> Result<(), waiters::N
/// Console management API listener task.
/// It spawns console response handlers needed for the link auth.
pub async fn task_main(listener: TcpListener) -> anyhow::Result<()> {
pub async fn task_main(listener: TcpListener) -> anyhow::Result<Infallible> {
scopeguard::defer! {
info!("mgmt has shut down");
}