use std::sync::atomic::AtomicU32;
use std::sync::Arc;
use std::time::Instant;
use tokio::sync::watch;
use crate::daemon::pipe_sessions::PipeSessionRegistry;
use crate::daemon::pty_sessions::PtySessionRegistry;
use crate::daemon::registry::Registry;
#[cfg(test)]
#[allow(unused_imports)]
use crate::proto::daemon::{DaemonRequest, ProcessState, StatusCode};
mod core;
mod kill;
mod maintenance;
mod observer;
mod pipe_sessions_handlers;
mod process_tree;
mod pty_sessions_handlers;
mod registry_handlers;
mod services;
mod spawn;
mod telemetry;
mod util;
pub use self::core::{handle_ping, handle_shutdown, handle_status};
pub use self::kill::{handle_kill_tree, handle_kill_zombies};
pub use self::maintenance::{
handle_bulk_terminate_sessions, handle_get_session_backlog, handle_purge_exited_sessions,
};
pub use self::observer::{
handle_get_session_observer_status, handle_register_session_observer,
handle_unregister_session_observer,
};
pub use self::pipe_sessions_handlers::{
handle_attach_pipe_stream, handle_detach_pipe_stream, handle_list_pipe_sessions,
handle_spawn_pipe_session, handle_terminate_pipe_session, handle_write_pipe_stdin,
};
pub use self::process_tree::handle_get_process_tree;
pub use self::pty_sessions_handlers::{
handle_attach_pty_session, handle_detach_pty_session, handle_list_pty_sessions,
handle_resize_pty_session, handle_spawn_pty_session, handle_terminate_pty_session,
};
pub use self::registry_handlers::{
handle_list_active, handle_list_by_originator, handle_register, handle_unregister,
};
pub use self::services::{
handle_service_delete, handle_service_describe, handle_service_flush, handle_service_list,
handle_service_logs, handle_service_restart, handle_service_resurrect, handle_service_save,
handle_service_start, handle_service_stop,
};
pub use self::spawn::handle_spawn_daemon;
pub use self::telemetry::{
handle_get_session_tee_status, handle_register_session_tee, handle_unregister_session_tee,
};
pub struct DaemonState {
pub start_time: Instant,
pub version: String,
pub socket_path: String,
pub db_path: String,
pub scope: String,
pub scope_hash: String,
pub scope_cwd: String,
pub shutdown_tx: watch::Sender<bool>,
pub active_connections: AtomicU32,
pub registry: Arc<Registry>,
pub pty_sessions: Arc<PtySessionRegistry>,
pub pipe_sessions: Arc<PipeSessionRegistry>,
pub services: Arc<crate::daemon::services::ServiceRegistry>,
pub emergency_reserve: Arc<crate::daemon::emergency_reserve::EmergencyReserve>,
}
#[cfg(test)]
#[path = "../handlers_tests.rs"]
mod tests;