Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade Zenoh to 1.1.0 #261

Merged
merged 2 commits into from
Dec 13, 2024
Merged

feat: upgrade Zenoh to 1.1.0 #261

merged 2 commits into from
Dec 13, 2024

Conversation

J-Loudet
Copy link
Contributor

This commit updates the version of Zenoh used to 1.1.0.

This also forces us to use the version 1.75.0 of the Rust toolchain — as Zenoh-Flow can be started as a Zenoh plugin which, in turn, requires Zenoh-Flow to be compiled with the same version of the Rust toolchain.

The bulk of the changes is due to changes in Zenoh's API which can be
summarised as follows:

  • There is no longer an async prelude.
  • There is no longer the need to call res() in order to make an
    asynchronous Zenoh call.
  • A Zenoh Session internally uses an Arc so there is no longer
    the need to explicitly wrap them inside one.
  • The Value structure was removed and, instead, relevant payload()
    method were added.
  • To access the Sample associated with a Reply the method result()
    should be called.
  • We can call reply_err to reply to a Query with an error.
  • To access the bytes representation of a payload, the method
    to_bytes() was introduced.
  • The FlumeSubscriber structure was removed from Zenoh's API. Instead,
    we use the Subscriber<FifoChannelHandler<Sample>>. Internally it
    still uses flume but that dependency is now hidden.

This commit prepares upgrading the version of Zenoh to 1.0.4 by bumping
the version of the Rust toolchain to 1.75.0.

As with every new version of Rust, new Clippy warnings are introduced.
This commit also fixes them.

* rust-toolchain.toml: bump the toolchain to 1.75.0.
* zenoh-flow-descriptors/src/flattened/mod.rs: removed the unused
  exports.
* zenoh-flow-nodes/src/io/outputs.rs: use `or_default`.
* zenoh-flow-records/src/dataflow.rs: use `or_default`.

Signed-off-by: Julien Loudet <julien.loudet@zettascale.tech>
This commit updates the version of Zenoh used to 1.1.0.

The bulk of the changes is due to changes in Zenoh's API which can be
summarised as follows:
- There is no longer an `async` prelude.
- There is no longer the need to call `res()` in order to make an
  asynchronous Zenoh call.
- A Zenoh `Session` internally uses an `Arc` so there is no longer
  the need to explicitly wrap them inside one.
- The `Value` structure was removed and, instead, relevant `payload()`
  method were added.
- To access the `Sample` associated with a `Reply` the method `result()`
  should be called.
- We can call `reply_err` to reply to a Query with an error.
- To access the bytes representation of a payload, the method
  `to_bytes()` was introduced.
- The `FlumeSubscriber` structure was removed from Zenoh's API. Instead,
  we use the `Subscriber<FifoChannelHandler<Sample>>`. Internally it
  still uses `flume` but that dependency is now hidden.

---

* Cargo.lock: copied the content of the `Cargo.lock` of Zenoh's 1.1.0
  release and ran `cargo build` after.

* Cargo.toml:
  - Updated and froze the version of the Zenoh crates to 1.1.4.
  - Removed the crates that were no longer needed:
    - `zenoh-protocol`,
    - `zenoh-result`,
    - `zenoh-sync`,
    - `zenoh-util`.

* zenoh-flow-commons/Cargo.toml: replaced the crate `zenoh-protocol`
  with `zenoh-config` as this is now the crate that exposes the
  `ZenohId` structure.

* zenoh-flow-commons/src/identifiers.rs:
  - `ZenohId` is now exposed in the `zenoh_config` crate.
  - `ZenohId::rand()` no longer exists and the implementation of the
    `Default` trait does the same.

* zenoh-flow-daemon/src/daemon/mod.rs:
  - There is no longer an `async` prelude.
  - The `Session` structure is exposed in the root of the `zenoh` crate.
  - A `Session` internally uses an `Arc`, meaning that we no longer need
    to wrap it inside one.

* zenoh-flow-daemon/src/daemon/queryables.rs:
  - There is no longer an `async` prelude.
  - The `Session` structure is exposed in the root of the `zenoh` crate.
  - A `Session` internally uses an `Arc`, meaning that we no longer need
    to wrap it inside one.
  - The `AsyncResolve` trait no longer exists, we can directly `await`
    a future returned by a Zenoh call.

* zenoh-flow-daemon/src/queries/instances/abort.rs:
  - There is no longer an `async` prelude.
  - The `Session` structure is exposed in the root of the `zenoh` crate.
  - The `AsyncResolve` trait no longer exists, we can directly `await`
    a future returned by a Zenoh call — no longer needing to call the
    method `res()`.

* zenoh-flow-daemon/src/queries/instances/create.rs
  - There is no longer an `async` prelude.
  - The `Value` structure was removed and we have to use instead the
    `payload()` method to attach a payload to a query.
  - The `AsyncResolve` trait no longer exists, we can directly `await`
    a future returned by a Zenoh call — no longer needing to call the
    method `res()`.
  - To access the `Sample` of a `Reply` we now have to call the
    `result()` method.

