moq-clock: convert to a moq-native example#1494
Conversation
WalkthroughThis PR removes the rs/moq-clock crate and its ancillary files from workspace and packaging outputs, updates documentation and README links to point to a new clock example added at rs/moq-native/examples/clock.rs, changes the demo justfile to run that example, adds chrono to rs/moq-native dev-dependencies, and updates the Nix overlay to remove moq-clock and introduce a moq-relay package. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Replaces the standalone moq-clock crate with rs/moq-native/examples/clock.rs,
joining the existing chat example. The clock binary was already marked
publish = false on crates.io and had no external consumers; folding it
into the examples folder keeps it building with the workspace, drops a
member from `cargo check`'s target set, and removes the release-plz
config and Nix derivation that existed only to build a binary nobody
shipped.
Also fixes the release-plz CI failure on main: with the crate gone, the
`publish = false` (Cargo.toml) vs `publish = true` (release-plz default)
mismatch that aborted `release-plz release` no longer exists, so the
`.release-plz.toml` package block is dropped entirely.
Run with `cargo run -p moq-native --example clock -- --url ... --broadcast clock {publish,subscribe}`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2c77dd3 to
0dacb88
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@rs/moq-native/examples/clock.rs`:
- Around line 138-141: Replace the panic-worthy .unwrap() on create_group with
the ? operator so errors are propagated from run(): change the line using
self.track.create_group(sequence.into()).unwrap() to use
self.track.create_group(sequence.into())? and keep the rest of the loop intact;
ensure the surrounding run() signature returns a compatible Result or map the
error (e.g., using .map_err(...)? ) if the error types differ so compilation
succeeds.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e3f37277-fc9f-41d9-bc42-b29f6f310aee
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (18)
.release-plz.tomlCLAUDE.mdCargo.tomldemo/pub/justfiledoc/lib/rs/index.mdflake.nixjs/clock/README.mdnix/overlay.nixpy/moq-rs/examples/clock.pyrs/moq-clock/CHANGELOG.mdrs/moq-clock/Cargo.tomlrs/moq-clock/README.mdrs/moq-clock/build.rsrs/moq-clock/src/clock.rsrs/moq-clock/src/main.rsrs/moq-native/Cargo.tomlrs/moq-native/examples/clock.rsrs/moq-net/README.md
💤 Files with no reviewable changes (11)
- rs/moq-clock/README.md
- rs/moq-clock/src/main.rs
- nix/overlay.nix
- Cargo.toml
- rs/moq-clock/build.rs
- doc/lib/rs/index.md
- rs/moq-clock/CHANGELOG.md
- rs/moq-clock/src/clock.rs
- flake.nix
- .release-plz.toml
- rs/moq-clock/Cargo.toml
✅ Files skipped from review due to trivial changes (4)
- rs/moq-net/README.md
- js/clock/README.md
- CLAUDE.md
- py/moq-rs/examples/clock.py
| loop { | ||
| let segment = self.track.create_group(sequence.into()).unwrap(); | ||
|
|
||
| sequence += 1; |
There was a problem hiding this comment.
Prefer ? over .unwrap() for create_group.
If create_group fails, this will panic. Since run() returns Result, propagate the error instead.
Suggested fix
- let segment = self.track.create_group(sequence.into()).unwrap();
+ let segment = self.track.create_group(sequence.into())?;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| loop { | |
| let segment = self.track.create_group(sequence.into()).unwrap(); | |
| sequence += 1; | |
| loop { | |
| let segment = self.track.create_group(sequence.into())?; | |
| sequence += 1; |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@rs/moq-native/examples/clock.rs` around lines 138 - 141, Replace the
panic-worthy .unwrap() on create_group with the ? operator so errors are
propagated from run(): change the line using
self.track.create_group(sequence.into()).unwrap() to use
self.track.create_group(sequence.into())? and keep the rest of the loop intact;
ensure the surrounding run() signature returns a compatible Result or map the
error (e.g., using .map_err(...)? ) if the error types differ so compilation
succeeds.
Summary
rs/moq-clockcrate and move its source intors/moq-native/examples/clock.rs, alongside the existingchat.rsexample.moq-clockfrom the Cargo workspace, the Nix overlay/flake,.release-plz.toml, and thedemo/pub/justfile.CLAUDE.md,rs/moq-net/README.md,doc/lib/rs/index.md,js/clock/README.md,py/moq-rs/examples/clock.py) to point at the new location.Run with:
Why
moq-clock was already marked
publish = falseafter #1488 and had no external consumers. Keeping it as a workspace member just added another binary to build, a Nix derivation, and a release-plz config block that we had to maintain. As an example it stays buildable alongside the workspace and lives next to the existingchatexample that the moq-net README already links to.This also fixes the
release-plz releasefailure onmain(https://github.com/moq-dev/moq/actions/runs/26375450178/job/77634868258). With the crate gone, thepublish = false(Cargo.toml) vspublish = true(release-plz default) mismatch no longer exists, so the.release-plz.tomlpackage block is dropped entirely instead of being patched.Placement note
Examples that demonstrate moq-net usage with moq-native helpers (logging, ClientConfig, etc.) already live in
rs/moq-native/examples/(seechat.rs). Putting clock there too avoids a dev-dep cycle (moq-net → moq-native → moq-net) and matches that precedent. The moq-net README continues to link to both examples.Test plan
cargo check --all-targets(default members) passescargo build -p moq-native --example clocksucceedscargo run -p moq-native --example clock -- --helpshows the expected CLIjust rs check(check, clippy, fmt, doc, shear, sort) passesRelease RSrun onmainreachesrelease-plz releasewithout the publish-mismatch error.🤖 Generated with Claude Code
(Written by Claude)