Repository navigation
Conversation
…opted into HLS and ABR A publishing session's usage and session_close records now carry gateway.opt_in_seconds.abr and .hls (usage.OptInSeconds): the whole seconds its announcements beneath /.abr/ and /.hls/ lasted on the relay, added up over its broadcasts. Only an opt-in the session's grant covers reaches the relay, and moqt ends one a revoked ticket no longer covers, so the time is billed to the key that holds the opt-in. qumo abr never needs to know whose broadcast it transcodes. - relay: optInClock counts each checked session's opt-in announcements while they last; the lease sends its totals with each revalidate and reportEnd with the end (auth.Request.OptIns). - auth: a publisher's records carry them; a viewer's total does not. - optin.Of names the egress a path opts into; ingest uses it too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KPWMJL7PH3rPhK5UTGavaB
3 tasks done
A publisher that opted anything in sent a usage record at every revalidate, even with no bytes moved and under a whole second opted in. It now reports only when a metric is positive, as before #613 for bytes. The opt-in clock reads time.Now itself; its tests run in a synctest bubble instead of passing a fake clock through the constructor. TestOf uses subtests; two doc comments are rewrapped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KPWMJNAzsnsiqRPREa2JqY
okdaichi
added a commit
that referenced
this pull request
Nov 18, 2026
The opt-in clock now lives in internal/optin: NewClock takes no clock and its tests run in a synctest bubble, as in #613. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KPWMJNAzsnsiqRPREa2JqY
This branch has not been deployed
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.
Description
Step 2 of usage metering, stacked on #608. Merge #608 first; GitHub then retargets this PR to
main.A publishing session's
usageandsession_closerecords now carry opt-in seconds:gateway.opt_in_seconds.abrandgateway.opt_in_seconds.hls/.abr/and/.hls/lasted on the relay, added up over its broadcasts (two broadcasts opted into ABR for a minute each are 120)A control plane can then bill ABR or HLS by the time it was used, under the tenant's key. This follows the rule agreed for metering: usage goes to the kid of the tenant token the server itself verified. The relay verifies the ticket that lets the session announce the opt-in, so the relay meters it.
qumo abrnever needs to know whose broadcast it transcodes.Why only paid opt-ins are counted:
Related Issue
Follows #608 (step 1:
internal/meter). Steps 3 (ingest) and 4 (hls) come next.Changes
internal/relay:optInClockcounts each checked session's opt-in announcements while they last. Per egress it keeps the time of ended announcements pluslive × (now − last change).AfterFunclater on another goroutine, which would otherwise count the time until then.reportEndwith the end (auth.Request.OptIns).internal/auth:usage.OptInSeconds(optIn)names the metric.optin.Ofnames the egress a path opts into;internal/ingestnow uses it instead of its own copy.cli/abr.md, CHANGELOG (Added).Records of sessions that opted nothing in are unchanged, so a receiver that doesn't bill opt-ins sees what it saw before.
Testing
optInClock: live and ended announcements, two egresses, a path that is not an opt-in, an announcement that ended before it was tracked, a nil clock (-race).optin.Ofandusage.OptInSeconds.TestRelay_ReportsOptInSecondsruns a paid tenant against a relay with a usage sink.session_closerecord under the tenant's kid carriesgateway.opt_in_seconds.abrbetween 2 and 5.go test ./...passes; golangci-lint reports 0 issues; theinternal/integrationsuite passes.TestServer_DualStackBind_ReachableOverIPv6fails in this container only because it has no IPv6 loopback; CI has one.Checklist
Generated by Claude Code