Browse Source

Merge pull request #203 from dora-rs/fix-zenoh

Update zenoh to remove git dependencies
tags/v0.2.0-rc
Haixuan Xavier Tao GitHub 2 years ago
parent
commit
4a026e0e11
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 439 additions and 500 deletions
  1. +394
    -461
      Cargo.lock
  2. +1
    -1
      README.md
  3. +1
    -1
      binaries/cli/src/template/c/dataflow-template.yml
  4. +1
    -1
      binaries/cli/src/template/cxx/dataflow-template.yml
  5. +1
    -1
      binaries/cli/src/template/python/dataflow-template.yml
  6. +1
    -1
      binaries/cli/src/template/rust/dataflow-template.yml
  7. +1
    -1
      binaries/coordinator/Cargo.toml
  8. +1
    -1
      docs/src/dataflow-config.md
  9. +1
    -1
      examples/benchmark/dataflow.yml
  10. +1
    -1
      examples/c++-dataflow/dataflow.yml
  11. +1
    -1
      examples/c-dataflow/dataflow.yml
  12. +1
    -1
      examples/python-dataflow/dataflow.yml
  13. +1
    -1
      examples/python-dataflow/dataflow_without_webcam.yml
  14. +1
    -1
      examples/python-operator-dataflow/dataflow.yml
  15. +1
    -1
      examples/python-operator-dataflow/dataflow_without_webcam.yml
  16. +1
    -1
      examples/rust-dataflow-url/dataflow.yml
  17. +1
    -1
      examples/rust-dataflow/dataflow.yml
  18. +3
    -3
      libraries/communication-layer/pub-sub/Cargo.toml
  19. +15
    -12
      libraries/communication-layer/pub-sub/src/zenoh.rs
  20. +1
    -1
      libraries/core/Cargo.toml
  21. +1
    -1
      libraries/core/src/config.rs
  22. +1
    -2
      libraries/extensions/zenoh-logger/Cargo.toml
  23. +8
    -4
      libraries/extensions/zenoh-logger/src/main.rs

+ 394
- 461
Cargo.lock
File diff suppressed because it is too large
View File


+ 1
- 1
README.md View File

