resolver

package
v1.7.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2017 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package resolver defines APIs for name resolution in gRPC. All APIs in this package are experimental.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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.

func SetDefaultScheme

func SetDefaultScheme(scheme string)

SetDefaultScheme sets the default scheme that will be used. The default default scheme is "dns".

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.
	// It's the name of the grpc load balancer, which will be used for authentication.
	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 {
}

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

func Get(scheme string) Builder

Get returns the resolver builder registered with the given scheme. If no builder is register with the scheme, the default scheme will be used. If the default scheme is not modified, "dns" will be the default scheme, and the preinstalled dns resolver will be used. If the default scheme is modified, and a resolver is registered with the scheme, that resolver will be returned. If the default scheme is modified, and no resolver is registered with the scheme, nil will be returned.

type ClientConn

type ClientConn 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.
	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.
	NewServiceConfig(serviceConfig string)
}

ClientConn contains the callbacks for resolver to notify any updates to the gRPC ClientConn.

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.
	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 Target

type Target struct {
	Scheme    string
	Authority string
	Endpoint  string
}

Target represents a target for gRPC, as specified in: https://github.com/grpc/grpc/blob/master/doc/naming.md.

Directories

Path Synopsis
Package dns implements a dns resolver to be installed as the default resolver in grpc.
Package dns implements a dns resolver to be installed as the default resolver in grpc.
Package manual contains a resolver for testing purpose only.
Package manual contains a resolver for testing purpose only.
Package passthrough implements a pass-through resolver.
Package passthrough implements a pass-through resolver.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL