Skip to content

Commit

Permalink
Merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
Mallets committed Dec 27, 2022
2 parents a38547c + 6f98a5e commit 3237bfd
Show file tree
Hide file tree
Showing 19 changed files with 149 additions and 99 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
args: --verbose --all-targets

- name: Install nextest
run: cargo install cargo-nextest
run: cargo install cargo-nextest --locked

- name: Run tests
uses: actions-rs/cargo@v1
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ jobs:
shell: bash
run: |
cargo login ${{ secrets.CRATES_IO_TOKEN }}
<<<<<<< HEAD
cd commons/zenoh-macros && cargo publish && cd - && sleep 20
cd commons/zenoh-core && cargo publish && cd - && sleep 20
cd commons/zenoh-cfg-properties && cargo publish && cd - && sleep 20
Expand Down Expand Up @@ -357,6 +358,36 @@ jobs:
cd plugins/zenoh-plugin-rest && cargo publish && cd - && sleep 20
cd plugins/zenoh-backend-traits && cargo publish && cd - && sleep 20
cd plugins/zenoh-plugin-storage-manager && cargo publish && cd - && sleep 20
=======
cd commons/zenoh-macros && cargo publish && cd -
cd commons/zenoh-core && cargo publish && cd -
cd commons/zenoh-cfg-properties && cargo publish && cd -
cd commons/zenoh-sync && cargo publish && cd -
cd commons/zenoh-collections && cargo publish && cd -
cd commons/zenoh-crypto && cargo publish && cd -
cd commons/zenoh-util && cargo publish && cd -
cd commons/zenoh-protocol-core && cargo publish && cd -
cd commons/zenoh-config && cargo publish && cd -
cd commons/zenoh-buffers && cargo publish && cd -
cd commons/zenoh-protocol && cargo publish && cd -
cd io/zenoh-link-commons && cargo publish && cd -
cd io/zenoh-links/zenoh-link-udp && cargo publish && cd -
cd io/zenoh-links/zenoh-link-tcp && cargo publish && cd -
cd io/zenoh-links/zenoh-link-tls && cargo publish && cd -
cd io/zenoh-links/zenoh-link-quic && cargo publish && cd -
cd io/zenoh-links/zenoh-link-unixsock_stream && cargo publish && cd -
cd io/zenoh-links/zenoh-link-serial && cargo publish && cd -
cd io/zenoh-links/zenoh-link-ws && cargo publish && cd -
cd io/zenoh-link && cargo publish && cd -
cd io/zenoh-transport && cargo publish && cd -
cd plugins/zenoh-plugin-trait && cargo publish && cd -
cd zenoh && cargo publish && cd -
cd zenoh-ext && cargo publish && cd -
cd zenohd && cargo publish && cd -
cd plugins/zenoh-plugin-rest && cargo publish && cd -
cd plugins/zenoh-backend-traits && cargo publish && cd -
cd plugins/zenoh-plugin-storage-manager && cargo publish && cd -
>>>>>>> master
- name: Cancel workflow if fail # thus Docker job be interrupted
if: failure()
uses: andymckay/[email protected]
Expand Down
43 changes: 42 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,51 @@ Check the website [zenoh.io](http://zenoh.io) and the [roadmap](https://github.c

Zenoh is extremely easy to learn, the best place to master the fundamentals is our [getting started guide](https://zenoh.io/docs/getting-started/first-app/).

-------------------------------
## How to install it

To install the latest release of the Zenoh router (`zenohd`) and its default plugins (REST API plugin and Storages Manager plugin) you can do as follows:

### Manual installation (all platforms)

All release packages can be downloaded from:
- https://download.eclipse.org/zenoh/zenoh/latest/

Each subdirectory has the name of the Rust target. See the platforms each target corresponds to on https://doc.rust-lang.org/stable/rustc/platform-support.html

Choose your platform and download the `.zip` file.
Unzip it where you want, and run the extracted `zenohd` binary.

### Linux Debian

Add Eclipse Zenoh private repository to the sources list, and install the `zenoh` package:

```bash
echo "deb [trusted=yes] https://download.eclipse.org/zenoh/debian-repo/ /" | sudo tee -a /etc/apt/sources.list > /dev/null
sudo apt update
sudo apt install zenoh
```
Then you can start run `zenohd`.

### MacOS

Tap our brew package repository and install the `zenoh` formula:

```bash
brew tap eclipse-zenoh/homebrew-zenoh
brew install zenoh
```
Then you can start run `zenohd`.


### Rust API

-------------------------------
## How to build it

Install [Cargo and Rust](https://doc.rust-lang.org/cargo/getting-started/installation.html). Zenoh can be succesfully compiled with Rust stable (>= 1.5.1), so no special configuration is required from your side.
> :warning: **WARNING** :warning: : Zenoh and its ecosystem are under active development. When you build from git, make sure you also build from git any other Zenoh repository you plan to use (e.g. binding, plugin, backend, etc.). It may happen that some changes in git are not compatible with the most recent packaged Zenoh release (e.g. deb, docker, pip). We put particular effort in mantaining compatibility between the various git repositories in the Zenoh project.
Install [Cargo and Rust](https://doc.rust-lang.org/cargo/getting-started/installation.html). Zenoh can be succesfully compiled with Rust stable (>= 1.62.1), so no special configuration is required from your side.
To build Zenoh, just type the following command after having followed the previous instructions:

```bash
Expand Down
2 changes: 1 addition & 1 deletion commons/zenoh-codec/src/zenoh/declare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ where
}

let len: usize = self.codec.read(&mut *reader)?;
let mut declarations = Vec::with_capacity(len as usize);
let mut declarations = Vec::with_capacity(len);
for _ in 0..len {
let d: Declaration = self.codec.read(&mut *reader)?;
declarations.push(d);
Expand Down
2 changes: 1 addition & 1 deletion commons/zenoh-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ validated_struct::validator! {
UserConf {
user: Option<String>,
password: Option<String>,
/// The path to a file containing the user password dictionary, a file containing "<user>:<password>"
/// The path to a file containing the user password dictionary, a file containing `<user>:<password>`
dictionary_file: Option<String>,
} where (user_conf_validator),
pub pubkey: #[derive(Default)]
Expand Down
2 changes: 1 addition & 1 deletion commons/zenoh-macros/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::{env, ffi::OsString, fs::OpenOptions, io::Write, process::Command};

fn main() {
let rustc = env::var_os("RUSTC").unwrap_or_else(|| OsString::from("rustc"));
let output = Command::new(&rustc)
let output = Command::new(rustc)
.arg("-v")
.arg("-V")
.output()
Expand Down
14 changes: 7 additions & 7 deletions commons/zenoh-util/src/time_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,15 +342,15 @@ fn parse_duration(s: &str) -> Result<f64, ZError> {
}
let mut it = s.bytes().enumerate().rev();
match it.next().unwrap() {
(i, b'u') => s[..i].parse::<f64>().map(|u| U_TO_SECS * u as f64),
(i, b'u') => s[..i].parse::<f64>().map(|u| U_TO_SECS * u),
(_, b's') => match it.next().unwrap() {
(i, b'm') => s[..i].parse::<f64>().map(|ms| MS_TO_SECS * ms as f64),
(i, _) => s[..i + 1].parse::<f64>().map(|sec| sec as f64),
(i, b'm') => s[..i].parse::<f64>().map(|ms| MS_TO_SECS * ms),
(i, _) => s[..i + 1].parse::<f64>(),
},
(i, b'm') => s[..i].parse::<f64>().map(|m| M_TO_SECS * m as f64),
(i, b'h') => s[..i].parse::<f64>().map(|h| H_TO_SECS * h as f64),
(i, b'd') => s[..i].parse::<f64>().map(|d| D_TO_SECS * d as f64),
(i, b'w') => s[..i].parse::<f64>().map(|w| W_TO_SECS * w as f64),
(i, b'm') => s[..i].parse::<f64>().map(|m| M_TO_SECS * m),
(i, b'h') => s[..i].parse::<f64>().map(|h| H_TO_SECS * h),
(i, b'd') => s[..i].parse::<f64>().map(|d| D_TO_SECS * d),
(i, b'w') => s[..i].parse::<f64>().map(|w| W_TO_SECS * w),
_ => s.parse::<f64>(),
}
.map_err(|e| zerror!(r#"Invalid duration "{}" ({})"#, s, e))
Expand Down
4 changes: 1 addition & 3 deletions examples/examples/z_get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
// Contributors:
// ZettaScale Zenoh Team, <[email protected]>
//
use async_std::prelude::FutureExt;
use clap::{App, Arg};
use std::convert::TryFrom;
use std::time::Duration;
Expand All @@ -34,10 +33,9 @@ async fn main() {
None => session.get(&selector),
}
.target(target)
.res()
.timeout(timeout)
.res()
.await
.unwrap_or_else(|_| panic!("Query has timed out after {:?}", timeout))
.unwrap();
while let Ok(reply) = replies.recv_async().await {
match reply.sample {
Expand Down
4 changes: 2 additions & 2 deletions gen_zenoh_deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if [ -z "$1" -o -z "$2" ]; then
exit 1
fi

VERSION=`echo $1 | sed s/-/~/g`
VERSION=`echo $1`
ARCH=$2

PACKAGE_NAME="zenoh_${VERSION}_${ARCH}"
Expand All @@ -40,7 +40,7 @@ echo "Section: net " >> ${CONTROL_FILE}
echo "Priority: optional" >> ${CONTROL_FILE}
echo "Essential: no" >> ${CONTROL_FILE}
echo "Installed-Size: 1024 " >> ${CONTROL_FILE}
echo "Depends: zenohd, zenoh-plugin-rest, zenoh-plugin-storage-manager " >> ${CONTROL_FILE}
echo "Depends: zenohd (=${VERSION}), zenoh-plugin-rest (=${VERSION}), zenoh-plugin-storage-manager (=${VERSION}) " >> ${CONTROL_FILE}
echo "Maintainer: [email protected] " >> ${CONTROL_FILE}
echo "Description: The zenoh top-level package" >> ${CONTROL_FILE}
echo "" >> ${CONTROL_FILE}
Expand Down
1 change: 1 addition & 0 deletions io/zenoh-transport/src/multicast/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ impl TransportMulticastInner {
/* SCHEDULE AND SEND TX */
/*************************************/
/// Schedule a Zenoh message on the transmission queue
#[allow(unused_mut)] // Required with "shared-memory" feature
pub(crate) fn schedule(&self, mut message: ZenohMessage) {
// Multicast transports do not support SHM for the time being
#[cfg(feature = "shared-memory")]
Expand Down
4 changes: 2 additions & 2 deletions plugins/zenoh-plugin-rest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ authors = [
]
edition = "2018"
license = " EPL-2.0 OR Apache-2.0"
categories = ["network-programming"]
categories = ["network-programming", "web-programming::http-server"]
description = "The zenoh REST plugin"

[features]
Expand Down Expand Up @@ -71,4 +71,4 @@ maintainer = "[email protected]"
copyright = "2022 ZettaScale Technology"
section = "net"
license-file = ["../../LICENSE", "0"]
depends = "zenohd (=0.6.0~beta.1)"
depends = "zenohd (=0.7.0-rc)"
2 changes: 1 addition & 1 deletion plugins/zenoh-plugin-storage-manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ maintainer = "[email protected]"
copyright = "2022 ZettaScale Technology"
section = "net"
license-file = ["../../LICENSE", "0"]
depends = "zenohd (=0.7.0~rc)"
depends = "zenohd (=0.7.0-rc)"
4 changes: 2 additions & 2 deletions plugins/zenoh-plugin-storage-manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ impl StorageRuntimeInner {
if let Some(storages) = self.storages.remove(&volume.name) {
async_std::task::block_on(futures::future::join_all(
storages
.into_iter()
.map(|(_, s)| async move { s.send(StorageMessage::Stop) }),
.into_values()
.map(|s| async move { s.send(StorageMessage::Stop) }),
));
}
std::mem::drop(self.volumes.remove(&volume.name));
Expand Down
3 changes: 3 additions & 0 deletions zenoh-ext/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,6 @@ path = "examples/z_member.rs"
[[example]]
name = "z_view_size"
path = "examples/z_view_size.rs"

[package.metadata.docs.rs]
features = ["unstable"]
4 changes: 3 additions & 1 deletion zenoh/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ unstable = []
default = [
"auth_pubkey",
"auth_usrpwd",
"shared-memory",
"transport_quic",
"transport_tcp",
"transport_tls",
Expand Down Expand Up @@ -110,3 +109,6 @@ rustc_version = "0.4.0"

[lib]
name = "zenoh"

[package.metadata.docs.rs]
features = ["unstable"]
8 changes: 4 additions & 4 deletions zenoh/src/key_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ impl<'a> KeyExpr<'a> {
prefix_len,
session_id,
} if session.id == *session_id => WireExpr {
scope: *expr_id as u64,
scope: *expr_id,
suffix: std::borrow::Cow::Borrowed(&key_expr.as_str()[((*prefix_len) as usize)..]),
},
KeyExprInner::BorrowedWire {
Expand All @@ -510,7 +510,7 @@ impl<'a> KeyExpr<'a> {
prefix_len,
session_id,
} if session.id == *session_id => WireExpr {
scope: *expr_id as u64,
scope: *expr_id,
suffix: std::borrow::Cow::Borrowed(&key_expr.as_str()[((*prefix_len) as usize)..]),
},
KeyExprInner::Owned(key_expr) | KeyExprInner::Wire { key_expr, .. } => WireExpr {
Expand Down Expand Up @@ -568,7 +568,7 @@ impl SyncResolve for KeyExprUndeclaration<'_> {
session_id
} if *prefix_len as usize == key_expr.len() => {
if *session_id == session.id {
*expr_id as u64
*expr_id
} else {
return Err(zerror!("Failed to undeclare {}, as it was declared by an other Session", expr).into())
}
Expand All @@ -580,7 +580,7 @@ impl SyncResolve for KeyExprUndeclaration<'_> {
session_id
} if *prefix_len as usize == key_expr.len() => {
if *session_id == session.id {
*expr_id as u64
*expr_id
} else {
return Err(zerror!("Failed to undeclare {}, as it was declared by an other Session", expr).into())
}
Expand Down
50 changes: 24 additions & 26 deletions zenoh/src/net/runtime/adminspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ use zenoh_config::ValidatedMap;
use zenoh_core::Result as ZResult;
use zenoh_protocol::{
core::{
key_expr::{keyexpr, OwnedKeyExpr},
Channel, CongestionControl, ConsolidationMode, Encoding, KnownEncoding, QueryTarget,
QueryableInfo, SampleKind, SubInfo, WireExpr, ZInt, ZenohId, EMPTY_EXPR_ID,
key_expr::OwnedKeyExpr, Channel, CongestionControl, ConsolidationMode, Encoding,
KnownEncoding, QueryTarget, QueryableInfo, SampleKind, SubInfo, WireExpr, ZInt, ZenohId,
EMPTY_EXPR_ID,
},
zenoh::{DataInfo, QueryBody, RoutingContext},
};
Expand All @@ -43,7 +43,7 @@ pub struct AdminContext {
}

type Handler = Box<
dyn for<'a> Fn(&'a AdminContext, &'a WireExpr<'a>, &'a str) -> BoxFuture<'a, (ZBuf, Encoding)>
dyn for<'a> Fn(&'a AdminContext, &'a KeyExpr<'a>, &'a str) -> BoxFuture<'a, (ZBuf, Encoding)>
+ Send
+ Sync,
>;
Expand Down Expand Up @@ -393,27 +393,30 @@ impl Primitives for AdminSpace {
}
}

let key_expr = match self.key_expr_to_string(key_expr) {
Ok(key_expr) => key_expr.into_owned(),
Err(e) => {
log::error!("Unknown KeyExpr!! ({})", e);
// router is not re-entrant
task::spawn(async move {
primitives.send_reply_final(qid);
});
return;
}
};

let zid = self.zid;
let plugin_key: OwnedKeyExpr = format!("@/router/{}/status/plugins/**", &zid)
.try_into()
.unwrap();
let mut ask_plugins = false;
let context = self.context.clone();

let mut matching_handlers = vec![];
match self.key_expr_to_string(key_expr) {
Ok(name) => {
ask_plugins = plugin_key.intersects(&name);
for (key, handler) in &self.handlers {
if name.intersects(key) {
matching_handlers.push((key.clone(), handler.clone()));
}
}
let ask_plugins = plugin_key.intersects(&key_expr);
for (key, handler) in &self.handlers {
if key_expr.intersects(key) {
matching_handlers.push((key.clone(), handler.clone()));
}
Err(e) => log::error!("Unknown KeyExpr!! ({})", e),
};

let key_expr = key_expr.to_owned();
}
let parameters = parameters.to_owned();

// router is not re-entrant
Expand All @@ -438,11 +441,6 @@ impl Primitives for AdminSpace {
));
if ask_plugins {
futures::join!(handler_tasks, async {
let key_expr = if key_expr.scope == 0 {
KeyExpr::from(unsafe { keyexpr::from_str_unchecked(&key_expr.suffix) })
} else {
unreachable!("An unresolved WireExpr ({:?}) reached the plugins, this shouldn't have happened, please contact us via GitHub or Discord.", key_expr)
};
let plugin_status = plugins_status(&context, &key_expr, &parameters).await;
for status in plugin_status {
let plugins::Response { key, mut value } = status;
Expand Down Expand Up @@ -515,7 +513,7 @@ impl Primitives for AdminSpace {

pub async fn router_data(
context: &AdminContext,
_key: &WireExpr<'_>,
_key: &KeyExpr<'_>,
#[allow(unused_variables)] selector: &str,
) -> (ZBuf, Encoding) {
let transport_mgr = context.runtime.manager().clone();
Expand Down Expand Up @@ -584,7 +582,7 @@ pub async fn router_data(

pub async fn linkstate_routers_data(
context: &AdminContext,
_key: &WireExpr<'_>,
_key: &KeyExpr<'_>,
_args: &str,
) -> (ZBuf, Encoding) {
let tables = zread!(context.runtime.router.tables);
Expand All @@ -605,7 +603,7 @@ pub async fn linkstate_routers_data(

pub async fn linkstate_peers_data(
context: &AdminContext,
_key: &WireExpr<'_>,
_key: &KeyExpr<'_>,
_args: &str,
) -> (ZBuf, Encoding) {
let data: Vec<u8> = context
Expand Down
Loading

0 comments on commit 3237bfd

Please sign in to comment.