Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert rust example to node #494

Merged
merged 6 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ members = [
"binaries/daemon",
"binaries/runtime",
"examples/rust-dataflow/node",
"examples/rust-dataflow/operator",
"examples/rust-dataflow/status-node",
"examples/rust-dataflow/sink",
"examples/rust-ros2-dataflow/node",
"examples/benchmark/node",
Expand Down
2 changes: 1 addition & 1 deletion examples/multiple-daemons/dataflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ nodes:
operators:
- id: rust-operator
build: cargo build -p multiple-daemons-example-operator
shared-library: ../../target/debug/rust_dataflow_example_operator
shared-library: ../../target/debug/multiple_daemons_example_operator
inputs:
tick: dora/timer/millis/100
random: rust-node/random
Expand Down
13 changes: 6 additions & 7 deletions examples/rust-dataflow/dataflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ nodes:
tick: dora/timer/millis/10
outputs:
- random
- id: runtime-node
operators:
- id: rust-operator
build: cargo build -p rust-dataflow-example-operator
shared-library: ../../target/debug/rust_dataflow_example_operator
- id: rust-status-node
custom:
build: cargo build -p rust-dataflow-example-status-node
source: ../../target/debug/rust-dataflow-example-status-node
inputs:
tick: dora/timer/millis/100
random: rust-node/random
Expand All @@ -22,11 +21,11 @@ nodes:
build: cargo build -p rust-dataflow-example-sink
source: ../../target/debug/rust-dataflow-example-sink
inputs:
message: runtime-node/rust-operator/status
message: rust-status-node/status
- id: dora-record
custom:
build: cargo build -p dora-record
source: ../../target/debug/dora-record
inputs:
message: runtime-node/rust-operator/status
message: rust-status-node/status
random: rust-node/random
52 changes: 0 additions & 52 deletions examples/rust-dataflow/operator/src/lib.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
[package]
name = "rust-dataflow-example-operator"
name = "rust-dataflow-example-status-node"
version.workspace = true
edition = "2021"
license.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["cdylib"]

[dependencies]
dora-operator-api = { workspace = true }
dora-node-api = { workspace = true, features = ["tracing"] }
eyre = "0.6.8"
47 changes: 47 additions & 0 deletions examples/rust-dataflow/status-node/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
use dora_node_api::{self, dora_core::config::DataId, DoraNode, Event, IntoArrow};
use eyre::Context;

fn main() -> eyre::Result<()> {
println!("hello");

let status_output = DataId::from("status".to_owned());
let (mut node, mut events) = DoraNode::init_from_env()?;

let mut ticks = 0;
while let Some(event) = events.recv() {
match event {
Event::Input { id, metadata, data } => match id.as_ref() {
"tick" => {
ticks += 1;
}
"random" => {
let value = u64::try_from(&data).context("unexpected data type")?;

let output = format!(
"operator received random value {value:#x} after {} ticks",
ticks
);
node.send_output(
status_output.clone(),
metadata.parameters,
output.into_arrow(),
)?;
}
other => eprintln!("ignoring unexpected input {other}"),
},
Event::Stop => {}
Event::InputClosed { id } => {
println!("input `{id}` was closed");
if *id == "random" {
println!("`random` input was closed -> exiting");
break;
}
}
other => {
println!("received unknown event {other:?}");
}
}
}

Ok(())
}
1 change: 1 addition & 0 deletions libraries/extensions/ros2-bridge/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(feature = "generate-messages")]
use std::path::PathBuf;

#[cfg(not(feature = "generate-messages"))]
Expand Down
Loading