Skip to content

feat(zenoh): one session for ZenohConnector and its Ros2Connector (design 053 s11) - #313

Merged
lxsaah merged 1 commit into
feat/aimdb-zenoh-connectorfrom
feat/053-s11-shared-session
Oct 9, 2026
Merged

lxsaah merged 1 commit into
feat/aimdb-zenoh-connectorfrom
feat/053-s11-shared-session

Conversation

@lxsaah

@lxsaah lxsaah commented Oct 9, 2026

Copy link
Copy Markdown
Member

Stage s11 of docs/design/053-implementation-plan.md: one session for both schemes (053 §4.7). Meets criterion 8.

What it adds

let zenoh = ZenohConnector::new("tcp/192.168.10.5:7447");
let ros2 = zenoh.ros2(Ros2Node::new("cell4_gateway")).register::<Temperature>();
builder.with_connector(zenoh).with_connector(ros2);   // either order
  • ZenohConnector::ros2(&self, node): a Ros2Connector on the same session. Ros2Connector::new still opens a session of its own.
  • Shared (src/shared.rs, std only) holds the endpoint and config, one build-time slot per view, and a flag for the session task.
    • Each connector's build() validates exactly as before, then leaves its parts in its slot.
    • The first build() returns the session task; the other returns no futures.
    • The task takes every part on its first poll, opens the session, and serves both views in one future (tokio::join!). AimDbBuilder runs every build() before it polls anything, so both parts are there in time.
  • Code split: the code after open() moved into ZenohParts::serve and Ros2Parts::serve. Behaviour is unchanged, and the s08–s10 suites pass as they were.
  • A .ros2(..) view that's never registered is logged once and skipped; the Zenoh side runs normally.
  • Two .ros2(..) views on one session both claim the ros2 scheme, so core's existing owned-scheme check refuses them. One ROS node per session, as 053 §4.7 says.
  • with_zenoh_config on either view configures the shared session.

Tests (tests/shared_session.rs)

A TCP proxy in front of an in-process router counts every connection the database opens.

Test Asserts
The gateway (053 §4.8), Zenoh connector registered first a zenoh://cell4/probe/temperature put comes out as a ROS sample on 7/cell4/temperature/… with its 33-byte attachment; 1 connection
The same, ROS view registered first same result; 1 connection
Control: ZenohConnector plus a separate Ros2Connector::new 2 connections, so the proxy really counts
A never-registered .ros2(..) view zenoh:// publishing still works
Two .ros2(..) views registered build() refuses them

Design change

053 §4.7 said Shared would hold core's session::OneShot. A flag in Shared does the same job, and OneShot sits behind core's connector-session feature, which this crate doesn't need. 053 §4.7 now says so and cites the test.

Checks

The full matrix runs in CI. Locally, as a quick signal: the library tests (22), shared_session (5), native_session (7), ros2_inbound (3), ros2_outbound (5), the embedded cargo check, and cargo fmt --all -- --check.

🤖 Generated with Claude Code

`zenoh.ros2(node)` returns a Ros2Connector on the ZenohConnector's
session: one router connection for `zenoh://` and `ros2://`.
`Ros2Connector::new` still owns a session of its own.

Each connector's build() validates its links and leaves its parts in
`Shared`; the first build() returns the session task, the other none.
The task opens the session, then serves both views' parts in one
future. A `.ros2(..)` view that is never registered is logged and
skipped; two views on one session both claim `ros2` and core refuses
them.

Tests count TCP connections through a proxy: the gateway (zenoh:// in,
ros2:// out) opens one in either registration order, and two separate
connectors open two.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@lxsaah
lxsaah merged commit 8c01a05 into feat/aimdb-zenoh-connector Oct 9, 2026
7 checks passed
@lxsaah
lxsaah deleted the feat/053-s11-shared-session branch October 9, 2026 19:39
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