* zenoh-flow-daemon/src/queries/instances/delete.rs:
  - There is no longer an `async` prelude.
  - The `Value` structure was removed and we have to use instead the
    `payload()` method to attach a payload to a query.
  - The `AsyncResolve` trait no longer exists, we can directly `await`
    a future returned by a Zenoh call — no longer needing to call the
    method `res()`.

* zenoh-flow-daemon/src/queries/instances/mod.rs:
  - There is no longer an `async` prelude.
  - The `Query` structure is now under the `zenoh::query` module.
  - The `reply()` method now takes two parameters: a key expression
    and a payload.
  - We can now reply an error using the `reply_err()` method.

* zenoh-flow-daemon/src/queries/instances/start.rs:
  - There is no longer an `async` prelude.
  - The `Query` structure is now under the `zenoh::query` module.
  - The `Session` structure is exposed in the root of the `zenoh` crate.
  - We can now reply an error using the `reply_err()` method.
  - The `reply()` method now takes two parameters: a key expression
    and a payload.
  - The `Value` structure was removed and we have to use instead the
    `payload()` method to attach a payload to a query.
  - The `AsyncResolve` trait no longer exists, we can directly `await`
    a future returned by a Zenoh call — no longer needing to call the
    method `res()`.

* zenoh-flow-daemon/src/queries/mod.rs:
  - There is no longer an `async` prelude.
  - The `Query` structure is now under the `zenoh::query` module.
  - The check of the encoding was removed as it was superfluous, not
    providing much added benefits.
  - The `Value` structure was removed and we have to use instead the
    `payload()` method to access the payload of a query.
  - To access the bytes representation of a payload we can now call the
    `to_bytes()` method.

* zenoh-flow-daemon/src/queries/runtime.rs:
  - There is no longer an `async` prelude.
  - The `Query` structure is now under the `zenoh::query` module.
  - The `AsyncResolve` trait no longer exists, we can directly `await`
    a future returned by a Zenoh call — no longer needing to call the
    method `res()`.
  - The `reply()` method now takes two parameters: a key expression
    and a payload.
  - We can now reply an error using the `reply_err()` method.

* zenoh-flow-runtime/src/lib.rs:
  - The `client`, `empty` and `peer` function no longer exists.
  - There is no longer an `async` prelude.
  - The `open` method, `Config` and `Session` structures were moved at
    the root of the `zenoh` crate.

* zenoh-flow-runtime/src/runners/builtin/zenoh/sink.rs:
  - There is no longer an `async` prelude.
  - The `Session` structure is exposed in the root of the `zenoh` crate.
  - The `OwnedKeyExpr` structure is now exposed under the
    `zenoh::key_expr` module.
  - The `Publisher` structure is now exposed under the `zenoh::pubsub`
    module.
  - A `Session` internally uses an `Arc`, meaning that we no longer need
    to wrap it inside one.
  - The `AsyncResolve` trait no longer exists, we can directly `await`
    a future returned by a Zenoh call — no longer needing to call the
    method `res()`.

* zenoh-flow-runtime/src/runners/builtin/zenoh/source.rs:
  - There is no longer an `async` prelude.
  - The `FlumeSubscriber` no longer exists and was instead replaced with
    the `FifoChannelHandler`.
  - The `OwnedKeyExpr` structure is now exposed under the
    `zenoh::key_expr` module.
  - The `Publisher` structure is now exposed under the `zenoh::pubsub`
    module.
  - The `Sample` structure is now exposed under the `zenoh::sample`
    module.
  - The `Session` structure is exposed in the root of the `zenoh` crate.
  - A `Session` internally uses an `Arc`, meaning that we no longer need
    to wrap it inside one.
  - The `AsyncResolve` trait no longer exists, we can directly `await`
    a future returned by a Zenoh call — no longer needing to call the
    method `res()`.
  - To access the bytes representation of a payload we can now call the
    `to_bytes()` method.

* zenoh-flow-runtime/src/runners/connectors.rs:
  - There is no longer an `async` prelude.
  - The `FlumeSubscriber` no longer exists and was instead replaced with
    the `FifoChannelHandler`.
  - The `OwnedKeyExpr` structure is now exposed under the
    `zenoh::key_expr` module.
  - The `Publisher` structure is now exposed under the `zenoh::pubsub`
    module.
  - The `Sample` structure is now exposed under the `zenoh::sample`
    module.
  - The `Session` structure is exposed in the root of the `zenoh` crate.
  - A `Session` internally uses an `Arc`, meaning that we no longer need
    to wrap it inside one.
  - The `AsyncResolve` trait no longer exists, we can directly `await`
    a future returned by a Zenoh call — no longer needing to call the
    method `res()`.
  - To "read" the bytes representation of a payload we can now call the
    `reader()` method.

* zenoh-flow-runtime/src/runtime/builder.rs:
  - The `Session` structure is exposed in the root of the `zenoh` crate.
  - There is no longer an `async` prelude.
  - A `Session` internally uses an `Arc`, meaning that we no longer need
    to wrap it inside one.
  - The `zenoh::config::peer()` function no longer exists and the
    implementation of the `Default` trait now yields the same result.
  - The `AsyncResolve` trait no longer exists, we can directly `await`
    a future returned by a Zenoh call — no longer needing to call the
    method `res_async()`.

