mirror of
https://github.com/Xevion/Pac-Man.git
synced 2025-12-16 22:12:36 -06:00
refactor: allow optional database in setup, use derived default
This commit is contained in:
@@ -44,6 +44,16 @@ pub struct AppState {
|
||||
|
||||
impl AppState {
|
||||
pub async fn new(config: Config, auth: AuthRegistry, db: PgPool, shutdown_notify: Arc<Notify>) -> Self {
|
||||
Self::new_with_database(config, auth, db, shutdown_notify, true).await
|
||||
}
|
||||
|
||||
pub async fn new_with_database(
|
||||
config: Config,
|
||||
auth: AuthRegistry,
|
||||
db: PgPool,
|
||||
shutdown_notify: Arc<Notify>,
|
||||
use_database: bool,
|
||||
) -> Self {
|
||||
let jwt_secret = config.jwt_secret.clone();
|
||||
|
||||
// Initialize image storage
|
||||
@@ -67,8 +77,8 @@ impl AppState {
|
||||
healthchecker_task: Arc::new(RwLock::new(None)),
|
||||
};
|
||||
|
||||
// Start the healthchecker task
|
||||
{
|
||||
// Start the healthchecker task only if database is being used
|
||||
if use_database {
|
||||
let health_state = app_state.health.clone();
|
||||
let db_pool = app_state.db.clone();
|
||||
let healthchecker_task = app_state.healthchecker_task.clone();
|
||||
|
||||
Reference in New Issue
Block a user