refactor
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
use crate::core::config::Config;
|
||||
use dashmap::DashMap;
|
||||
use serde::Serialize;
|
||||
use sqlx::SqlitePool;
|
||||
use std::sync::{Arc, atomic::AtomicUsize};
|
||||
use tokio::sync::{mpsc, oneshot};
|
||||
|
||||
pub type Database = SqlitePool;
|
||||
pub type DeviceCounts = DashMap<String, Arc<AtomicUsize>>;
|
||||
pub type Registry = DashMap<(String, String), RegistryEntry>;
|
||||
|
||||
pub struct RegistryEntry {
|
||||
pub sender: mpsc::Sender<PendingExec>,
|
||||
pub in_flight: Arc<AtomicUsize>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct ExecResult {
|
||||
pub exit_code: i32,
|
||||
pub stdout: String,
|
||||
pub stderr: String,
|
||||
}
|
||||
|
||||
pub struct PendingExec {
|
||||
pub exec_id: String,
|
||||
pub command: String,
|
||||
pub reply: oneshot::Sender<ExecResult>,
|
||||
}
|
||||
|
||||
pub struct AppState {
|
||||
pub database: Database,
|
||||
pub registry: Arc<Registry>,
|
||||
pub device_counts: Arc<DeviceCounts>,
|
||||
pub config: Arc<Config>,
|
||||
}
|
||||
Reference in New Issue
Block a user