diff --git a/Cargo.toml b/Cargo.toml index 5b82864..e47ff8d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kafka-settings" -version = "0.3.2" +version = "0.3.3" authors = ["Sebastian Rollen "] edition = "2018" diff --git a/src/settings.rs b/src/settings.rs index f1a9da1..625e11c 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -14,7 +14,7 @@ pub enum SecurityProtocol { #[derive(Debug, Clone, Deserialize)] pub struct ConsumerSettings { pub group_id: String, - #[serde(default)] + #[serde(default, deserialize_with = "from_str")] pub unique_id: bool, #[serde(deserialize_with = "vec_from_str")] pub input_topics: Vec, @@ -136,12 +136,13 @@ mod test { std::env::set_var("KAFKA__SECURITY_PROTOCOL", "PLAINTEXT"); std::env::set_var("KAFKA__GROUP_ID", "group"); std::env::set_var("KAFKA__INPUT_TOPICS", "A,B,C"); + std::env::set_var("KAFKA__UNIQUE_ID", "true"); let mut s = Config::new(); s.merge(Environment::new().separator("__")).unwrap(); let settings: Test = s.try_into().unwrap(); let consumer_settings = settings.kafka.consumer.unwrap(); assert_eq!(consumer_settings.group_id, "group".to_string()); - assert!(!consumer_settings.unique_id); + assert!(consumer_settings.unique_id); assert_eq!( consumer_settings.input_topics, vec!["A".to_string(), "B".to_string(), "C".to_string()]