diff options
author | Vika <vika@fireburn.ru> | 2024-08-01 19:48:37 +0300 |
---|---|---|
committer | Vika <vika@fireburn.ru> | 2024-08-01 20:40:00 +0300 |
commit | 7e8e688e2e58f9c944b941e768ab7b034a348a1f (patch) | |
tree | 1068469c6b9b97bac407038276fd8971b2101e48 /src/webmentions | |
parent | 57a9c3c7e520714928904fc7e2ff3d62ac2b2467 (diff) | |
download | kittybox-7e8e688e2e58f9c944b941e768ab7b034a348a1f.tar.zst |
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.
Diffstat (limited to 'src/webmentions')
-rw-r--r-- | src/webmentions/queue.rs | 8 |
1 files changed, 4 insertions, 4 deletions
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<T> Clone for PostgresJobQueue<T> { } impl PostgresJobQueue<Webmention> { - pub async fn new(uri: &str) -> Result<Self, sqlx::Error> { - let mut options = sqlx::postgres::PgConnectOptions::from_str(uri)? + pub async fn new(uri: &url::Url) -> Result<Self, sqlx::Error> { + 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(); |