Repository navigation
feat(json): ValueWriter stamps value-track updates itself - #99
Merged
Merged
Conversation
A latest-value JSON track is timed, and moq-net refuses a group that starts at or before the group before it. A scalar value starts a group with every change, so two changes in the same millisecond failed when the caller stamped them with `Timestamp::from(Instant::now())`, and every application needed its own stamp counter and a drop guard that finishes the track. The new `moq-ext-json` crate adds `ValueWriter<T>`. It wraps the moq-json snapshot producer, stamps each update from the moq clock at the track's timescale, and moves a stamp that does not pass the previous one a tick past it, so stamps strictly increase. Clones share the track and the stamps, and stamp and write under one lock, so clones on several threads cannot reorder them. The last clone to drop finishes the track. `update_at` takes an explicit time, `mutate` edits in place, and `producer()` hands out the underlying producer for refresh and cut. `Node::publish_value` and `LocalBroadcast::value_track` return the writer, and `iroh-live-node`, `moq-ext-publisher` and the `iroh-live` facade re-export it. The type lives in its own crate because the node and the publisher do not depend on each other. Nothing changes on the wire or on the read side. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Value tracks are timed since the moq bump in #94: every update carries a
timestamp, and moq-net refuses a group that starts at or before the group
before it (
TimestampMismatch). A scalar value starts a new group on everychanged update, so two updates in the same millisecond fail, and every
caller had to keep its own monotonic clock.
This adds
ValueWriter<T>in a small new crate,moq-ext-json, andreturns it from
Node::publish_valueandLocalBroadcast::value_track.update(&v)stamps from the moq clock. A stamp that is not past the lastone becomes one tick after it, so updates never collide.
different threads stay ordered.
update_at(&v, at)takes a caller's time,mutateedits in place,finishends the track, and the track finishes when the last clonedrops.
until updates slow down.
It lives in its own crate because iroh-live-node and moq-ext-publisher do
not depend on each other. The facade re-exports it as
iroh_live::ValueWriter. The reading side is unchanged.Breaking:
publish_valueandvalue_trackreturn aValueWriterinsteadof a raw snapshot producer. docs/migration.md has the before and after.
Tests cover ties, a clock stepping back, a burst of 100 updates, clones on
two threads,
update_atbefore the previous group, and finish on the lastdrop.
🤖 Generated with Claude Code