rpc: gate the claim skip process-wide for every server - #1729
Conversation
Wires psrpc's WithServerSkipClaim into WithServerObservability, which is the one seam every server constructor shares -- WithDefaultServerOptions calls it, and the constructors that take only a logger reach it too. The setting is process-wide because the claim is a transport policy rather than a per-service one, and it is read per request so callers may set it before or after their servers exist and revoke it without a redeploy. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
| return p.Bus, psrpc.WithClientOptions(p.Options()...) | ||
| } | ||
|
|
||
| var serverSkipClaim atomic.Pointer[func() bool] |
There was a problem hiding this comment.
maybe rename this to psrpcServerSkipClaim. I don't think it is super clear even then, but there are so many references to server and client everywhere, hoping it makes at least a bit clearer. And the function names change to PsRPCSetServerSkipClaim etc.
There was a problem hiding this comment.
Done in 7674583 — went with SetPSRPCServerSkipClaim / psrpcServerSkipClaim rather than PsRPCSetServerSkipClaim: this package already spells the initialism PSRPC (PSRPCConfig, PSRPCMetricsObserver), and the verb-first setter matches Go convention. Cloud's call site updated in its PR.
Server and client mean too many things in this package for a bare SetServerSkipClaim to read clearly. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Summary
Wires psrpc's new
WithServerSkipClaim(livekit/psrpc#122) intoWithServerObservability.WithServerObservabilityis the one seam every server constructor shares:WithDefaultServerOptionscalls it, and the constructors that take only a loggerreach it too. In cloud that is 33 server sites — 23 via
WithDefaultServerOptionsand 10 via
WithServerObservabilitydirectly — covered by a single edit.The setting is process-wide rather than per-service because the claim is a
transport policy, and it is read per request, so callers may set it before or
after their servers are constructed and revoke it at runtime without a redeploy.
Why not per-config
WithDefaultServerOptionsalready receivesPSRPCConfig, so a field there wasthe obvious home — but
PSRPCConfigis passed by value at construction, whichwould lose the runtime kill switch that motivated the client-side version
(livekit/cloud#4567). It also would not reach the 10 logger-only sites. A
process-wide setter keeps both properties.
Verification
go build ./...— cleango test -race ./rpc/... ./utils/...— passesTestServerSkipClaimcovers the three properties the call sites depend on:unset means claim, the func is consulted per call rather than captured, and it
stays revocable.
Depends on
livekit/psrpc#122 — merged and released as v0.7.5, which
go.modnow pins.Ready to land.
Note the merged psrpc PR evolved past the revision this description was first
written against: the client option was removed in favor of an always-on
advertisement (new field number, old one reserved), so the server election wired
here is the only switch.
🤖 Generated with Claude Code