#[derive(Debug, Clone)]
pub struct ServiceModel {
pub package: String,
pub service: String,
pub source_file: String,
pub default_task_queue: String,
pub workflows: Vec<WorkflowModel>,
pub signals: Vec<SignalModel>,
pub queries: Vec<QueryModel>,
pub updates: Vec<UpdateModel>,
pub activities: Vec<ActivityModel>,
}
impl ServiceModel {
pub fn resolved_task_queue<'a>(&'a self, wf: &'a WorkflowModel) -> &'a str {
if !wf.task_queue.is_empty() {
&wf.task_queue
} else {
&self.default_task_queue
}
}
}
#[derive(Debug, Clone)]
pub struct WorkflowModel {
pub rpc_method: String,
pub input_type: ProtoType,
pub output_type: ProtoType,
pub task_queue: String,
pub registered_name: Option<String>,
pub aliases: Vec<String>,
pub attached_signals: Vec<SignalRef>,
pub attached_queries: Vec<QueryRef>,
pub attached_updates: Vec<UpdateRef>,
}
#[derive(Debug, Clone)]
pub struct SignalRef {
pub method: String,
pub signal_with_start: bool,
}
#[derive(Debug, Clone)]
pub struct QueryRef {
pub method: String,
}
#[derive(Debug, Clone)]
pub struct UpdateRef {
pub method: String,
pub update_with_start: bool,
pub update_with_validation: Option<bool>,
}
#[derive(Debug, Clone)]
pub struct SignalModel {
pub rpc_method: String,
pub input_type: ProtoType,
pub output_type: ProtoType,
pub registered_name: String,
}
#[derive(Debug, Clone)]
pub struct QueryModel {
pub rpc_method: String,
pub input_type: ProtoType,
pub output_type: ProtoType,
pub registered_name: String,
}
#[derive(Debug, Clone)]
pub struct UpdateModel {
pub rpc_method: String,
pub input_type: ProtoType,
pub output_type: ProtoType,
pub registered_name: String,
}
#[derive(Debug, Clone)]
pub struct ActivityModel {
pub rpc_method: String,
pub registered_name: String,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ProtoType {
pub full_name: String,
pub is_empty: bool,
}
impl ProtoType {
pub fn from_full_name(name: &str) -> Self {
let full = name.strip_prefix('.').unwrap_or(name).to_string();
let is_empty = full == "google.protobuf.Empty";
Self {
full_name: full,
is_empty,
}
}
}