xds/clients: future-proof exported interfaces and add non-comparable struct guards
Author: dashpoleCreated Sep 30, 2026Updated Sep 30, 2026
Use case(s) - what problem will this feature solve?
Once internal/xds/clients is moved to a public import path:
- Exported interfaces implemented by external callers (
ResourceWatcher,Decoder,TransportBuilder,Transport,Stream,MetricsReporter) cannot gain new methods in futurev1.xreleases without breaking existing implementations. - Exported structs (
Config,Authority,ServerConfig,ResourceType,DecodeOptions,DecodeResult) can be compared with==or used as map keys by callers unless explicitly prevented, which makes adding a slice, map, orfuncfield to those structs in a future minor release a breaking change.
Proposed Solution
- Follow the pattern used by
grpc-gogenerated server interfaces (Unimplemented...Server) andexperimental/stats.MetricsRecorder(UnimplementedMetricsRecorder+internal.Enforce...Embedding): provide an embeddableUnimplemented...struct with no-op default methods and an unexported marker method on interfaces implemented by callers where future methods may be added. - Embed
_ [0]func()(zero-size non-comparable field) in exported configuration and parameter structs (Config,Authority,ResourceType,DecodeOptions,DecodeResult) once internal maps no longer key onResourceType, ensuring callers do not rely on struct comparability.
Alternatives Considered
Relying on documentation comments warning callers not to compare structs or implement interfaces without embedding. Compile-time guards prevent accidental breakage across minor releases.
Additional Context
Part of #9455.
Source: grpc/grpc-go