@@ -96,7 +96,7 @@ You need to add the created operators/nodes to your dataflow YAML file.
```yaml
communication:
zenoh:
prefix: /abc_project
prefix: abc_project

nodes:
- id: op_1


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

@@ -1,6 +1,6 @@
communication:
zenoh:
prefix: /___name___
prefix: ___name___

nodes:
- id: runtime-node_1


+ 1
- 1
binaries/cli/src/template/cxx/dataflow-template.yml View File

@@ -1,6 +1,6 @@
communication:
zenoh:
prefix: /___name___
prefix: ___name___

nodes:
- id: runtime-node_1


+ 1
- 1
binaries/cli/src/template/python/dataflow-template.yml View File

@@ -1,6 +1,6 @@
communication:
zenoh:
prefix: /___name___
prefix: ___name___

nodes:
- id: op_1


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

@@ -1,6 +1,6 @@
communication:
zenoh:
prefix: /___name___
prefix: ___name___

nodes:
- id: runtime-node_1


+ 1
- 1
binaries/coordinator/Cargo.toml View File

@@ -27,7 +27,7 @@ rand = "0.8.5"
dora-core = { workspace = true }
tracing = "0.1.36"
futures-concurrency = "7.1.0"
zenoh = { git = "https://github.com/eclipse-zenoh/zenoh.git", rev = "79a136e4fd90b11ff5d775ced981af53c4f1071b" }
zenoh = "0.7.0-rc"
serde_json = "1.0.86"
dora-download = { path = "../../libraries/extensions/download" }
dora-tracing = { workspace = true, optional = true }


+ 1
- 1
docs/src/dataflow-config.md View File

@@ -112,7 +112,7 @@ The mandatory `communication` key specifies how dora nodes and operators should
```yaml
communication:
zenoh:
prefix: /some-unique-prefix
prefix: some-unique-prefix
```

The specified `prefix` is added to all pub/sub topics. It is useful for filtering messages (e.g. in a logger) when other applications use `zenoh` in parallel. Dora will extend the given prefix with a newly generated UUID on each run, to ensure that multiple instances of the same dataflow run concurrently without interfering with each other.


+ 1
- 1
examples/benchmark/dataflow.yml View File

@@ -1,6 +1,6 @@
communication:
zenoh:
prefix: /benchmark-example
prefix: benchmark-example

nodes:
- id: rust-node


+ 1
- 1
examples/c++-dataflow/dataflow.yml View File

@@ -1,6 +1,6 @@
communication:
zenoh:
prefix: /example-cxx-dataflow
prefix: example-cxx-dataflow

nodes:
- id: cxx-node-rust-api


+ 1
- 1
examples/c-dataflow/dataflow.yml View File

@@ -1,6 +1,6 @@
communication:
zenoh:
prefix: /example-c-dataflow
prefix: example-c-dataflow

nodes:
- id: c_node


+ 1
- 1
examples/python-dataflow/dataflow.yml View File

@@ -1,6 +1,6 @@
communication:
zenoh:
prefix: /example-python-dataflow
prefix: example-python-dataflow

nodes:
- id: webcam


+ 1
- 1
examples/python-dataflow/dataflow_without_webcam.yml View File

@@ -1,6 +1,6 @@
communication:
zenoh:
prefix: /example-python-no-webcam-dataflow
prefix: example-python-no-webcam-dataflow

nodes:
- id: no_webcam


+ 1
- 1
examples/python-operator-dataflow/dataflow.yml View File

@@ -1,6 +1,6 @@
communication:
zenoh:
prefix: /example-python-dataflow
prefix: example-python-dataflow

nodes:
- id: webcam


+ 1
- 1
examples/python-operator-dataflow/dataflow_without_webcam.yml View File

@@ -1,6 +1,6 @@
communication:
zenoh:
prefix: /example-python-no-webcam-dataflow
prefix: example-python-no-webcam-dataflow

nodes:
- id: no_webcam


+ 1
- 1
examples/rust-dataflow-url/dataflow.yml View File

@@ -1,6 +1,6 @@
communication:
zenoh:
prefix: /example-rust-dataflow
prefix: example-rust-dataflow

nodes:
- id: rust-node


+ 1
- 1
examples/rust-dataflow/dataflow.yml View File

@@ -1,6 +1,6 @@
communication:
zenoh:
prefix: /example-rust-dataflow
prefix: example-rust-dataflow

daemon_config: Tcp # or Shmem



+ 3
- 3
libraries/communication-layer/pub-sub/Cargo.toml View File

@@ -5,12 +5,12 @@ edition = "2021"

[features]
default = ["zenoh"]
zenoh = ["dep:zenoh", "dep:zenoh-config"]
zenoh = ["dep:zenoh"]

[dependencies]
zenoh = { version = "0.7.0-rc", optional = true, features = ["transport_tcp"] }
eyre = "0.6.8"
zenoh = { git = "https://github.com/eclipse-zenoh/zenoh.git", rev = "79a136e4fd90b11ff5d775ced981af53c4f1071b", optional = true }
zenoh-config = { git = "https://github.com/eclipse-zenoh/zenoh.git", rev = "79a136e4fd90b11ff5d775ced981af53c4f1071b", optional = true }
flume = "0.10"

[package.metadata.docs.rs]
all-features = true


+ 15
- 12
libraries/communication-layer/pub-sub/src/zenoh.rs View File

@@ -1,12 +1,10 @@
//! Provides [`ZenohCommunicationLayer`] to communicate over `zenoh`.

pub use zenoh_config;

use super::{CommunicationLayer, Publisher, Subscriber};
use crate::{BoxError, ReceivedSample};
use std::{borrow::Cow, sync::Arc, time::Duration};
use zenoh::{
prelude::{EntityFactory, Priority, Receiver as _, SplitBuffer, ZFuture},
prelude::{sync::SyncResolve, Config, Priority, SessionDeclarations, SplitBuffer},
publication::CongestionControl,
};

@@ -22,9 +20,9 @@ impl ZenohCommunicationLayer {
/// The `prefix` is added to all topic names when using the [`publisher`][Self::publisher]
/// and [`subscriber`][Self::subscribe] methods. Pass an empty string if no prefix is
/// desired.
pub fn init(config: zenoh_config::Config, prefix: String) -> Result<Self, BoxError> {
pub fn init(config: Config, prefix: String) -> Result<Self, BoxError> {
let zenoh = ::zenoh::open(config)
.wait()
.res_sync()
.map_err(BoxError::from)?
.into_arc();
Ok(Self {
@@ -42,10 +40,10 @@ impl CommunicationLayer for ZenohCommunicationLayer {
fn publisher(&mut self, topic: &str) -> Result<Box<dyn Publisher>, BoxError> {
let publisher = self
.zenoh
.publish(self.prefixed(topic))
.declare_publisher(self.prefixed(topic))
.congestion_control(CongestionControl::Block)
.priority(Priority::RealTime)
.wait()
.res_sync()
.map_err(BoxError::from)?;

Ok(Box::new(ZenohPublisher { publisher }))
@@ -54,9 +52,9 @@ impl CommunicationLayer for ZenohCommunicationLayer {
fn subscribe(&mut self, topic: &str) -> Result<Box<dyn Subscriber>, BoxError> {
let subscriber = self
.zenoh
.subscribe(self.prefixed(topic))
.declare_subscriber(self.prefixed(topic))
.reliable()
.wait()
.res_sync()
.map_err(BoxError::from)?;

Ok(Box::new(ZenohReceiver(subscriber)))
@@ -104,11 +102,16 @@ impl<'a> crate::PublishSample<'a> for ZenohPublishSample {
}

fn publish(self: Box<Self>) -> Result<(), BoxError> {
self.publisher.send(self.sample).map_err(BoxError::from)
self.publisher
.put(self.sample)
.res_sync()
.map_err(BoxError::from)
}
}

struct ZenohReceiver(zenoh::subscriber::Subscriber<'static>);
struct ZenohReceiver(
zenoh::subscriber::Subscriber<'static, flume::Receiver<zenoh::sample::Sample>>,
);

impl Subscriber for ZenohReceiver {
fn recv(&mut self) -> Result<Option<Box<dyn ReceivedSample>>, BoxError> {
@@ -122,7 +125,7 @@ impl Subscriber for ZenohReceiver {
}

struct ZenohReceivedSample {
sample: zenoh::buf::ZBuf,
sample: zenoh::buffers::ZBuf,
}

impl ReceivedSample for ZenohReceivedSample {


+ 1
- 1
libraries/core/Cargo.toml View File

@@ -11,9 +11,9 @@ eyre = "0.6.8"
serde = { version = "1.0.136", features = ["derive"] }
serde_yaml = "0.9.11"
once_cell = "1.13.0"
zenoh-config = { git = "https://github.com/eclipse-zenoh/zenoh.git", rev = "79a136e4fd90b11ff5d775ced981af53c4f1071b" }
which = "4.3.0"
uuid = { version = "1.2.1", features = ["serde"] }
dora-message = { path = "../message" }
tracing = "0.1"
serde-with-expand-env = "1.1.0"
zenoh = "0.7.0-rc"

+ 1
- 1
libraries/core/src/config.rs View File

@@ -254,7 +254,7 @@ pub struct NodeRunConfig {
pub enum CommunicationConfig {
Zenoh {
#[serde(default)]
config: Box<zenoh_config::Config>,
config: Box<zenoh::prelude::Config>,
prefix: String,
},
}


+ 1
- 2
libraries/extensions/zenoh-logger/Cargo.toml View File

@@ -7,5 +7,4 @@ license = "Apache-2.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
zenoh = { git = "https://github.com/eclipse-zenoh/zenoh.git", rev = "79a136e4fd90b11ff5d775ced981af53c4f1071b" }
zenoh-config = { git = "https://github.com/eclipse-zenoh/zenoh.git", rev = "79a136e4fd90b11ff5d775ced981af53c4f1071b" }
zenoh = "0.7.0-rc"

+ 8
- 4
libraries/extensions/zenoh-logger/src/main.rs View File

@@ -1,11 +1,15 @@
use zenoh::prelude::{Receiver, ZFuture};
use zenoh::prelude::{sync::SyncResolve, Config};

fn main() {
let zenoh = zenoh::open(zenoh_config::Config::default()).wait().unwrap();
let mut sub = zenoh.subscribe("/**").reliable().wait().unwrap();
let zenoh = zenoh::open(Config::default()).res_sync().unwrap();
let sub = zenoh
.declare_subscriber("/**")
.reliable()
.res_sync()
.unwrap();

loop {
let msg = sub.receiver().recv().unwrap();
let msg = sub.recv().unwrap();
println!("{}", msg.key_expr);
}
}

Loading…
Cancel
Save