kedge_map

package
v1.0.0-alpha.test.10 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotKedgeDestination = errors.New("not a kedge destination")
)

Functions

func RouteMapper

func RouteMapper(r []RouteGetter) *routeMapper

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

Types

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