Skip to content

refactor(router): add dynamo-zmq, the socket helper - #177

Closed
ishandhanani wants to merge 1 commit into
idhanani/rs2-03-kv-eventsfrom
idhanani/rs2-04-zmq
Closed

ishandhanani wants to merge 1 commit into
idhanani/rs2-03-kv-eventsfrom
idhanani/rs2-04-zmq

Conversation

@ishandhanani

Copy link
Copy Markdown
Owner

Router split v2, unit 04 of 17. Stacked on #176 (unit 03).

Summary

dynamo-zmq (lib/zmq) is the one ZMQ socket helper: an async ZmqSocket over tokio::io::unix::AsyncFd, multipart send and receive, the process-wide context pool sized by DYN_ZMQ_IO_THREADS, the SUB, DEALER, and bound PUB constructors, and validate_endpoint, moved verbatim from lib/kv-router/src/services/common/zmq.rs. The per-service feature gates inside the file are dropped because the crate is unconditional, and pub(crate) becomes pub; that is the entire non-whitespace delta. It is the one router crate allowed to reach zmq; the error type stays anyhow until its callers (indexer listener, replica mesh, direct ingress) move into kv-router's adapter layer in unit 11. kv-router re-exports it at services::common::zmq. Replaces fork PR #114.

What moves

  • refactor(router): add dynamo-zmq, the socket helper #114 5bc7bdf07b refactor(router): add dynamo-zmq, the socket helper: services/common/zmq.rs to lib/zmq/src/lib.rs. Move-diff (its body): 326 normalized lines in common; 12 new and 12 dropped, each pair the same line with pub(crate) replaced by pub.

Dependency edges

  • dynamo-zmq -> no router crate; direct: anyhow, tokio, tracing, zmq (dynamo-runtime, dynamo-kv-router, dynamo-router-protocol, dynamo-kv-events, dynamo-kv-hashing, prometheus, axum, hyper, reqwest forbidden in its tree)

Validation

Unit-level move-diff, run from the worktree at the unit head 5bc7bdf07b: python3 -I scripts/router_move_diff.py acd8bf4226 5bc7bdf07b --from <1 paths> --to <1 paths>, the union of the replaced fork PRs' --from/--to lists filtered to the paths present at each end (full command in the artifact /tmp/rr-split/unit-prs/04-move-diff.txt).

summary from_normalized=338 to_normalized=338 common=326 new=12 dropped=12
result DIFFERS

12 new / 12 dropped, each pair the same declaration with pub(crate) replaced by pub, as the fork PR recorded.

New and dropped normalized lines (12 new, 12 dropped).
new 1x pub async fn recv_multipart(&mut self) -> Result<MultipartMessage> {
new 1x pub async fn send_multipart(&mut self, frames: MultipartMessage) -> Result<()> {
new 1x pub fn connect(&self, endpoint: &str) -> Result<()> {
new 1x pub fn connect_dealer_socket(endpoint: &str) -> Result<ZmqSocket> {
new 1x pub fn connect_sub_socket(endpoint: &str) -> Result<ZmqSocket> {
new 1x pub fn create_bound_pub_socket(endpoint: &str) -> Result<ZmqSocket> {
new 1x pub fn create_sub_socket(topic: &[u8]) -> Result<ZmqSocket> {
new 1x pub fn create_sub_socket_topics(topics: &[&[u8]]) -> Result<ZmqSocket> {
new 1x pub fn disconnect(&self, endpoint: &str) -> Result<()> {
new 1x pub fn validate_endpoint(endpoint: &str) -> Result<()> {
new 1x pub struct ZmqSocket(AsyncFd<SocketWrapper>);
new 1x pub type MultipartMessage = Vec<Vec<u8>>;
dropped 1x pub(crate) async fn recv_multipart(&mut self) -> Result<MultipartMessage> {
dropped 1x pub(crate) async fn send_multipart(&mut self, frames: MultipartMessage) -> Result<()> {
dropped 1x pub(crate) fn connect(&self, endpoint: &str) -> Result<()> {
dropped 1x pub(crate) fn connect_dealer_socket(endpoint: &str) -> Result<ZmqSocket> {
dropped 1x pub(crate) fn connect_sub_socket(endpoint: &str) -> Result<ZmqSocket> {
dropped 1x pub(crate) fn create_bound_pub_socket(endpoint: &str) -> Result<ZmqSocket> {
dropped 1x pub(crate) fn create_sub_socket(topic: &[u8]) -> Result<ZmqSocket> {
dropped 1x pub(crate) fn create_sub_socket_topics(topics: &[&[u8]]) -> Result<ZmqSocket> {
dropped 1x pub(crate) fn disconnect(&self, endpoint: &str) -> Result<()> {
dropped 1x pub(crate) fn validate_endpoint(endpoint: &str) -> Result<()> {
dropped 1x pub(crate) struct ZmqSocket(AsyncFd<SocketWrapper>);
dropped 1x pub(crate) type MultipartMessage = Vec<Vec<u8>>;

Chain v2, full mode, on the rebased stack head ebd31cdf4d (every unit's commits are ancestors of it; the chain ran once on the head, not per unit), log /tmp/rr-split/srebase-validation.log: stage 1, the 13 router crates (clippy under default and all features, cargo test 1,247 passed / 5 ignored, rustdoc with all features), 1 min 50 s; stage 2, kv-router (clippy, bench check, 229 tests including the prelude test), 1 min 20 s; stage 3, workspace clippy, 4 min 58 s; stage 4, hosts (dynamo-llm lib alone, its kv_router 492 / discovery 275 / pool_relay 261 tests, 13 host crates clippy, bindings clippy; the pre-existing kvbm-consolidator manifest failure is the one non-zero exit), 29 min 21 s; stage 5, gates (every kv-router feature alone and together, 6 public-API snapshots unchanged with kv-router at 918 items, layering gate 47 checks and --host 66 checks with 0 failures, codeowners 7590/7590, fmt, 3 lockfiles --locked), 3 min 06 s; 40 min 35 s total, exit 0.

Each replaced fork PR carried its own validation chain; see its body.

Tickets

Part of DYNO-173

Move lib/kv-router/src/services/common/zmq.rs to lib/zmq as the
dynamo-zmq crate: the async ZmqSocket over tokio's AsyncFd, multipart send
and receive, the process-wide context pool sized by DYN_ZMQ_IO_THREADS, the
SUB, DEALER, and bound PUB constructors, and validate_endpoint. The file
moves verbatim; the feature gates that selected functions per standalone
service are dropped because the crate is unconditional, and pub(crate)
becomes pub. The error type stays anyhow for now so callers do not change;
it becomes a thiserror enum when those callers move into the router adapter
layer.

lib/kv-router re-exports the crate at services::common::zmq behind the same
standalone features, so no caller changes. The layering gate gains a
dynamo-zmq row; CODEOWNERS claims lib/zmq.

Step 4 of the router split v2 plan. DYNO-173.

Signed-off-by: Ishan Dhanani <ishandhanani@gmail.com>
@ishandhanani

Copy link
Copy Markdown
Owner Author

Landed upstream as ai-dynamo#18055 (squash commit 79692cf on main, 2026-11-11). Closing this fork review unit.

This branch had an error being deployed

1 failed deployment
external_collaborator — 5bc7bdf0 Deployed Nov 2, 2026 by ishandhanani via ok-to-test #516
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant