Created
May 9, 2022 00:53
-
-
Save EvanCarroll/235e25564c32f4740b9301407ee06ee0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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