tests pass

master
Bel LaPointe 2023-03-17 08:03:39 -06:00
parent 70324cfd49
commit 7889816a0b
4 changed files with 36 additions and 4 deletions

View File

@ -23,6 +23,11 @@ pub struct Stream {
pub struct Engine { pub struct Engine {
pub name: String, pub name: String,
pub kafka: Option<Kafka>, pub kafka: Option<Kafka>,
pub device: Option<Device>,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct Device {
} }
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
@ -58,12 +63,14 @@ fn build_config_std() -> Config {
engine: Engine{ engine: Engine{
name: String::from("stdin"), name: String::from("stdin"),
kafka: None, kafka: None,
device: None,
}, },
}, },
output: Stream { output: Stream {
engine: Engine{ engine: Engine{
name: String::from("stdout"), name: String::from("stdout"),
kafka: None, kafka: None,
device: None,
}, },
}, },
}, },

View File

@ -8,10 +8,25 @@ pub fn build_input_engine(cfg: &Engine) -> Result<Box<dyn InputEngine>, String>
match cfg.name.as_str() { match cfg.name.as_str() {
"stdin" => return Ok(Box::new(InputEngineStdin{})), "stdin" => return Ok(Box::new(InputEngineStdin{})),
"kafka" => return build_input_engine_kafka(&cfg), "kafka" => return build_input_engine_kafka(&cfg),
"device" => return build_input_engine_device(&cfg),
_ => return Err("unknown input engine name".to_string() + &cfg.name), _ => 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 { struct InputEngineKafka {
} }
@ -50,11 +65,11 @@ mod test_input {
#[test] #[test]
fn test_input_engine_impl() { fn test_input_engine_impl() {
let input_engine_test = InputEngineTest{}; let mut input_engine_test = InputEngineTest{};
_test_input_engine_impl(&input_engine_test); _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>()); assert_eq!("hello world".to_string(), engine.get().iter().cloned().collect::<String>());
} }
} }

View File

@ -0,0 +1,8 @@
streams:
input:
engine:
name: device
device: {}
output:
engine:
name: stdout

View File

@ -14,7 +14,9 @@
"name": "kafka", "name": "kafka",
"kafka": { "kafka": {
"topic": "topic-name", "topic": "topic-name",
"consumer_group": "consumer-group-name" "consumer_group": "consumer-group-name",
"addr": "",
"crt": ""
} }
} }
} }