-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #494 from Michael-J-Ward/convert-rust-example-to-node
Convert rust example to node
- Loading branch information
Showing
8 changed files
with
63 additions
and
68 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
7 changes: 3 additions & 4 deletions
7
examples/rust-dataflow/operator/Cargo.toml → ...ples/rust-dataflow/status-node/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"))] | ||
|