* zenoh-flow-runtime/src/runtime/mod.rs:
  - A `Session` internally uses an `Arc`, meaning that we no longer need
    to wrap it inside one.
  - Due to the previous change, the method `session()` now returns a
    reference that a caller can `clone()` — yielding the same result.

* zenoh-plugin-zenoh-flow/Cargo.toml: removed the no longer needed
  crates `zenoh-result` and `zenoh-util`.

* zenoh-plugin-zenoh-flow/src/lib.rs:
  - A `Session` internally uses an `Arc`, meaning that we no longer need
    to wrap it inside one. That rendes the import to `std::sync::Arc`
    unneeded.
  - There is no longer an `async` prelude.
  - The `zenoh_result::zerror` macro was moved inside the
    `zenoh::internal` module.
  - The `Runtime` and `RunningPlugin` were, respectively, moved inside
    the modules `zenoh::internal::runtime` and
    `zenoh::internal::plugins`.
  - The `AsyncResolve` trait no longer exists, we can directly `await`
    a future returned by a Zenoh call — no longer needing to call the
    method `res()`.
  - The signature of the method `adminspace_getter` of the
    `RunningPluginTrait` changed to accept a `KeyExpr` instead of a
    `Selector`.
  - The `Result` structure was moved in the root of the `zenoh` crate.
  - The `Response` structure was moved in the `zenoh::internal::plugins`
    module.

* zfctl/Cargo.toml: removed the unneeded crate `zenoh-util`.

* zfctl/src/daemon_command.rs:
  - There is no longer an `async` prelude.
  - The `Session` structure is exposed in the root of the `zenoh` crate.
  - The `Config` structure is exposed in the root of the `zenoh` crate.
  - The `zenoh::config::peer()` function no longer exists and the
    implementation of the `Default` trait now yields the same result.
  - The `AsyncResolve` trait no longer exists, we can directly `await`
    a future returned by a Zenoh call — no longer needing to call the
    method `res_async()`.
  - A `Session` internally uses an `Arc`, meaning that we no longer need
    to wrap it inside one.

* zfctl/src/instance_command.rs:
  - There is no longer an `async` prelude.
  - The enumeration `ConsolidationMode` is now exposed in the
    `zenoh::query` module.
  - The `Session` structure is exposed in the root of the `zenoh` crate.
  - The `Value` structure was removed and we have to use instead the
    `payload()` method to set the payload of a query.
  - The `AsyncResolve` trait no longer exists, we can directly `await`
    a future returned by a Zenoh call — no longer needing to call the
    method `res()`.
  - To access the `Sample` of a `Reply` we now have to call the
    `result()` method.
  - To access the bytes representation of a payload we can now call the
    `to_bytes()` method.
  - To access the `replier_id` we now have to call the corresponding
    getter method.

* zfctl/src/main.rs:
  - There is no longer an `async` prelude.
  - The `Config` structure is exposed in the root of the `zenoh` crate.
  - The `zenoh::config::peer()` function no longer exists and the
    implementation of the `Default` trait now yields the same result.
  - The `AsyncResolve` trait no longer exists, we can directly `await`
    a future returned by a Zenoh call — no longer needing to call the
    method `res()`.

* zfctl/src/run_local.rs:
  - The `AsyncResolve` trait no longer exists, we can directly `await`
    a future returned by a Zenoh call — no longer needing to call the
    method `res_async()`.
  - A `Session` internally uses an `Arc`, meaning that we no longer need
    to wrap it inside one.

* zfctl/src/runtime_command.rs:
  - There is no longer an `async` prelude.
  - The `Session` structure is exposed in the root of the `zenoh` crate.
  - The `Value` structure was removed and we have to use instead the
    `payload()` method to attach a payload to a query.
  - The `AsyncResolve` trait no longer exists, we can directly `await`
    a future returned by a Zenoh call — no longer needing to call the
    method `res()`.
  - To access the `Sample` of a `Reply` we now have to call the
    `result()` method.
  - To access the bytes representation of a payload we can now call the
    `to_bytes()` method.

* zfctl/src/utils.rs:
  - There is no longer an `async` prelude.
  - The `Session` structure is exposed in the root of the `zenoh` crate.
  - The enumeration `ConsolidationMode` is now exposed in the
    `zenoh::query` module.
  - The `Value` structure was removed and we have to use instead the
    `payload()` method to attach a payload to a query.
  - The `AsyncResolve` trait no longer exists, we can directly `await`
    a future returned by a Zenoh call — no longer needing to call the
    method `res()`.
  - To access the `Sample` of a `Reply` we now have to call the
    `result()` method.
  - To access the bytes representation of a payload we can now call the
    `to_bytes()` method.

Signed-off-by: Julien Loudet <julien.loudet@zettascale.tech>
@J-Loudet J-Loudet merged commit bbf8eac into main Dec 13, 2024
9 checks passed
@J-Loudet J-Loudet deleted the feat/Zenoh-1.1.0 branch December 13, 2024 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant