trickle: align Go publisher with SDK probe-and-fallback pattern#3926
Closed
rickstaa wants to merge 1 commit into
Closed
trickle: align Go publisher with SDK probe-and-fallback pattern#3926rickstaa wants to merge 1 commit into
rickstaa wants to merge 1 commit into
Conversation
3e07d6f to
cc202db
Compare
Mirror the Python SDK's first-POST flow in the Go publisher:
GET {baseURL}/next to learn the server's nextWrite, fall back to slot 0
on probe failure. Establishes a single canonical pattern across the two
trickle clients in the Livepeer stack.
Wire behavior on a fresh channel is unchanged — both old (always-0) and
new (probe-then-resolve) paths POST to /0 first, then /1, /2, ...
The probe adds one round-trip on session start; against a server with
the /next route (#3925) it returns nextWrite cleanly,
against a server without it (today's master) the failure path resolves
to 0 — the same starting slot.
The fallback explicitly returns 0 (not -1) for the same reason the
Python SDK does: -1 would let the server resolve to nextWrite, but the
publisher has no read-back path to learn what slot the server picked.
The local counter then increments past whatever the server chose,
causing the second POST to race the first at slot 0. Returning 0 keeps
the publisher's local counter in lockstep with the server.
Tests in trickle_test.go cover both paths via mock /next handlers
(success returning Lp-Trickle-Latest, fallback returning 400). The
existing test suite continues to pass against the configured trickle
server (which doesn't have /next on master) since the fallback path is
the existing behavior in disguise.
Refs #3925, livepeer/livepeer-python-gateway#12.
cc202db to
58e6add
Compare
5 tasks
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.
Stacked on #3925. Targets
trickle-next-endpointbranch; will retarget tomasterwhen #3925 merges.Summary
Mirror the Python SDK's first-POST flow in the Go HTTP publisher:
GET {baseURL}/nextto learn the server'snextWrite, fall back to slot 0on probe failure. Establishes a single canonical pattern across the two
trickle clients in the Livepeer stack.
Why now
The Python SDK probes
/nextto learn the next-write slot before itsfirst POST. The Go publisher (used by gateway → orchestrator media-in)
historically just started at slot 0. With #3925 introducing the
/nextendpoint, parity becomes possible — and worth taking, so we have one
canonical client-side pattern to maintain.
Behavior
/nextreturnsLp-Trickle-Latest/nextreturns 400 / no header (pre-#3925 servers)Wire behavior on a fresh channel is identical to today — both old
(always-0) and new (probe-then-resolve) paths POST to
/0, then/1,/2, ... The probe adds one round-trip on session start.Why fallback returns 0, not -1
Same reason the SDK does:
-1would let the server resolve tonextWrite, but the publisher has no read-back path to learn what slotthe server picked. The local counter then increments past whatever the
server chose, causing the second POST to race the first at slot 0.
Returning 0 keeps the publisher's local counter in lockstep with the
server.
Tests
trickle/trickle_test.goadds two tests via mock/nexthandlers:TestTrickle_PublisherProbeFallback— server returns 400 on/next. Asserts first POST targets slot 0.TestTrickle_PublisherProbeSuccess— server returnsLp-Trickle-Latest: 7on/next. Asserts first POST targets slot 7.The existing trickle test suite continues to pass against the configured
trickle server (which doesn't have
/nexton master) since the fallbackpath is the existing behavior in disguise.
Relationship to #3884
Josh's #3884 builds the server side (
/nextroute,Lp-Trickle-SeqonPOST responses,
Lp-Trickle-Resethandling) but does not update theGo HTTP publisher to consume any of it. This PR fills that client-side
gap.
Test plan
go build ./trickle/...passesgo test ./trickle/...passes (existing + new)Refs livepeer/livepeer-python-gateway#12.
🤖 Generated with Claude Code