The operator API is a framework for you to implement. The implemented operator will be managed by dora. This framework enable us to make optimisation and provide advanced features. It is the recommended way of using dora.
An operator requires to be registered and implement the DoraOperator trait. It is composed of an on_event method that defines the behaviour of the operator when there is an event such as receiving an input for example.
{{#include ../../examples/rust-dataflow/operator/src/lib.rs:0:17}}
cargo new rust-dataflow-example-operator --lib
Cargo.toml
{{#include ../../examples/rust-dataflow/operator/Cargo.toml}}
src/lib.rs
{{#include ../../examples/rust-dataflow/operator/src/lib.rs}}
cargo build --release
{{#include ../../examples/rust-dataflow/dataflow.yml:13:21}}
This example can be found in examples.
The custom node API allow you to integrate dora into your application. It allows you to retrieve input and send output in any fashion you want.
DoraNode::init_from_env()DoraNode::init_from_env() initiate a node from environment variables set by dora-coordinator
let (mut node, mut events) = DoraNode::init_from_env()?;
.recv().recv() wait for the next event on the events stream.
let event = events.recv();
.send_output(...)send_output send data from the node to the other nodes.
We take a closure as an input to enable zero copy on send.
node.send_output(
&data_id,
metadata.parameters,
data.len(),
|out| {
out.copy_from_slice(data);
})?;
cargo new rust-dataflow-example-node
{{#include ../../examples/rust-dataflow/node/Cargo.toml}}
src/main.rs
{{#include ../../examples/rust-dataflow/node/src/main.rs}}
{{#include ../../examples/rust-dataflow/dataflow.yml:6:12}}