refactor: structure of an hexagonal architecture
Created a kernel crate to store models and future action implementations. Will be useful to create admin cli.
This commit is contained in:
parent
69af48bb62
commit
3713cc2443
87 changed files with 834 additions and 474 deletions
21
lib/kernel/src/database.rs
Normal file
21
lib/kernel/src/database.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
use anyhow::{Context, Result};
|
||||
use sqlx::{sqlite::{SqliteConnectOptions, SqlitePoolOptions}, ConnectOptions};
|
||||
use std::str::FromStr;
|
||||
|
||||
use crate::repositories::storage::Storage;
|
||||
|
||||
pub async fn prepare_database(sqlite_db_path: &str) -> Result<Storage> {
|
||||
let conn_str = format!("sqlite:{}", sqlite_db_path);
|
||||
|
||||
let pool = SqlitePoolOptions::new()
|
||||
.max_connections(50)
|
||||
.connect_with(
|
||||
SqliteConnectOptions::from_str(&conn_str)?
|
||||
.log_statements(log::LevelFilter::Trace)
|
||||
)
|
||||
.await
|
||||
.context("could not connect to database_url")?;
|
||||
|
||||
Ok(Storage(pool))
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue