Scalable and distributed custom feed generator, ott - on that topic

Filter posts to only create records

Changed files
+9 -7
smart-modules
contruct-post-uri
src
+9 -7
smart-modules/contruct-post-uri/src/lib.rs
··· 1 use eyre::eyre; 2 use fluvio_smartmodule::{RecordData, Result, SmartModuleRecord, smartmodule}; 3 use serde_json::{Map, Value}; 4 - use std::str::FromStr; 5 6 - #[smartmodule(map)] 7 - pub fn map(record: &SmartModuleRecord) -> Result<(Option<RecordData>, RecordData)> { 8 let key = record.key.clone(); 9 10 let string = std::str::from_utf8(record.value.as_ref())?; ··· 13 .as_object_mut() 14 .ok_or(eyre!("Failed to parse value"))?; 15 16 - let uri = get_uri(obj)?; 17 - let uri_value = Value::String(uri); 18 - obj.insert("uri".to_string(), uri_value); 19 20 - Ok((key, value.to_string().as_str().into())) 21 } 22 23 fn get_uri(obj: &Map<String, Value>) -> Result<String> {
··· 1 use eyre::eyre; 2 use fluvio_smartmodule::{RecordData, Result, SmartModuleRecord, smartmodule}; 3 use serde_json::{Map, Value}; 4 5 + #[smartmodule(filter_map)] 6 + pub fn filter_map(record: &SmartModuleRecord) -> Result<Option<(Option<RecordData>, RecordData)>> { 7 let key = record.key.clone(); 8 9 let string = std::str::from_utf8(record.value.as_ref())?; ··· 12 .as_object_mut() 13 .ok_or(eyre!("Failed to parse value"))?; 14 15 + if let Ok(uri) = get_uri(obj) { 16 + let uri_value = Value::String(uri); 17 + obj.insert("uri".to_string(), uri_value); 18 19 + Ok(Some((key, value.to_string().as_str().into()))) 20 + } else { 21 + Ok(None) 22 + } 23 } 24 25 fn get_uri(obj: &Map<String, Value>) -> Result<String> {