MCPcopy Create free account
hub / github.com/Rustixir/darkbird / connect_to_postgres

Method connect_to_postgres

src/darkbird/persistent_worker.rs:72–91  ·  view source on GitHub ↗
(cfg_string: String)

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected