File size: 2,071 Bytes
b98ffbb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
use std::{collections::BTreeSet, fmt::Display, path::PathBuf, time::Duration};
use uuid::Uuid;
use crate::{
config::{NodeId, OperatorId},
descriptor::Descriptor,
};
pub const DORA_COORDINATOR_PORT_DEFAULT: u16 = 0xD02A;
pub const DORA_COORDINATOR_PORT_CONTROL_DEFAULT: u16 = 0x177C;
pub const MANUAL_STOP: &str = "dora/stop";
#[derive(Debug, serde::Deserialize, serde::Serialize)]
pub enum ControlRequest {
Start {
dataflow: Descriptor,
name: Option<String>,
// TODO: remove this once we figure out deploying of node/operator
// binaries from CLI to coordinator/daemon
local_working_dir: PathBuf,
},
Reload {
dataflow_id: Uuid,
node_id: NodeId,
operator_id: Option<OperatorId>,
},
Check {
dataflow_uuid: Uuid,
},
Stop {
dataflow_uuid: Uuid,
grace_duration: Option<Duration>,
},
StopByName {
name: String,
grace_duration: Option<Duration>,
},
Logs {
uuid: Option<Uuid>,
name: Option<String>,
node: String,
},
Destroy,
List,
DaemonConnected,
ConnectedMachines,
}
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)]
pub enum ControlRequestReply {
Error(String),
CoordinatorStopped,
DataflowStarted {
uuid: Uuid,
},
DataflowReloaded {
uuid: Uuid,
},
DataflowStopped {
uuid: Uuid,
result: Result<(), String>,
},
DataflowList {
dataflows: Vec<DataflowId>,
},
DestroyOk,
DaemonConnected(bool),
ConnectedMachines(BTreeSet<String>),
Logs(Vec<u8>),
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct DataflowId {
pub uuid: Uuid,
pub name: Option<String>,
}
impl Display for DataflowId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
if let Some(name) = &self.name {
write!(f, "[{name}] {}", self.uuid)
} else {
write!(f, "[<unnamed>] {}", self.uuid)
}
}
}
|