Struct Runtime

Source
pub struct Runtime { /* private fields */ }
Expand description

Represents a single data pipeline configuration Runtime to run

Implementations§

Source§

impl Runtime

Source

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();
Source

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();
Source

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());
Source

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()
Source

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()
Source

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()
Source

pub fn set_timeout(&mut self, timeout: Option<Duration>) -> Result<(), Error>

The function sets the timeout, or duration to run the pipeline

env.set_timeout(Some(Duration::from_secs(60)))
Source

pub async fn run(&self) -> Result<(), Error>

The function runs the existing data pipeline until receiving an Error::EndOfInput

env.run().await.unwrap();

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T