kedge_map

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNotKedgeDestinationError

func IsNotKedgeDestinationError(err error) bool

func NotKedgeDestinationErr

func NotKedgeDestinationErr(host string, port string) error

func RouteMapper

func RouteMapper(r []RouteGetter) *routeMapper

RouteMapper is a mapper that resolves Route based on given DNS.

Types

type ErrorNotKedgeDestination

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

ErrorKedgeDestination displays that host/port is not a kedge destination. We are not using errors.New, because sometimes we need to check for type of the error (for example in winch/grpc/proxy.go).

func (ErrorNotKedgeDestination) Error

func (e ErrorNotKedgeDestination) Error() string

type Mapper

type Mapper interface {
	// Map maps a target's DNS name and optional port (e.g. myservice.prod.ext.europe-cluster.local and 80) to a Route.
	// If the targets shouldn't be proxied, ErrNotKedgeDestination should be returned.
	Map(targetAuthorityDnsName string, port string) (*Route, error)
}

Mapper is an interface that allows you to direct traffic to different kedges including various auth. These are used by client libraries.

func SimpleHost

func SimpleHost(mapping map[string]*Route) Mapper

SimpleHost is a kedge mapper that returns route based on map provided in constructor. It does not care about port.

func SimpleHostPort

func SimpleHostPort(mapping map[string]*Route) Mapper

SimpleHostPort is a kedge mapper that returns route based on map provided in constructor.

func Single

func Single(kedgeUrl *url.URL) Mapper

Single is a simplistic kedge mapper that forwards all traffic through the same kedge. No auth is involved.

func SingleWithProxyAuth

func SingleWithProxyAuth(kedgeUrl *url.URL, proxyAuth tokenauth.Source) Mapper

SingleWithProxyAuth is kedge mapper that always returns predefined route with given Proxy auth and no backend auth. Used for loadtest.

func Suffix

func Suffix(matchPattern string, suffix string, scheme string) (Mapper, error)

Suffix is a `kedge.Mapper` that copies over wildcarded parts of a URL.

For example: given a matchPattern of *.*.clusters.local, and a URL of `myservice.mynamespace.svc.us1.prod.clusters.local` and a suffixMapper of `.clusters.example.com`, it will return a kedge url of `us1.prod.clusters.example.com`.

NOTE: It does not care about port.

Scheme needs to be `http` or `https`

type Route

type Route struct {
	// URL specifies public URL to the Kedge fronting route destination.
	// The returned Scheme is deciding whether the Kedge connection is secure.
	URL *url.URL

	// BackendAuth represents optional auth for end application. Sometimes it is required to be injected here, because of common
	// restriction blocking auth headers in plain HTTP requests (even when communication locally with local forward proxy).
	BackendAuth tokenauth.Source
	// ProxyAuth represents optional auth for kedge.
	ProxyAuth tokenauth.Source
}

type RouteGetter

type RouteGetter interface {
	Route(hostPort string) (*Route, bool, error)
}

Jump to

Keyboard shortcuts

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