pub struct Runtime { /* private fields */ }Expand description
Represents a single data pipeline configuration Runtime to run
Implementations§
Source§impl Runtime
impl Runtime
Sourcepub async fn from_config(config: &str) -> Result<Self, Error>
pub async fn from_config(config: &str) -> Result<Self, Error>
The function takes the raw configuration of the data pipeline and registers built-in plugins, validates the configuration and returns the Runtime to run.
use fiddler::Runtime;
let conf_str = r#"input:
stdin: {}
processors:
- label: my_cool_mapping
noop: {}
output:
stdout: {}"#;
let env = Runtime::from_config(conf_str).await.unwrap();Sourcepub fn set_label(&mut self, label: Option<String>) -> Result<(), Error>
pub fn set_label(&mut self, label: Option<String>) -> Result<(), Error>
The function sets the data pipeline with a label.
env.set_label(Some("MyPipeline".into())).unwrap();or to remove a given label:
env.set_label(None).unwrap();Sourcepub fn get_label(&self) -> Option<String>
pub fn get_label(&self) -> Option<String>
The function returns the currect label assigned to the pipeline
assert_eq!(env.get_label().unwrap(), "MyPipeline".to_string());Sourcepub async fn set_input(
&mut self,
input: &HashMap<String, Value>,
) -> Result<(), Error>
pub async fn set_input( &mut self, input: &HashMap<String, Value>, ) -> Result<(), Error>
The function replaces the existing input configuration with the provided input.
use serde_yaml::Value;
let conf_str = r#"file:
filename: tests/data/input.txt
codec: ToEnd"#;
let parsed_input: HashMap<String, Value> = serde_yaml::from_str(conf_str).unwrap();
env.set_input(&parsed_input).await.unwrap()Sourcepub async fn set_output(
&mut self,
output: &HashMap<String, Value>,
) -> Result<(), Error>
pub async fn set_output( &mut self, output: &HashMap<String, Value>, ) -> Result<(), Error>
The function replaces the existing output configuration with the provided output.
use serde_yaml::Value;
let conf_str = r#"stdout: {}"#;
let parsed_output: HashMap<String, Value> = serde_yaml::from_str(conf_str).unwrap();
env.set_output(&parsed_output).await.unwrap()Sourcepub fn set_threads(&mut self, count: usize) -> Result<(), Error>
pub fn set_threads(&mut self, count: usize) -> Result<(), Error>
The function sets the number of instances of processors and outputs to create.
env.set_threads(1).unwrap()Auto Trait Implementations§
impl Freeze for Runtime
impl RefUnwindSafe for Runtime
impl Send for Runtime
impl Sync for Runtime
impl Unpin for Runtime
impl UnwindSafe for Runtime
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more