tests pass
parent
70324cfd49
commit
7889816a0b
|
|
@ -23,6 +23,11 @@ pub struct Stream {
|
|||
pub struct Engine {
|
||||
pub name: String,
|
||||
pub kafka: Option<Kafka>,
|
||||
pub device: Option<Device>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct Device {
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
|
|
@ -58,12 +63,14 @@ fn build_config_std() -> Config {
|
|||
engine: Engine{
|
||||
name: String::from("stdin"),
|
||||
kafka: None,
|
||||
device: None,
|
||||
},
|
||||
},
|
||||
output: Stream {
|
||||
engine: Engine{
|
||||
name: String::from("stdout"),
|
||||
kafka: None,
|
||||
device: None,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -8,10 +8,25 @@ pub fn build_input_engine(cfg: &Engine) -> Result<Box<dyn InputEngine>, String>
|
|||
match cfg.name.as_str() {
|
||||
"stdin" => return Ok(Box::new(InputEngineStdin{})),
|
||||
"kafka" => return build_input_engine_kafka(&cfg),
|
||||
"device" => return build_input_engine_device(&cfg),
|
||||
_ => return Err("unknown input engine name".to_string() + &cfg.name),
|
||||
}
|
||||
}
|
||||
|
||||
struct InputEngineDevice {
|
||||
}
|
||||
|
||||
pub fn build_input_engine_device(cfg: &Engine) -> Result<Box<dyn InputEngine>, String> {
|
||||
let device_cfg = cfg.device.as_ref().unwrap();
|
||||
return Err("do what".to_string());
|
||||
}
|
||||
|
||||
impl InputEngine for InputEngineDevice {
|
||||
fn get(&mut self) -> Vec<char> {
|
||||
Err("end".to_string()).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
struct InputEngineKafka {
|
||||
}
|
||||
|
||||
|
|
@ -50,11 +65,11 @@ mod test_input {
|
|||
|
||||
#[test]
|
||||
fn test_input_engine_impl() {
|
||||
let input_engine_test = InputEngineTest{};
|
||||
_test_input_engine_impl(&input_engine_test);
|
||||
let mut input_engine_test = InputEngineTest{};
|
||||
_test_input_engine_impl(&mut input_engine_test);
|
||||
}
|
||||
|
||||
fn _test_input_engine_impl(engine: &dyn InputEngine) {
|
||||
fn _test_input_engine_impl(engine: &mut dyn InputEngine) {
|
||||
assert_eq!("hello world".to_string(), engine.get().iter().cloned().collect::<String>());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
streams:
|
||||
input:
|
||||
engine:
|
||||
name: device
|
||||
device: {}
|
||||
output:
|
||||
engine:
|
||||
name: stdout
|
||||
|
|
@ -14,7 +14,9 @@
|
|||
"name": "kafka",
|
||||
"kafka": {
|
||||
"topic": "topic-name",
|
||||
"consumer_group": "consumer-group-name"
|
||||
"consumer_group": "consumer-group-name",
|
||||
"addr": "",
|
||||
"crt": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue