reactive_graph_plugin_delegates/
flow_instance_manager_impl.rs1use std::sync::Arc;
2
3use uuid::Uuid;
4
5use reactive_graph_graph::FlowInstance;
6use reactive_graph_graph::FlowTypeId;
7use reactive_graph_graph::PropertyInstances;
8use reactive_graph_reactive_model_impl::ReactiveFlow;
9use reactive_graph_reactive_service_api::ReactiveFlowCreationError;
10use reactive_graph_reactive_service_api::ReactiveFlowManager;
11
12pub struct FlowInstanceManagerDelegate {
13 reactive_flow_manager: Arc<dyn ReactiveFlowManager + Send + Sync>,
14}
15
16impl FlowInstanceManagerDelegate {
17 pub fn new(reactive_flow_manager: Arc<dyn ReactiveFlowManager + Send + Sync>) -> Self {
18 Self { reactive_flow_manager }
19 }
20}
21
22impl reactive_graph_plugin_api::FlowInstanceManager for FlowInstanceManagerDelegate {
23 fn has(&self, id: Uuid) -> bool {
24 self.reactive_flow_manager.has(id)
25 }
26
27 fn get(&self, id: Uuid) -> Option<ReactiveFlow> {
28 self.reactive_flow_manager.get(id)
29 }
30
31 fn get_by_label(&self, label: &str) -> Option<ReactiveFlow> {
32 self.reactive_flow_manager.get_by_label(label)
33 }
34
35 fn create(&self, flow_instance: FlowInstance) -> Result<ReactiveFlow, ReactiveFlowCreationError> {
36 self.reactive_flow_manager.create_reactive_flow(flow_instance)
37 }
38
39 fn create_from_type(
40 &self,
41 ty: &FlowTypeId,
42 id: Option<Uuid>,
43 variables: PropertyInstances,
44 properties: PropertyInstances,
45 ) -> Result<ReactiveFlow, ReactiveFlowCreationError> {
46 self.reactive_flow_manager.create_from_type(ty, id, variables, properties)
47 }
48
49 fn delete(&self, id: Uuid) -> bool {
50 self.reactive_flow_manager.delete(id)
51 }
52}