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
impl Runtime
Sourcepub async fn try_load_data_flow(&self, data_flow: DataFlowRecord) -> Result<()>
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
impl Runtime
Sourcepub fn builder(name: impl Into<String>) -> RuntimeBuilder
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");
Sourcepub fn name(&self) -> Arc<str>
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.
Sourcepub async fn instances_state(
&self,
) -> HashMap<InstanceId, (Arc<str>, InstanceState)>
pub async fn instances_state( &self, ) -> HashMap<InstanceId, (Arc<str>, InstanceState)>
Returns the InstanceState of the DataFlowInstance(s) managed by this Zenoh-Flow runtime.
Sourcepub fn session(&self) -> Arc<Session>
pub fn session(&self) -> Arc<Session>
Returns a shared pointer over the Zenoh session used by this Runtime.
Sourcepub async fn try_get_record(
&self,
id: &InstanceId,
) -> Result<DataFlowRecord, DataFlowErr>
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.
Sourcepub async fn get_instance_status(
&self,
id: &InstanceId,
) -> Option<InstanceStatus>
pub async fn get_instance_status( &self, id: &InstanceId, ) -> Option<InstanceStatus>
Sourcepub async fn try_start_instance(&self, id: &InstanceId) -> Result<()>
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.
Sourcepub async fn try_abort_instance(&self, id: &InstanceId) -> Result<()>
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.
Sourcepub async fn try_delete_instance(&self, id: &InstanceId) -> Result<()>
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.