Skip to content

Instantly share code, notes, and snippets.

@EvanCarroll
Created May 9, 2022 00:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EvanCarroll/235e25564c32f4740b9301407ee06ee0 to your computer and use it in GitHub Desktop.
Save EvanCarroll/235e25564c32f4740b9301407ee06ee0 to your computer and use it in GitHub Desktop.
let mut res = config
.connect(tokio_postgres::NoTls)
.await;
let (dbh, connection);
loop {
match res {
Err(_) => {
eprintln!("Could not connect, will try again in 1 second");
tokio::time::sleep(std::time::Duration::from_secs(1));
res = config.connect(tokio_postgres::NoTls).await
}
Ok((dbh2, connection2)) => {
dbh = dbh2;
connection = connection2;
break
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment