| @@ -118,6 +118,9 @@ jobs: | |||||
| - name: "Rust Dataflow example" | - name: "Rust Dataflow example" | ||||
| timeout-minutes: 30 | timeout-minutes: 30 | ||||
| run: cargo run --example rust-dataflow | run: cargo run --example rust-dataflow | ||||
| - name: "Rust Git Dataflow example" | |||||
| timeout-minutes: 30 | |||||
| run: cargo run --example rust-dataflow-git | |||||
| - name: "Multiple Daemons example" | - name: "Multiple Daemons example" | ||||
| timeout-minutes: 30 | timeout-minutes: 30 | ||||
| run: cargo run --example multiple-daemons | run: cargo run --example multiple-daemons | ||||
| @@ -132,6 +132,10 @@ path = "examples/vlm/run.rs" | |||||
| name = "rust-dataflow" | name = "rust-dataflow" | ||||
| path = "examples/rust-dataflow/run.rs" | path = "examples/rust-dataflow/run.rs" | ||||
| [[example]] | |||||
| name = "rust-dataflow-git" | |||||
| path = "examples/rust-dataflow-git/run.rs" | |||||
| [[example]] | [[example]] | ||||
| name = "rust-ros2-dataflow" | name = "rust-ros2-dataflow" | ||||
| path = "examples/rust-ros2-dataflow/run.rs" | path = "examples/rust-ros2-dataflow/run.rs" | ||||
| @@ -0,0 +1,7 @@ | |||||
| # Git-based Rust example | |||||
| To get started: | |||||
| ```bash | |||||
| cargo run --example rust-dataflow-git | |||||
| ``` | |||||
| @@ -0,0 +1,29 @@ | |||||
| nodes: | |||||
| - id: rust-node | |||||
| git: https://github.com/dora-rs/dora.git | |||||
| rev: e31b2a34 # pinned commit, update this when changing the message crate | |||||
| build: cargo build -p rust-dataflow-example-node | |||||
| path: target/debug/rust-dataflow-example-node | |||||
| inputs: | |||||
| tick: dora/timer/millis/10 | |||||
| outputs: | |||||
| - random | |||||
| - id: rust-status-node | |||||
| git: https://github.com/dora-rs/dora.git | |||||
| rev: e31b2a34 # pinned commit, update this when changing the message crate | |||||
| build: cargo build -p rust-dataflow-example-status-node | |||||
| path: target/debug/rust-dataflow-example-status-node | |||||
| inputs: | |||||
| tick: dora/timer/millis/100 | |||||
| random: rust-node/random | |||||
| outputs: | |||||
| - status | |||||
| - id: rust-sink | |||||
| git: https://github.com/dora-rs/dora.git | |||||
| rev: e31b2a34 # pinned commit, update this when changing the message crate | |||||
| build: cargo build -p rust-dataflow-example-sink | |||||
| path: target/debug/rust-dataflow-example-sink | |||||
| inputs: | |||||
| message: rust-status-node/status | |||||
| @@ -0,0 +1,52 @@ | |||||
| use dora_tracing::set_up_tracing; | |||||
| use eyre::{bail, Context}; | |||||
| use std::path::Path; | |||||
| #[tokio::main] | |||||
| async fn main() -> eyre::Result<()> { | |||||
| set_up_tracing("rust-dataflow-runner").wrap_err("failed to set up tracing subscriber")?; | |||||
| let root = Path::new(env!("CARGO_MANIFEST_DIR")); | |||||
| std::env::set_current_dir(root.join(file!()).parent().unwrap()) | |||||
| .wrap_err("failed to set working dir")?; | |||||
| let args: Vec<String> = std::env::args().collect(); | |||||
| let dataflow = if args.len() > 1 { | |||||
| Path::new(&args[1]) | |||||
| } else { | |||||
| Path::new("dataflow.yml") | |||||
| }; | |||||
| build_dataflow(dataflow).await?; | |||||
| run_dataflow(dataflow).await?; | |||||
| Ok(()) | |||||
| } | |||||
| async fn build_dataflow(dataflow: &Path) -> eyre::Result<()> { | |||||
| let cargo = std::env::var("CARGO").unwrap(); | |||||
| let mut cmd = tokio::process::Command::new(&cargo); | |||||
| cmd.arg("run"); | |||||
| cmd.arg("--package").arg("dora-cli"); | |||||
| cmd.arg("--").arg("build").arg(dataflow); | |||||
| if !cmd.status().await?.success() { | |||||
| bail!("failed to build dataflow"); | |||||
| }; | |||||
| Ok(()) | |||||
| } | |||||
| async fn run_dataflow(dataflow: &Path) -> eyre::Result<()> { | |||||
| let cargo = std::env::var("CARGO").unwrap(); | |||||
| let mut cmd = tokio::process::Command::new(&cargo); | |||||
| cmd.arg("run"); | |||||
| cmd.arg("--package").arg("dora-cli"); | |||||
| cmd.arg("--") | |||||
| .arg("daemon") | |||||
| .arg("--run-dataflow") | |||||
| .arg(dataflow); | |||||
| if !cmd.status().await?.success() { | |||||
| bail!("failed to run dataflow"); | |||||
| }; | |||||
| Ok(()) | |||||
| } | |||||