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 UnsafeUnpin 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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more