Struct Runtime

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

A Zenoh-Flow runtime manages a subset of the nodes of DataFlowInstance(s).

In order to start a data flow, a Zenoh-Flow runtime should first be created and then tasked with loading and starting the nodes it is responsible for.

It is important to note here that, on its own, a Zenoh-Flow runtime will not contact other runtimes to coordinate the start of a data flow. If a data flow spawns on multiple runtimes, one needs to start each separately. Otherwise, the Zenoh-Flow daemon structure has been especially designed to address this use-case.

Implementations§

Source§

impl Runtime

Source

pub async fn try_load_data_flow(&self, data_flow: DataFlowRecord) -> Result<()>

Attempts to load the provided DataFlowRecord, creating a new DataFlowInstance in this Runtime.

Upon creation the DataFlowInstance will be put in the Creating state. Once all the nodes managed by this Runtime have been successfully loaded, the instance will be put in the Loaded state.

§Errors

This method can fail for the following reasons:

  • the data flow was not valid; more specifically, at least one link was connecting two nodes that are running on different runtimes (the current one and another),
  • the runtime failed to load: an operator, a source, a sink,
  • the runtime encountered an internal error:
    • a channel was not created for a node,
    • a Zenoh built-in source failed to declare its subscriber.
Source§

impl Runtime

Source

pub fn builder(name: impl Into<String>) -> RuntimeBuilder

Create a new builder in order to construct a Runtime.

§Example
use zenoh_flow_runtime::Runtime;
let runtime = Runtime::builder("demo")
    .build()
    .await
    .expect("Failed to build the Runtime");
Source

pub fn id(&self) -> &RuntimeId

Returns the unique identifier of this Zenoh-Flow runtime.

Source

pub fn name(&self) -> Arc<str>

Returns the name of this Zenoh-Flow runtime.

The name of a Zenoh-Flow runtime does NOT have to be unique, it is only used as a human-readable description.

Source

pub fn hlc(&self) -> Arc<HLC>

Returns a shared pointer over the HLC used by this Runtime.

Source

pub async fn instances_state( &self, ) -> HashMap<InstanceId, (Arc<str>, InstanceState)>

Returns the InstanceState of the DataFlowInstance(s) managed by this Zenoh-Flow runtime.

Source

pub fn session(&self) -> Arc<Session>

Returns a shared pointer over the Zenoh session used by this Runtime.

Source

pub async fn try_get_record( &self, id: &InstanceId, ) -> Result<DataFlowRecord, DataFlowErr>

Returns the DataFlowRecord associated with the provided instance.

§Errors

This method will return an error if:

  • this runtime does not manage a data flow with the provided id,
  • the data flow is in an failed state.
Source

pub async fn get_instance_status( &self, id: &InstanceId, ) -> Option<InstanceStatus>

Returns the status of the provided data flow instance or None if this runtime does not manage this instance.

Source

pub async fn try_start_instance(&self, id: &InstanceId) -> Result<()>

Attempts to (re-)start the DataFlowInstance identified by the provided id.

Note that this method is idempotent: calling it on an already running data flow will do nothing.

§Errors

This method can fail for the following reason:

  • no data flow with the provided id was found,
  • the data flow is in a failed state,
  • the data flow is restarted and the on_resume method of one of the nodes (managed by the runtime) failed.
Source

pub async fn try_abort_instance(&self, id: &InstanceId) -> Result<()>

Attempts to abort the DataFlowInstance identified by the provided id.

Note that this method is idempotent: calling it on an already aborted data flow will do nothing.

§Errors

This method can fail for the following reasons:

  • no data flow with the provided id was found,
  • the data flow is in a failed state.
Source

pub async fn try_delete_instance(&self, id: &InstanceId) -> Result<()>

Attempts to delete the DataFlowInstance identified by the provided id.

§Errors

This method can fail for the following reasons:

  • no data flow with the provided id was found,
  • another action is currently being performed on the data flow.

Trait Implementations§

Source§

impl Debug for Runtime

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Runtime

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> AsNode<T> for T

Source§

fn as_node(&self) -> &T

Source§

impl<T> AsNodeMut<T> for T

Source§

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

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SendSyncAny for T
where T: 'static + Send + Sync,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

fn as_mut_any(&mut self) -> &mut (dyn Any + 'static)

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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,