package resolver
import "google.golang.org/grpc/resolver"
Package resolver defines APIs for name resolution in gRPC. All APIs in this package are experimental.
Index ¶
- func GetDefaultScheme() string
- func Register(b Builder)
- func SetDefaultScheme(scheme string)
- func UnregisterForTesting(scheme string)
- type Address
- type AddressType
- type BuildOption
- type Builder
- type ClientConn
- type ResolveNowOption
- type Resolver
- type State
- type Target
Functions ¶
func GetDefaultScheme ¶
func GetDefaultScheme() string
GetDefaultScheme gets the default scheme that will be used.
func Register ¶
func Register(b Builder)
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.
func SetDefaultScheme ¶
func SetDefaultScheme(scheme string)
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.
func UnregisterForTesting ¶
func UnregisterForTesting(scheme string)
UnregisterForTesting removes the resolver builder with the given scheme from the resolver map. This function is for testing only.
Types ¶
type Address ¶
type Address struct { // Addr is the server address on which a connection will be established. Addr string // Type is the type of this address. Type AddressType // ServerName is the name of this address. // // e.g. if Type is GRPCLB, ServerName should be the name of the remote load // balancer, not the name of the backend. ServerName string // Metadata is the information associated with Addr, which may be used // to make load balancing decision. Metadata interface{} }
Address represents a server the client connects to. This is the EXPERIMENTAL API and may be changed or extended in the future.
type AddressType ¶
type AddressType uint8
AddressType indicates the address type returned by name resolution.
const ( // Backend indicates the address is for a backend server. Backend AddressType = iota // GRPCLB indicates the address is for a grpclb load balancer. GRPCLB )
type BuildOption ¶
type BuildOption struct { // DisableServiceConfig indicates whether resolver should fetch service config data. DisableServiceConfig bool }
BuildOption includes additional information for the builder to create the resolver.
type Builder ¶
type Builder interface { // Build creates a new resolver for the given target. // // gRPC dial calls Build synchronously, and fails if the returned error is // not nil. Build(target Target, cc ClientConn, opts BuildOption) (Resolver, error) // Scheme returns the scheme supported by this resolver. // Scheme is defined at https://github.com/grpc/grpc/blob/master/doc/naming.md. Scheme() string }
Builder creates a resolver that will be used to watch name resolution updates.
func Get ¶
Get returns the resolver builder registered with the given scheme.
If no builder is register with the scheme, nil will be returned.
type ClientConn ¶
type ClientConn interface { // UpdateState updates the state of the ClientConn appropriately. UpdateState(State) // 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. NewAddress(addresses []Address) // 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. NewServiceConfig(serviceConfig string) }
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.
type ResolveNowOption ¶
type ResolveNowOption struct{}
ResolveNowOption includes additional information for ResolveNow.
type Resolver ¶
type Resolver interface { // 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. ResolveNow(ResolveNowOption) // Close closes the resolver. Close() }
Resolver watches for the updates on the specified target. Updates include address updates and service config updates.
type State ¶
type State struct { Addresses []Address // Resolved addresses for the target ServiceConfig string // JSON representation of the service config }
State contains the current Resolver state relevant to the ClientConn.
type Target ¶
Target represents a target for gRPC, as specified in: https://github.com/grpc/grpc/blob/master/doc/naming.md.
Source Files ¶
resolver.go
Directories ¶
Path | Synopsis |
---|---|
resolver/dns | Package dns implements a dns resolver to be installed as the default resolver in grpc. |
resolver/manual | Package manual defines a resolver that can be used to manually send resolved addresses to ClientConn. |
resolver/passthrough | Package passthrough implements a pass-through resolver. |
- Version
- v1.20.1
- Published
- Apr 18, 2019
- Platform
- linux/amd64
- Last checked
- 33 minutes ago –
Tools for package owners.