MCPcopy
hub / github.com/grpc/grpc-go / delegatingResolver

Struct delegatingResolver

internal/resolver/delegatingresolver/delegatingresolver.go:52–69  ·  view source on GitHub ↗

delegatingResolver manages both target URI and proxy address resolution by delegating these tasks to separate child resolvers. Essentially, it acts as an intermediary between the gRPC ClientConn and the child resolvers. It implements the [resolver.Resolver] interface.

Source from the content-addressed store, hash-verified

50//
51// It implements the [resolver.Resolver] interface.
52type delegatingResolver struct {
53 target resolver.Target // parsed target URI to be resolved
54 cc resolver.ClientConn // gRPC ClientConn
55 proxyURL *url.URL // proxy URL, derived from proxy environment and target
56
57 // We do not hold both mu and childMu in the same goroutine. Avoid holding
58 // both locks when calling into the child, as the child resolver may
59 // synchronously callback into the channel.
60 mu sync.Mutex // protects all the fields below
61 targetResolverState *resolver.State // state of the target resolver
62 proxyAddrs []resolver.Address // resolved proxy addresses; empty if no proxy is configured
63
64 // childMu serializes calls into child resolvers. It also protects access to
65 // the following fields.
66 childMu sync.Mutex
67 targetResolver resolver.Resolver // resolver for the target URI, based on its scheme
68 proxyResolver resolver.Resolver // resolver for the proxy URI; nil if no proxy is configured
69}
70
71// nopResolver is a resolver that does nothing.
72type nopResolver struct{}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected