Wrap sqlite connection in an Arc and tokios RwLock
This commit is contained in:
parent
898e10f040
commit
d6aee960fa
10
src/main.rs
10
src/main.rs
@ -5,6 +5,7 @@ use std::{
|
||||
io::prelude::*,
|
||||
boxed::Box,
|
||||
error::Error,
|
||||
sync::Arc,
|
||||
};
|
||||
use serde::Deserialize;
|
||||
use sqlx::{
|
||||
@ -14,6 +15,9 @@ use sqlx::{
|
||||
SqliteConnectOptions,
|
||||
},
|
||||
};
|
||||
use tokio::{
|
||||
sync::RwLock,
|
||||
};
|
||||
|
||||
const DEFAULT_DATABASE_PATH: &'static str = "/var/lib/noise-server/noise-server.sqlite";
|
||||
|
||||
@ -55,7 +59,11 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||
println!("{:?}", options);
|
||||
|
||||
#[cfg(feature = "sqlite")]
|
||||
let sqlite_connection = connect_sqlite(&config.database_path).await?;
|
||||
let sqlite_connection = Arc::new(
|
||||
RwLock::new(
|
||||
connect_sqlite(&config.database_path).await?
|
||||
)
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user