From 7e8e688e2e58f9c944b941e768ab7b034a348a1f Mon Sep 17 00:00:00 2001 From: Vika Date: Thu, 1 Aug 2024 19:48:37 +0300 Subject: treewide: create a common method for state initialization Now the database objects can be uniformly created from a URI. They can also optionally do sanity checks and one-time initialization. --- src/webmentions/queue.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/webmentions/queue.rs') diff --git a/src/webmentions/queue.rs b/src/webmentions/queue.rs index b811e71..af1387f 100644 --- a/src/webmentions/queue.rs +++ b/src/webmentions/queue.rs @@ -1,7 +1,7 @@ -use std::{pin::Pin, str::FromStr}; +use std::pin::Pin; use futures_util::{Stream, StreamExt}; -use sqlx::{postgres::PgListener, Executor}; +use sqlx::{postgres::PgListener, ConnectOptions, Executor}; use uuid::Uuid; use super::Webmention; @@ -115,8 +115,8 @@ impl Clone for PostgresJobQueue { } impl PostgresJobQueue { - pub async fn new(uri: &str) -> Result { - let mut options = sqlx::postgres::PgConnectOptions::from_str(uri)? + pub async fn new(uri: &url::Url) -> Result { + let mut options = sqlx::postgres::PgConnectOptions::from_url(uri)? .options([("search_path", "kittybox_webmention")]); if let Ok(password_file) = std::env::var("PGPASS_FILE") { let password = tokio::fs::read_to_string(password_file).await.unwrap(); -- cgit 1.4.1