postgres session storage backend

This commit is contained in:
Igor Katson 2024-08-15 14:18:55 +01:00
parent f22814c77b
commit 2871c358e3
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
8 changed files with 99 additions and 48 deletions

View file

@ -332,6 +332,8 @@ impl<'a> AddTorrent<'a> {
pub enum SessionPersistenceConfig {
/// The filename for persistence. By default uses an OS-specific folder.
Json { folder: Option<PathBuf> },
#[cfg(feature = "postgres")]
Postgres { connection_string: String },
}
impl SessionPersistenceConfig {
@ -494,6 +496,12 @@ impl Session {
.await
.context("error initializing JsonSessionPersistenceStore")?,
)))
},
#[cfg(feature = "postgres")]
Some(SessionPersistenceConfig::Postgres { connection_string }) => {
use crate::session_persistence::postgres::PostgresSessionStorage;
let p = PostgresSessionStorage::new(connection_string).await?;
Ok(Some(Box::new(p)))
}
None => Ok(None),
}