builder

package
v1.22.21 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: Zlib Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const KDefBuild = "/"

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	// Addr is the server address on which a connection will be established.
	Addr string

	// 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 Method 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.
	ServerName string

	// Attributes contains arbitrary data about this address intended for
	// consumption by the load balancing policy.
	Attributes *attributes.Attributes

	// Weight sort max in front
	Weight int64
}

Address Notice: This type is EXPERIMENTAL and may be changed or removed in a later release.

type Addresses added in v1.1.9

type Addresses []Address

func (Addresses) Len added in v1.1.9

func (a Addresses) Len() int

func (Addresses) Less added in v1.1.9

func (a Addresses) Less(i, j int) bool

Less 权重大的在前面

func (Addresses) Swap added in v1.1.9

func (a Addresses) Swap(i, j int)

func (Addresses) ToWeight added in v1.1.9

func (a Addresses) ToWeight()

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 Connector) (Resolver, error)

	// Scheme returns the scheme supported by this resolver.
	Scheme() string

	Type() string
}

Builder creates a resolver that will be used to watch name resolution updates.

type Connector

type Connector interface {
	// UpdateState updates the state of the ClientConn appropriately.
	UpdateState(State)

	// 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.
	ReportError(error)
}

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()

	// 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 is the latest set of resolved addresses for the target.
	Addresses Addresses

	// Attributes contains arbitrary data about the resolver intended for
	// consumption by the load balancing policy.
	Attributes *attributes.Attributes
}

State contains the current Resolver state relevant to the ClientConn.

type Target

type Target struct {
	// "grpc", "thrift", "local"...
	Type      string `json:"type"`
	Scheme    string `json:"scheme"`
	Authority string `json:"authority"`
	Endpoint  string `json:"endpoint"`
}

Target

  • "dns://some_authority/foo.bar" Target{Scheme: "dns", Authority: "some_authority", Endpoint: "foo.bar"}

func ParseTarget

func ParseTarget(target string) (ret Target)

ParseTarget splits target into a resolver.Target struct containing scheme, authority and endpoint.

If target is not a valid scheme://authority/endpoint, it returns {Endpoint: target}.

func TargetWith

func TargetWith(ty, scheme, authority, endpoint string) Target

func TargetWithGrpc

func TargetWithGrpc(scheme, authority, endpoint string) Target

func TargetWithLocal

func TargetWithLocal(scheme, authority, endpoint string) Target

func TargetWithThrift

func TargetWithThrift(scheme, authority, endpoint string) Target

func (*Target) NameWith

func (target *Target) NameWith(build string) string

func (*Target) SchemeWith

func (target *Target) SchemeWith(build string) string

Jump to

Keyboard shortcuts

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