feat(session): round out accept-side request helpers#33
Merged
Conversation
Every outbound request opener now has a matching Accept* counterpart, so a
server gets the same typed-handle ergonomics AcceptSubscribe already gave:
- AcceptPublish now returns *IncomingPublication (TrackAlias, Update)
instead of bare error — the receiving side of a publisher push.
- AcceptFetch writes FETCH_OK and returns *FetchResponder, whose
OpenFetchStream binds the fetch's Request ID onto the FETCH_HEADER
uni-stream automatically.
- AcceptTrackStatus writes TRACK_STATUS_OK. It returns no handle by
design (TRACK_STATUS is a one-shot status query with no push side);
this is documented rather than left as an arbitrary asymmetry.
- AcceptPublishNamespace / AcceptSubscribeNamespace / AcceptSubscribeTracks
write REQUEST_OK and return *IncomingNamespacePublication /
*IncomingNamespaceSubscription / *IncomingTrackSubscription. The last
carries WritePublishBlocked, mirroring TrackSubscription.ReadPublishBlocked.
Adds accept_test.go (round-trips incl. a FETCH stream and a PUBLISH_BLOCKED
exchange), updates the AcceptPublish callers/example, and adds a README row.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The README "Examples" table maps each topic to a real, compile-checked Example function; the accept-side row instead listed bare method names, which is neither an example nor verified. Extend ExampleSession_AcceptRequest to dispatch and answer every request type via its Accept* helper (adding the TrackStatus and namespace cases) and point the single "Accept requests" row at it, dropping the off-convention method list. Co-Authored-By: Claude Opus 4.8 <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.
What
The accept side of the request API was asymmetric:
AcceptSubscribereturned a rich*Publication,AcceptPublishreturned a bareerror, andFetch/TrackStatus/ the three namespace requests had noAccept*helper at all (servers hand-rolledreq.Reply). This rounds the set out so every outbound opener has a matching, typed accept-side counterpart.Subscribe→*SubscriptionAcceptSubscribe(unchanged)*PublicationPublish→*PublicationAcceptPublish*IncomingPublication(TrackAlias,Update)Fetch→*FetchRequestAcceptFetch*FetchResponder(OpenFetchStream, Request ID pre-bound)TrackStatus→*TrackStatusRequestAcceptTrackStatusPublishNamespace→*NamespacePublicationAcceptPublishNamespace*IncomingNamespacePublicationSubscribeNamespace→*NamespaceSubscriptionAcceptSubscribeNamespace*IncomingNamespaceSubscriptionSubscribeTracks→*TrackSubscriptionAcceptSubscribeTracks*IncomingTrackSubscription(WritePublishBlocked)Highlights:
AcceptPublishnow returns*IncomingPublication(was bareerror) — the receiving side of a publisher push, withTrackAlias()andUpdate().AcceptFetchwritesFETCH_OKand returns a responder whoseOpenFetchStream()binds the fetch's Request ID onto theFETCH_HEADERuni-stream automatically — mirroring howAcceptSubscribe'sPublication.OpenSubgrouppre-binds the alias.AcceptSubscribeTracks' handle hasWritePublishBlocked, the publisher-side mirror ofTrackSubscription.ReadPublishBlocked.AcceptTrackStatusdeliberately returns no handle (TRACK_STATUS is a one-shot status query with no object-push side) — documented, not left as an arbitrary gap.The
Incoming*names follow the package's existing convention for the receive/accept side (IncomingSubgroupStream,IncomingFetchStream).Testing
accept_test.go: round-trips for each helper, including a full FETCHOpenFetchStreamexchange (asserting the bound Request ID) and aWritePublishBlocked→ReadPublishBlockedexchange. The streaming tests run the server side in a goroutine and read on the client in send order, since thesessiontestpipes are synchronous (a deadlock here was caught bygo test ./...and fixed).AcceptPublishcallers/example for the new signature; added a README row.go build ./..., fullgo test ./...(every packageok),golangci-lint run, and themodernizecheck — all clean.🤖 Generated with Claude Code