refact: migrate sqlx + sqlite to tokio-postgresql
This commit is contained in:
parent
4f5e21becb
commit
03b614c62e
12 changed files with 838 additions and 250 deletions
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
use bytes::Bytes;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::SqlitePool;
|
||||
use deadpool_postgres::Pool;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use tokio::fs;
|
||||
|
|
@ -57,12 +57,12 @@ pub struct AppState {
|
|||
pub rooms: Mutex<HashMap<String, Room>>,
|
||||
/// Contains a mapping from game name to the maximum amount of players allowed.
|
||||
pub configs: RwLock<HashMap<String, u16>>,
|
||||
/// SQLite connection pool — shared across all request handlers.
|
||||
pub db: SqlitePool,
|
||||
/// PostgreSQL connection pool — shared across all request handlers.
|
||||
pub db: Pool,
|
||||
}
|
||||
|
||||
impl AppState {
|
||||
pub fn new(db: SqlitePool) -> Self {
|
||||
pub fn new(db: Pool) -> Self {
|
||||
Self {
|
||||
rooms: Mutex::new(HashMap::new()),
|
||||
configs: RwLock::new(HashMap::new()),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue