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
use std::sync::{Arc, Mutex};

use crate::{
    node::operator_executor::OperatorExecutor, scheduler::channel_manager::ChannelManager,
};

pub mod default_graph;
pub mod edge;
pub mod graph;
pub mod vertex;

pub use edge::{Channel, ChannelMetadata, StreamMetadata};
pub use graph::Graph;
pub use vertex::{DriverMetadata, OperatorMetadata, Vertex};

pub trait OperatorRunner:
    'static + (Fn(Arc<Mutex<ChannelManager>>) -> OperatorExecutor) + Sync + Send
{
    fn box_clone(&self) -> Box<dyn OperatorRunner>;
}

impl<T: 'static + (Fn(Arc<Mutex<ChannelManager>>) -> OperatorExecutor) + Sync + Send + Clone>
    OperatorRunner for T
{
    fn box_clone(&self) -> Box<dyn OperatorRunner> {
        Box::new(self.clone())
    }
}

pub trait StreamSetupHook: 'static + Fn(Arc<Mutex<ChannelManager>>) + Sync + Send {
    fn box_clone(&self) -> Box<dyn StreamSetupHook>;
}

impl<T: 'static + Fn(Arc<Mutex<ChannelManager>>) + Sync + Send + Clone> StreamSetupHook for T {
    fn box_clone(&self) -> Box<dyn StreamSetupHook> {
        Box::new(self.clone())
    }
}