MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / postgres_client

Function postgres_client

src/testdrive/src/util/postgres.rs:52–74  ·  view source on GitHub ↗
(
    url: &str,
    default_timeout: Duration,
)

Source from the content-addressed store, hash-verified

50}
51
52pub async fn postgres_client(
53 url: &str,
54 default_timeout: Duration,
55) -> Result<(Client, task::JoinHandle<Result<(), tokio_postgres::Error>>), anyhow::Error> {
56 let (client, connection) = Retry::default()
57 .max_duration(default_timeout)
58 .retry_async_canceling(|_| async move {
59 let pgconfig = &mut Config::from_str(url)?;
60 pgconfig.connect_timeout(default_timeout);
61 let tls = make_tls(pgconfig)?;
62 pgconfig.connect(tls).await.map_err(|e| anyhow!(e))
63 })
64 .await?;
65
66 if url.contains("mzp_") {
67 println!("Connecting to PostgreSQL server at [REDACTED]...");
68 } else {
69 println!("Connecting to PostgreSQL server at {}...", url);
70 }
71 let handle = task::spawn(|| "postgres_client_task", connection);
72
73 Ok((client, handle))
74}

Callers 5

reset_materializeMethod · 0.85
check_statement_loggingFunction · 0.85
run_executeFunction · 0.85
run_verify_slotFunction · 0.85
run_connectFunction · 0.85

Calls 7

make_tlsFunction · 0.85
spawnFunction · 0.85
retry_async_cancelingMethod · 0.80
max_durationMethod · 0.80
connect_timeoutMethod · 0.45
connectMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected