Package resolver provides internal resolver-related functionality.



This section is empty.


This section is empty.


func SetConfigSelector

func SetConfigSelector(state resolver.State, cs ConfigSelector) resolver.State

SetConfigSelector sets the config selector in state and returns the new state.


type ConfigSelector

type ConfigSelector interface {
	// Selects the configuration for the RPC, or terminates it using the error.
	// This error will be converted by the gRPC library to a status error with
	// code UNKNOWN if it is not returned as a status error.
	SelectConfig(RPCInfo) (*RPCConfig, error)

ConfigSelector controls what configuration to use for every RPC.

func GetConfigSelector

func GetConfigSelector(state resolver.State) ConfigSelector

GetConfigSelector retrieves the config selector from state, if present, and returns it or nil if absent.

type RPCConfig

type RPCConfig struct {
	// The context to use for the remainder of the RPC; can pass info to LB
	// policy or affect timeout or metadata.
	Context      context.Context
	MethodConfig serviceconfig.MethodConfig // configuration to use for this RPC
	OnCommitted  func()                     // Called when the RPC has been committed (retries no longer possible)

RPCConfig describes the configuration to use for each RPC.

type RPCInfo

type RPCInfo struct {
	// Context is the user's context for the RPC and contains headers and
	// application timeout.  It is passed for interception purposes and for
	// efficiency reasons.  SelectConfig should not be blocking.
	Context context.Context
	Method  string // i.e. "/Service/Method"

RPCInfo contains RPC information needed by a ConfigSelector.

type SafeConfigSelector

type SafeConfigSelector struct {
	// contains filtered or unexported fields

SafeConfigSelector allows for safe switching of ConfigSelector implementations such that previous values are guaranteed to not be in use when UpdateConfigSelector returns.

func (*SafeConfigSelector) SelectConfig

func (scs *SafeConfigSelector) SelectConfig(r RPCInfo) (*RPCConfig, error)

SelectConfig defers to the current ConfigSelector in scs.

func (*SafeConfigSelector) UpdateConfigSelector

func (scs *SafeConfigSelector) UpdateConfigSelector(cs ConfigSelector)

UpdateConfigSelector swaps to the provided ConfigSelector and blocks until all uses of the previous ConfigSelector have completed.


Path Synopsis
dns Package dns implements a dns resolver to be installed as the default resolver in grpc.
passthrough Package passthrough implements a pass-through resolver.
unix Package unix implements a resolver for unix targets.