Involved Source Filesmap.go
Package resolver defines APIs for name resolution in gRPC.
All APIs in this package are experimental.
Package-Level Type Names (total 12, in which 10 are exported)
/* sort exporteds by: | */
Address represents a server the client connects to.
# Experimental
Notice: This type is EXPERIMENTAL and may be changed or removed in a
later release.
Addr is the server address on which a connection will be established.
Attributes contains arbitrary data about this address intended for
consumption by the SubConn.
BalancerAttributes contains arbitrary data about this address intended
for consumption by the LB policy. These attribes do not affect SubConn
creation, connection establishment, handshaking, etc.
Metadata is the information associated with Addr, which may be used
to make load balancing decision.
Deprecated: use Attributes instead.
ServerName is the name of this address.
If non-empty, the ServerName is used as the transport certification authority for
the address, instead of the hostname from the Dial target string. In most cases,
this should not be set.
If Type is GRPCLB, ServerName should be the name of the remote load
balancer, not the name of the backend.
WARNING: ServerName must only be populated with trusted values. It
is insecure to populate it with data from untrusted inputs since untrusted
values could be used to bypass the authority checks performed by TLS.
Type is the type of this address.
Deprecated: use Attributes instead.
Equal returns whether a and o are identical. Metadata is compared directly,
not with any recursive introspection.
String returns JSON formatted string representation of the address.
Address : expvar.Var
Address : fmt.Stringer
Address : context.stringer
Address : github.com/aws/smithy-go/middleware.stringer
Address : runtime.stringer
func (*AddressMap).Keys() []Address
func google.golang.org/grpc/internal.SetXDSHandshakeClusterName(addr Address, clusterName string) Address
func google.golang.org/grpc/internal/metadata.Set(addr Address, md metadata.MD) Address
func google.golang.org/grpc/internal/transport/networktype.Set(address Address, networkType string) Address
func toMapKey(addr *Address) Address
func Address.Equal(o Address) bool
func (*AddressMap).Delete(addr Address)
func (*AddressMap).Get(addr Address) (value interface{}, ok bool)
func (*AddressMap).Set(addr Address, value interface{})
func ClientConn.NewAddress(addresses []Address)
func google.golang.org/grpc/balancer.ClientConn.NewSubConn([]Address, balancer.NewSubConnOptions) (balancer.SubConn, error)
func google.golang.org/grpc/balancer.ClientConn.UpdateAddresses(balancer.SubConn, []Address)
func google.golang.org/grpc/balancer.SubConn.UpdateAddresses([]Address)
func google.golang.org/grpc/internal.SetXDSHandshakeClusterName(addr Address, clusterName string) Address
func google.golang.org/grpc/internal/metadata.Get(addr Address) metadata.MD
func google.golang.org/grpc/internal/metadata.Set(addr Address, md metadata.MD) Address
func google.golang.org/grpc/internal/transport.NewClientTransport(connectCtx, ctx context.Context, addr Address, opts transport.ConnectOptions, onClose func(transport.GoAwayReason)) (transport.ClientTransport, error)
func google.golang.org/grpc/internal/transport/networktype.Get(address Address) (string, bool)
func google.golang.org/grpc/internal/transport/networktype.Set(address Address, networkType string) Address
func toMapKey(addr *Address) Address
func google.golang.org/grpc.equalAddresses(a, b []Address) bool
func google.golang.org/grpc.(*ClientConn).applyServiceConfigAndBalancer(sc *grpc.ServiceConfig, configSelector iresolver.ConfigSelector, addrs []Address)
func google.golang.org/grpc.(*ClientConn).getServerName(addr Address) string
func google.golang.org/grpc.(*ClientConn).maybeApplyDefaultServiceConfig(addrs []Address)
func google.golang.org/grpc.(*ClientConn).newAddrConn(addrs []Address, opts balancer.NewSubConnOptions) (*grpc.addrConn, error)
func google.golang.org/grpc/internal/transport.dial(ctx context.Context, fn func(context.Context, string) (net.Conn, error), addr Address, useProxy bool, grpcUA string) (net.Conn, error)
func google.golang.org/grpc/internal/transport.newHTTP2Client(connectCtx, ctx context.Context, addr Address, opts transport.ConnectOptions, onClose func(transport.GoAwayReason)) (_ *transport.http2Client, err error)
AddressMap is a map of addresses to arbitrary values taking into account
Attributes. BalancerAttributes are ignored, as are Metadata and Type.
Multiple accesses may not be performed concurrently. Must be created via
NewAddressMap; do not construct directly.
The underlying map is keyed by an Address with fields that we don't care
about being set to their zero values. The only fields that we care about
are `Addr`, `ServerName` and `Attributes`. Since we need to be able to
distinguish between addresses with same `Addr` and `ServerName`, but
different `Attributes`, we cannot store the `Attributes` in the map key.
The comparison operation for structs work as follows:
Struct values are comparable if all their fields are comparable. Two
struct values are equal if their corresponding non-blank fields are equal.
The value type of the map contains a slice of addresses which match the key
in their `Addr` and `ServerName` fields and contain the corresponding value
associated with them.
Delete removes addr from the map.
Get returns the value for the address in the map, if present.
Keys returns a slice of all current map keys.
Len returns the number of entries in the map.
Set updates or adds the value to the address in the map.
Values returns a slice of all current map values.
func NewAddressMap() *AddressMap
AddressType indicates the address type returned by name resolution.
Deprecated: use Attributes in Address instead.
const Backend
const GRPCLB
Builder creates a resolver that will be used to watch name resolution updates.
Build creates a new resolver for the given target.
gRPC dial calls Build synchronously, and fails if the returned error is
not nil.
Scheme returns the scheme supported by this resolver.
Scheme is defined at https://github.com/grpc/grpc/blob/master/doc/naming.md.
*google.golang.org/grpc/internal/resolver/dns.dnsBuilder
*google.golang.org/grpc/internal/resolver/passthrough.passthroughBuilder
*google.golang.org/grpc/internal/resolver/unix.builder
func Get(scheme string) Builder
func google.golang.org/grpc/internal/resolver/dns.NewBuilder() Builder
func google.golang.org/grpc.(*ClientConn).getResolver(scheme string) Builder
func google.golang.org/grpc.(*ClientConn).parseTargetAndFindResolver() (Builder, error)
func Register(b Builder)
func google.golang.org/grpc.WithResolvers(rs ...Builder) grpc.DialOption
func google.golang.org/grpc.newCCResolverWrapper(cc *grpc.ClientConn, rb Builder) (*grpc.ccResolverWrapper, error)
BuildOptions includes additional information for the builder to create
the resolver.
CredsBundle is the credentials bundle used by the ClientConn for
communicating with the target gRPC service (set via
WithCredentialsBundle). In cases where a name resolution service
requires the same credentials, the resolver may use this field. In most
cases though, it is not appropriate, and this field may be ignored.
DialCreds is the transport credentials used by the ClientConn for
communicating with the target gRPC service (set via
WithTransportCredentials). In cases where a name resolution service
requires the same credentials, the resolver may use this field. In most
cases though, it is not appropriate, and this field may be ignored.
Dialer is the custom dialer used by the ClientConn for dialling the
target gRPC service (set via WithDialer). In cases where a name
resolution service requires the same dialer, the resolver may use this
field. In most cases though, it is not appropriate, and this field may
be ignored.
DisableServiceConfig indicates whether a resolver implementation should
fetch service config data.
func Builder.Build(target Target, cc ClientConn, opts BuildOptions) (Resolver, error)
ClientConn contains the callbacks for resolver to notify any updates
to the gRPC ClientConn.
This interface is to be implemented by gRPC. Users should not need a
brand new implementation of this interface. For the situations like
testing, the new implementation should embed this interface. This allows
gRPC to add new methods to this interface.
NewAddress is called by resolver to notify ClientConn a new list
of resolved addresses.
The address list should be the complete list of resolved addresses.
Deprecated: Use UpdateState instead.
NewServiceConfig is called by resolver to notify ClientConn a new
service config. The service config should be provided as a json string.
Deprecated: Use UpdateState instead.
ParseServiceConfig parses the provided service config and returns an
object that provides the parsed config.
ReportError notifies the ClientConn that the Resolver encountered an
error. The ClientConn will notify the load balancer and begin calling
ResolveNow on the Resolver with exponential backoff.
UpdateState updates the state of the ClientConn appropriately.
*google.golang.org/grpc.ccResolverWrapper
func Builder.Build(target Target, cc ClientConn, opts BuildOptions) (Resolver, error)
ResolveNowOptions includes additional information for ResolveNow.
func Resolver.ResolveNow(ResolveNowOptions)
func google.golang.org/grpc/balancer.ClientConn.ResolveNow(ResolveNowOptions)
func google.golang.org/grpc.(*ClientConn).resolveNow(o ResolveNowOptions)
Resolver watches for the updates on the specified target.
Updates include address updates and service config updates.
Close closes the resolver.
ResolveNow will be called by gRPC to try to resolve the target name
again. It's just a hint, resolver can ignore this if it's not necessary.
It could be called multiple times concurrently.
*google.golang.org/grpc/internal/balancer/gracefulswitch.balancerWrapper
google.golang.org/grpc/internal/resolver/dns.deadResolver
*google.golang.org/grpc/internal/resolver/dns.dnsResolver
*google.golang.org/grpc/internal/resolver/passthrough.passthroughResolver
*google.golang.org/grpc/internal/resolver/unix.nopResolver
func Builder.Build(target Target, cc ClientConn, opts BuildOptions) (Resolver, error)
State contains the current Resolver state relevant to the ClientConn.
Addresses is the latest set of resolved addresses for the target.
Attributes contains arbitrary data about the resolver intended for
consumption by the load balancing policy.
ServiceConfig contains the result from parsing the latest service
config. If it is nil, it indicates no service config is present or the
resolver does not provide service configs.
func google.golang.org/grpc/balancer/grpclb/state.Set(state State, s *state.State) State
func google.golang.org/grpc/internal/resolver.SetConfigSelector(state State, cs resolver.ConfigSelector) State
func ClientConn.UpdateState(State) error
func google.golang.org/grpc/balancer/grpclb/state.Get(state State) *state.State
func google.golang.org/grpc/balancer/grpclb/state.Set(state State, s *state.State) State
func google.golang.org/grpc/internal/resolver.GetConfigSelector(state State) resolver.ConfigSelector
func google.golang.org/grpc/internal/resolver.SetConfigSelector(state State, cs resolver.ConfigSelector) State
func google.golang.org/grpc.(*ClientConn).updateResolverState(s State, err error) error
Target represents a target for gRPC, as specified in:
https://github.com/grpc/grpc/blob/master/doc/naming.md.
It is parsed from the target string that gets passed into Dial or DialContext
by the user. And gRPC passes it to the resolver and the balancer.
If the target follows the naming spec, and the parsed scheme is registered
with gRPC, we will parse the target string according to the spec. If the
target does not contain a scheme or if the parsed scheme is not registered
(i.e. no corresponding resolver available to resolve the endpoint), we will
apply the default scheme, and will attempt to reparse it.
Examples:
- "dns://some_authority/foo.bar"
Target{Scheme: "dns", Authority: "some_authority", Endpoint: "foo.bar"}
- "foo.bar"
Target{Scheme: resolver.GetDefaultScheme(), Endpoint: "foo.bar"}
- "unknown_scheme://authority/endpoint"
Target{Scheme: resolver.GetDefaultScheme(), Endpoint: "unknown_scheme://authority/endpoint"}
Deprecated: use URL.Host instead.
Deprecated: use URL.Scheme instead.
URL contains the parsed dial target with an optional default scheme added
to it if the original dial target contained no scheme or contained an
unregistered scheme. Any query params specified in the original dial
target can be accessed from here.
Endpoint retrieves endpoint without leading "/" from either `URL.Path`
or `URL.Opaque`. The latter is used when the former is empty.
func google.golang.org/grpc.parseTarget(target string) (Target, error)
func Builder.Build(target Target, cc ClientConn, opts BuildOptions) (Resolver, error)
find returns the index of addr in the addressMapEntry slice, or -1 if not
present.
Package-Level Functions (total 7, in which 6 are exported)
Get returns the resolver builder registered with the given scheme.
If no builder is register with the scheme, nil will be returned.
GetDefaultScheme gets the default scheme that will be used.
NewAddressMap creates a new AddressMap.
Register registers the resolver builder to the resolver map. b.Scheme will be
used as the scheme registered with this builder.
NOTE: this function must only be called during initialization time (i.e. in
an init() function), and is not thread-safe. If multiple Resolvers are
registered with the same name, the one registered last will take effect.
SetDefaultScheme sets the default scheme that will be used. The default
default scheme is "passthrough".
NOTE: this function must only be called during initialization time (i.e. in
an init() function), and is not thread-safe. The scheme set last overrides
previously set values.
UnregisterForTesting removes the resolver builder with the given scheme from the
resolver map.
This function is for testing only.
Package-Level Variables (total 2, neither is exported)
defaultScheme is the default scheme to use.
m is a map from scheme to resolver builder.
Package-Level Constants (total 2, both are exported)
Backend indicates the address is for a backend server.
Deprecated: use Attributes in Address instead.
GRPCLB indicates the address is for a grpclb load balancer.
Deprecated: to select the GRPCLB load balancing policy, use a service
config with a corresponding loadBalancingConfig. To supply balancer
addresses to the GRPCLB load balancing policy, set State.Attributes
using balancer/grpclb/state.Set.
The pages are generated with Goldsv0.4.9. (GOOS=linux GOARCH=amd64)