(cfg_string: String)
| 70 | } |
| 71 | |
| 72 | async fn connect_to_postgres(cfg_string: String) -> Result<Persistent, Error> { |
| 73 | let (client, connection) = match tokio_postgres::connect(&cfg_string, NoTls).await { |
| 74 | Ok(res) => res, |
| 75 | Err(e) => return Err(e), |
| 76 | }; |
| 77 | |
| 78 | // The connection object performs the actual communication with the database, |
| 79 | // so spawn it off to run on its own. |
| 80 | tokio::spawn(async move { |
| 81 | if let Err(e) = connection.await { |
| 82 | eprintln!("connection error: {}", e); |
| 83 | } |
| 84 | }); |
| 85 | |
| 86 | let persist = Persistent { |
| 87 | db_session: DatabaseSession::Postgres(client), |
| 88 | }; |
| 89 | |
| 90 | Ok(persist) |
| 91 | } |
| 92 | |
| 93 | async fn connect_to_scylla(uri: String) -> Result<Persistent, NewSessionError> { |
| 94 | let session = match SessionBuilder::new().known_node(uri).build().await { |
nothing calls this directly
no outgoing calls
no test coverage detected