mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 02:22:21 +00:00
Remove RwLock around stores, locking shall be the responsibility of the store implementation
This commit is contained in:
@@ -6,12 +6,11 @@ use rustical_frontend::configure_frontend;
|
||||
use rustical_store::auth::AuthenticationProvider;
|
||||
use rustical_store::{AddressbookStore, CalendarStore};
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::RwLock;
|
||||
use tracing_actix_web::TracingLogger;
|
||||
|
||||
pub fn make_app<AS: AddressbookStore + ?Sized, CS: CalendarStore + ?Sized>(
|
||||
addr_store: Arc<RwLock<AS>>,
|
||||
cal_store: Arc<RwLock<CS>>,
|
||||
addr_store: Arc<AS>,
|
||||
cal_store: Arc<CS>,
|
||||
auth_provider: Arc<impl AuthenticationProvider>,
|
||||
) -> App<
|
||||
impl ServiceFactory<
|
||||
|
||||
@@ -19,7 +19,6 @@ use rustical_store::{AddressbookStore, CalendarStore};
|
||||
use std::fs;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use tokio::sync::RwLock;
|
||||
use tracing::level_filters::LevelFilter;
|
||||
use tracing_opentelemetry::OpenTelemetryLayer;
|
||||
use tracing_subscriber::layer::SubscriberExt;
|
||||
@@ -41,14 +40,11 @@ struct Args {
|
||||
async fn get_data_stores(
|
||||
migrate: bool,
|
||||
config: &DataStoreConfig,
|
||||
) -> Result<(
|
||||
Arc<RwLock<dyn AddressbookStore>>,
|
||||
Arc<RwLock<dyn CalendarStore>>,
|
||||
)> {
|
||||
) -> Result<(Arc<dyn AddressbookStore>, Arc<dyn CalendarStore>)> {
|
||||
Ok(match &config {
|
||||
DataStoreConfig::Sqlite(SqliteDataStoreConfig { db_url }) => {
|
||||
let db = create_db_pool(db_url, migrate).await?;
|
||||
let sqlite_store = Arc::new(RwLock::new(SqliteStore::new(db)));
|
||||
let sqlite_store = Arc::new(SqliteStore::new(db));
|
||||
(sqlite_store.clone(), sqlite_store.clone())
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user