xresolver

package
v1.11.9 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2021 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultDialer = net.Dialer{}

Functions

func NormalizeRoute added in v1.10.3

func NormalizeRoute(route string) (string, error)

NormalizeRoute canonicalizes a route string from a backend

This function performs the following on the instance:

(1) If instance is a blank string, e.g. contains only whitespace or is empty, an empty string is returned with an error
(2) If the instance with whitespace trimmed off is not a valid instance, an error is returned with the trimmed instance string.
    This function is intentionally lenient on what is a valid instance string, e.g. "foobar.com", "foobar.com:8080", "asdf://foobar.com", etc
(3) If there was no scheme prepended to the route, http will be used

Types

type ConnCreation

type ConnCreation interface {
	Dial(network, address string) (net.Conn, error)
}

type Dial

type Dial interface {
	// DialContext connects to the address on the named network using the provided context.
	DialContext(ctx context.Context, network, addr string) (con net.Conn, err error)
}

type Lookup

type Lookup interface {
	// LookupIPAddr looks up host using the local resolver. It returns a slice of that host's IPv4 and IPv6 addresses.
	LookupRoutes(ctx context.Context, host string) ([]Route, error)
}

type Resolver

type Resolver interface {
	Dial

	// Add adds the resolver to the methods of creating the IPv4 and IPv6 addresses
	Add(r Lookup) error

	// Remove removes the resolver to the methods of creating the IPv4 and IPv6 addresses
	Remove(r Lookup) error
}

Resolver represents how to generate the address and how to create the connection

func NewResolver

func NewResolver(dialer net.Dialer, logger log.Logger, lookups ...Lookup) Resolver

type RoundRobin

type RoundRobin struct {
	// contains filtered or unexported fields
}

func NewRoundRobinBalancer

func NewRoundRobinBalancer() *RoundRobin

func (*RoundRobin) Add

func (robin *RoundRobin) Add(route Route) error

func (*RoundRobin) Get

func (robin *RoundRobin) Get() ([]Route, error)

func (*RoundRobin) Remove

func (robin *RoundRobin) Remove(route Route) error

func (*RoundRobin) Update

func (robin *RoundRobin) Update(routes []Route)

type Route

type Route struct {
	Scheme string
	Host   string
	Port   int
}

func CreateRoute

func CreateRoute(route string) (Route, error)

func (Route) String

func (r Route) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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