Browse Source

Replacing `-` with `_` in operator name template

The problem is that `op-1` get compiled into `libop_1.so` instead of `libop-1.so`.

The dataflow shared-library name would needs to be adapted afterward.
tags/v0.0.0-test-pr-131
haixuanTao 3 years ago
parent
commit
2fc3fc70de
6 changed files with 38 additions and 29 deletions
  1. +9
    -9
      binaries/cli/src/template/c/dataflow-template.yml
  2. +6
    -3
      binaries/cli/src/template/c/mod.rs
  3. +1
    -1
      binaries/cli/src/template/rust/Cargo-template.toml
  4. +12
    -12
      binaries/cli/src/template/rust/dataflow-template.yml
  5. +9
    -3
      binaries/cli/src/template/rust/mod.rs
  6. +1
    -1
      binaries/cli/src/template/rust/operator/lib-template.rs

+ 9
- 9
binaries/cli/src/template/c/dataflow-template.yml View File

@@ -3,25 +3,25 @@ communication:
prefix: /___name___

nodes:
- id: runtime-node-1
- id: runtime-node_1
operators:
- id: op-1
shared-library: build/op-1
- id: op_1
shared-library: build/op_1
inputs:
tick: dora/timer/millis/100
outputs:
- some-output
- id: op-2
shared-library: build/op-2
- id: op_2
shared-library: build/op_2
inputs:
tick: dora/timer/secs/2
outputs:
- some-output

- id: custom-node-1
- id: custom-node_1
custom:
source: build/node-1
source: build/node_1
inputs:
tick: dora/timer/secs/1
input-1: op-1/some-output
input-2: op-2/some-output
input-1: op_1/some-output
input-2: op_2/some-output

+ 6
- 3
binaries/cli/src/template/c/mod.rs View File

@@ -39,9 +39,9 @@ fn create_dataflow(name: String, path: Option<PathBuf>) -> Result<(), eyre::ErrR
fs::write(&dataflow_yml_path, &dataflow_yml)
.with_context(|| format!("failed to write `{}`", dataflow_yml_path.display()))?;

create_operator("op-1".into(), Some(root.join("op-1")))?;
create_operator("op-2".into(), Some(root.join("op-2")))?;
create_custom_node("node-1".into(), Some(root.join("node-1")))?;
create_operator("op_1".into(), Some(root.join("op_1")))?;
create_operator("op_2".into(), Some(root.join("op_2")))?;
create_custom_node("node_1".into(), Some(root.join("node_1")))?;

println!(
"Created new C dataflow at `{name}` at {}",
@@ -58,6 +58,9 @@ fn create_operator(name: String, path: Option<PathBuf>) -> Result<(), eyre::ErrR
if name.contains('/') {
bail!("operator name must not contain `/` separators");
}
if name.contains('-') {
bail!("operator name must not contain `-` separators");
}
if !name.is_ascii() {
bail!("operator name must be ASCII");
}


+ 1
- 1
binaries/cli/src/template/rust/Cargo-template.toml View File

@@ -1,2 +1,2 @@
[workspace]
members = ["op-1", "op-2", "node-1"]
members = ["op_1", "op_2", "node_1"]

+ 12
- 12
binaries/cli/src/template/rust/dataflow-template.yml View File

@@ -3,28 +3,28 @@ communication:
prefix: /___name___

nodes:
- id: runtime-node-1
- id: runtime-node_1
operators:
- id: op-1
build: cargo build -p op-1
shared-library: target/debug/op-1
- id: op_1
build: cargo build -p op_1
shared-library: target/debug/op_1
inputs:
tick: dora/timer/millis/100
outputs:
- some-output
- id: op-2
build: cargo build -p op-2
shared-library: target/debug/op-2
- id: op_2
build: cargo build -p op_2
shared-library: target/debug/op_2
inputs:
tick: dora/timer/secs/2
outputs:
- some-output

- id: custom-node-1
- id: custom-node_1
custom:
build: cargo build -p node-1
source: target/debug/node-1
build: cargo build -p node_1
source: target/debug/node_1
inputs:
tick: dora/timer/secs/1
input-1: op-1/some-output
input-2: op-2/some-output
input-1: op_1/some-output
input-2: op_2/some-output

+ 9
- 3
binaries/cli/src/template/rust/mod.rs View File

@@ -44,9 +44,9 @@ fn create_dataflow(name: String, path: Option<PathBuf>) -> Result<(), eyre::ErrR
fs::write(&cargo_toml_path, &cargo_toml)
.with_context(|| format!("failed to write `{}`", cargo_toml_path.display()))?;

create_operator("op-1".into(), Some(root.join("op-1")))?;
create_operator("op-2".into(), Some(root.join("op-2")))?;
create_custom_node("node-1".into(), Some(root.join("node-1")))?;
create_operator("op_1".into(), Some(root.join("op_1")))?;
create_operator("op_2".into(), Some(root.join("op_2")))?;
create_custom_node("node_1".into(), Some(root.join("node_1")))?;

println!(
"Created new Rust dataflow at `{name}` at {}",
@@ -63,6 +63,12 @@ fn create_operator(name: String, path: Option<PathBuf>) -> Result<(), eyre::ErrR
if name.contains('/') {
bail!("operator name must not contain `/` separators");
}
if name.contains('-') {
bail!(
"operator name must not contain `-` separators as
it get replaced by `_` as a static library."
);
}
if !name.is_ascii() {
bail!("operator name must be ASCII");
}


+ 1
- 1
binaries/cli/src/template/rust/operator/lib-template.rs View File

@@ -15,7 +15,7 @@ impl DoraOperator for ExampleOperator {
output_sender: &mut DoraOutputSender,
) -> Result<DoraStatus, String> {
match id {
other => eprintln!("ignoring unexpected input {other}"),
other => eprintln!("Received input {other}"),
}
Ok(DoraStatus::Continue)
}


Loading…
Cancel
Save