rustploy 0.1.36

Rustploy PaaS daemon — lightweight self-hosted deployment platform
//! Handlers de observability: o `dispatch` recebe os `Command` da seção e chama o handler certo.

pub mod apply_update;
pub mod check_update;
pub mod daemon_status;
pub mod ingress;
pub mod logs_executions;
pub mod logs_get;
pub mod logs_history;
pub mod ping;
pub mod update_status;

use crate::bootstrap::state::AppState;
use shared::{Command, Response as RpResponse};

pub async fn dispatch(state: AppState, cmd: Command) -> RpResponse {
    match cmd {
        Command::Ping => ping::handle(state).await,
        Command::DaemonStatus => daemon_status::handle(state).await,
        Command::CheckUpdate { force } => check_update::handle(state, force).await,
        Command::ApplyUpdate {
            allow_active_deploys,
        } => apply_update::handle(state, allow_active_deploys).await,
        Command::UpdateStatus => update_status::handle(state).await,
        Command::UpdateRollback => update_status::rollback(state).await,
        Command::IngressRoutes => ingress::routes(state).await,
        Command::IngressReconcile { service_id } => ingress::reconcile(state, service_id).await,
        Command::LogsGet { service_id, tail } => logs_get::handle(state, service_id, tail).await,
        Command::LogsHistory {
            service_id,
            before,
            limit,
            container_id,
            container_ids,
        } => {
            let mut containers = container_ids;
            containers.extend(container_id);
            logs_history::handle(state, service_id, before, limit, containers).await
        }
        Command::LogsExecutions { service_id } => logs_executions::list(state, service_id).await,
        Command::LogsExecutionDelete {
            service_id,
            container_ids,
        } => logs_executions::delete(state, service_id, container_ids).await,
        _ => RpResponse::err("NotImplemented", "command not yet implemented"),
    }
}