diff --git a/apis/rust/node/src/event_stream/mod.rs b/apis/rust/node/src/event_stream/mod.rs index c47a5674..5ac4b567 100644 --- a/apis/rust/node/src/event_stream/mod.rs +++ b/apis/rust/node/src/event_stream/mod.rs @@ -85,6 +85,7 @@ impl EventStream { }) } + /// wait for the next event on the events stream. pub fn recv(&mut self) -> Option { let event = self.receiver.recv(); self.recv_common(event) diff --git a/apis/rust/node/src/lib.rs b/apis/rust/node/src/lib.rs index 886fdc4a..a07be734 100644 --- a/apis/rust/node/src/lib.rs +++ b/apis/rust/node/src/lib.rs @@ -1,3 +1,18 @@ +//! 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. +//! +//! Try it out with: +//! +//! ```bash +//! dora new node --kind node +//! ``` +//! +//! You can also generate a dora rust project with +//! +//! ```bash +//! dora new project_xyz --kind dataflow +//! ``` +//! pub use dora_core; pub use dora_core::message::{uhlc, Metadata, MetadataParameters}; pub use event_stream::{Data, Event, EventStream, MappedInputData}; diff --git a/apis/rust/node/src/node/mod.rs b/apis/rust/node/src/node/mod.rs index a301842e..1c7c44fb 100644 --- a/apis/rust/node/src/node/mod.rs +++ b/apis/rust/node/src/node/mod.rs @@ -34,6 +34,12 @@ pub struct DoraNode { } impl DoraNode { + /// Initiate a node from environment variables set by `dora-coordinator` + /// + /// ```rust + /// let (mut node, mut events) = DoraNode::init_from_env()?; + /// ``` + /// pub fn init_from_env() -> eyre::Result<(Self, EventStream)> { let node_config: NodeConfig = { let raw = std::env::var("DORA_NODE_CONFIG") @@ -74,6 +80,19 @@ impl DoraNode { Ok((node, event_stream)) } + /// Send data from the node to the other nodes. + /// We take a closure as an input to enable zero copy on send. + /// + /// ```rust + /// node.send_output( + /// &data_id, + /// metadata.parameters, + /// data.len(), + /// |out| { + /// out.copy_from_slice(data); + /// })?; + /// ``` + /// pub fn send_output( &mut self, output_id: DataId, diff --git a/apis/rust/operator/src/lib.rs b/apis/rust/operator/src/lib.rs index 9db91b97..8b1b8387 100644 --- a/apis/rust/operator/src/lib.rs +++ b/apis/rust/operator/src/lib.rs @@ -1,3 +1,20 @@ +//! The operator API is a framework to implement dora operators. +//! 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. +//! +//! Try it out with: +//! +//! ```bash +//! dora new op --kind operator +//! ``` +//! + #![warn(unsafe_op_in_unsafe_fn)] #![allow(clippy::missing_safety_doc)]