use ek_core::service::ServiceDesc;
pub const SVC_LIST: &str = "svctl.list";
pub const SVC_START: &str = "svctl.start";
pub const SVC_REMOVE: &str = "svctl.remove";
#[derive(Debug, Clone, PartialEq)]
pub struct PlugRow {
pub name: String,
pub version: String,
pub state: String,
pub deps: Vec<String>,
pub spilled: u64,
pub panics: u64,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub struct ListReq;
pub type ListRes = Vec<PlugRow>;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct StartReq {
pub factory: String,
pub name: String,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum StartRes {
Started {
name: String,
},
Rejected {
reason: String,
},
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct RemoveReq {
pub name: String,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum RemoveRes {
Removed {
name: String,
},
NoSuchName {
name: String,
},
}
pub(crate) fn svctl_services() -> Vec<ServiceDesc> {
vec![
ServiceDesc::describe::<ListReq, ListRes>(SVC_LIST, "station: list plugin rows"),
ServiceDesc::describe::<StartReq, StartRes>(SVC_START, "station: inject plugin by factory"),
ServiceDesc::describe::<RemoveReq, RemoveRes>(SVC_REMOVE, "station: remove plugin by name"),
]
}