route

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2022 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DestinationClusterName

func DestinationClusterName(
	d *Destination,
	identifyingTags map[string]string,
) (string, error)

DestinationClusterName generates a unique cluster name for the destination. The destination must contain at least a service tag.

func FilterProtocols

FilterProtocols returns only the routes a listener of this protocol knows how to configure.

func HasExternalServiceEndpoint

func HasExternalServiceEndpoint(mesh *core_mesh.MeshResource, endpoints core_xds.EndpointMap, d Destination) bool

func InferForwardingProtocol

func InferForwardingProtocol(destinations []Destination) core_mesh.Protocol

func InferServiceProtocol

func InferServiceProtocol(endpoints []core_xds.Endpoint, routeProtocol core_mesh.Protocol) core_mesh.Protocol

func VirtualHostRoute

func VirtualHostRoute(route *RouteBuilder) envoy_routes.VirtualHostBuilderOpt

VirtualHostRoute creates an option to add the route builder to a virtual host. On execution, the builder will build the route and append it to the virtual host. Since Envoy evaluates route matches in order, route builders should be configured on virtual hosts in the intended match order.

Types

type Action

type Action struct {
	Forward  []Destination
	Redirect *Redirection
	Respond  struct{} // TODO(jpeach) add DirectResponseAction support
}

Action describes how a HTTP request should be dispatched.

type Destination

type Destination struct {
	Destination   envoy.Tags
	Weight        uint32
	RouteProtocol core_mesh.Protocol

	// Name is the globally unique name for this destination instance.
	// It takes into account not only the service that it targets, but
	// also the configuration context.
	Name string

	// Kuma connection policies for traffic forwarded to
	// this destination.
	Policies map[model.ResourceType]model.Resource
}

Destination is a forwarding target (aka Cluster).

type Entry

type Entry struct {
	Route  string
	Match  Match
	Action Action

	// Mirror specifies whether to mirror matching traffic.
	Mirror *Mirror

	// RequestHeaders specifies transformations on the HTTP
	// request headers.
	RequestHeaders *Headers

	Rewrite *Rewrite
}

Entry is a single routing element. Incoming requests are matched by Match and dispatched according to the Action. Other optional field specify additional processing.

type Headers

type Headers struct {
	// Append adds a value to a HTTP header field.
	Append []KeyValue
	// Replace adds a value to a HTTP header field, removing all other
	// values for that field.
	Replace []KeyValue
	// Delete deletes a HTTP header field.
	Delete []string
}

Headers is a set of operations to perform on HTTP message headers.

type KeyValue

type KeyValue struct {
	Key   string
	Value string
}

KeyValue is a generic pairing of key and value strings. Route table elements generally use this in preference to maps so that input ordering is preserved and output does not change based on map iteration order.

func Pair

func Pair(key string, value string) KeyValue

Pair combines key and value into a KeyValue.

type Match

type Match struct {
	ExactPath  string
	PrefixPath string
	RegexPath  string

	Method string

	ExactHeader []KeyValue // name -> value
	RegexHeader []KeyValue // name -> regex

	ExactQuery []KeyValue // param -> value
	RegexQuery []KeyValue // param -> regex
}

Match describes how to match a HTTP request.

type Mirror

type Mirror struct {
	Forward    Destination
	Percentage float64
}

Mirror specifies a traffic mirroring operation.

type Redirection

type Redirection struct {
	Status uint32 // HTTP status code.
	Scheme string // URL scheme (optional).
	Host   string // URL host (optional).
	Port   uint32 // URL port (optional).
	Path   string // URL path (optional).

	StripQuery bool // Whether to strip the query string.
}

Redirection is an action that responds to a HTTP request with a HTTP redirect response.

type Rewrite

type Rewrite struct {
	ReplaceFullPath *string

	ReplacePrefixMatch *string
}

type RouteBuilder

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

func (*RouteBuilder) Build

func (r *RouteBuilder) Build() (envoy.NamedResource, error)

func (*RouteBuilder) Configure

func (r *RouteBuilder) Configure(opts ...RouteConfigurer) *RouteBuilder

type RouteConfigureFunc

type RouteConfigureFunc func(*envoy_config_route.Route) error

func (RouteConfigureFunc) Configure

type RouteConfigurer

type RouteConfigurer interface {
	Configure(*envoy_config_route.Route) error
}

func RouteActionDirectResponse

func RouteActionDirectResponse(status uint32, respStr string) RouteConfigurer

RouteActionDirectResponse sets the direct response for a route

func RouteActionForward

func RouteActionForward(mesh *core_mesh.MeshResource, endpoints core_xds.EndpointMap, proxyTags mesh_proto.MultiValueTagSet, destinations []Destination) RouteConfigurer

RouteActionForward configures the route to forward traffic to the given destinations, with the appropriate weights. This replaces any previous action specification.

func RouteActionGrpcRetryOn

func RouteActionGrpcRetryOn(retryOn []mesh_proto.Retry_Conf_Grpc_RetryOn) RouteConfigurer

RouteActionGrpcRetryOn configure retry on for grpc

func RouteActionHttpRetryOn

func RouteActionHttpRetryOn(retryOn []mesh_proto.HttpRetryOn) RouteConfigurer

RouteActionHttpRetryOn configure retry on for http

func RouteActionRedirect

func RouteActionRedirect(redirect *Redirection) RouteConfigurer

RouteActionRedirect configures the route to automatically response with a HTTP redirection. This replaces any previous action specification.

func RouteActionRequestTimeout

func RouteActionRequestTimeout(timeout time.Duration) RouteConfigurer

RouteActionRequestTimeout sets the total timeout for an upstream request.

func RouteActionRetryBackoff

func RouteActionRetryBackoff(interval time.Duration, max time.Duration) RouteConfigurer

RouteActionRetryBackoff sets the backoff policy for retries.

func RouteActionRetryCount

func RouteActionRetryCount(numRetries uint32) RouteConfigurer

RouteActionRetryCount sets the number of retries to attempt.

func RouteActionRetryDefault

func RouteActionRetryDefault(protocol core_mesh.Protocol) RouteConfigurer

RouteActionRetryDefault initializes the retry policy with defaults appropriate for the protocol.

func RouteActionRetryMethods

func RouteActionRetryMethods(httpMethod ...string) RouteConfigurer

RouteActionRetryMethods sets the HTTP methods that should trigger retries.

func RouteActionRetryOnConditions

func RouteActionRetryOnConditions(conditionNames ...string) RouteConfigurer

RouteActionRetryOnConditions sets the Envoy condition names for triggering retries.

func RouteActionRetryOnStatus

func RouteActionRetryOnStatus(httpStatus ...uint32) RouteConfigurer

RouteActionRetryOnStatus sets the HTTP status codes for triggering retries.

func RouteActionRetryTimeout

func RouteActionRetryTimeout(perTryTimeout time.Duration) RouteConfigurer

RouteActionRetryTimeout sets the per-try retry timeout.

func RouteAppendRequestHeader

func RouteAppendRequestHeader(name string, value string) RouteConfigurer

RouteAppendRequestHeader appends the given value to the existing values of the given header.

func RouteDeleteRequestHeader

func RouteDeleteRequestHeader(name string) RouteConfigurer

RouteDeleteRequestHeader deletes the given header from the HTTP request.

func RouteMatchExactHeader

func RouteMatchExactHeader(name string, value string) RouteConfigurer

RouteMatchExactHeader appends an exact match for the value of the named HTTP request header.

func RouteMatchExactPath

func RouteMatchExactPath(path string) RouteConfigurer

RouteMatchExactPath updates the route to match the exact path. This replaces any previous path match specification.

func RouteMatchExactQuery

func RouteMatchExactQuery(name string, value string) RouteConfigurer

RouteMatchExactQuery appends an exact match for the value of the named query parameter.

func RouteMatchPrefixPath

func RouteMatchPrefixPath(prefix string) RouteConfigurer

RouteMatchPrefixPath updates the route to match the given path prefix. This is a byte-wise prefix, so it just checks that the request path begins with the given string. This replaces any previous path match specification.

func RouteMatchRegexHeader

func RouteMatchRegexHeader(name string, regex string) RouteConfigurer

RouteMatchRegexHeader appends a regex match for the value of the named HTTP request header.

func RouteMatchRegexPath

func RouteMatchRegexPath(regex string) RouteConfigurer

RouteMatchRegexPath updates the route to match the path using the given regex. This replaces any previous path match specification.

func RouteMatchRegexQuery

func RouteMatchRegexQuery(name string, regex string) RouteConfigurer

RouteMatchRegexQuery appends a regex match for the value of the named query parameter.

func RouteMirror

func RouteMirror(percent float64, destination Destination) RouteConfigurer

RouteMirror enables traffic mirroring on the route. It is an error to enable mirroring if the route is not forwarding. The route action must be configured beforehand.

func RoutePerFilterConfig

func RoutePerFilterConfig(filterName string, filterConfig *any.Any) RouteConfigurer

RoutePerFilterConfig sets an optional per-filter configuration message for this route. filterName is the name of the filter that should receive the configuration that is specified in filterConfig

func RouteReplaceHostHeader

func RouteReplaceHostHeader(host string) RouteConfigurer

RouteReplaceHostHeader replaces the Host header on the forwarded request. It is an error to rewrite the header if the route is not forwarding. The route action must be configured beforehand.

func RouteReplaceRequestHeader

func RouteReplaceRequestHeader(name string, value string) RouteConfigurer

RouteReplaceRequestHeader replaces all values of the given header with the given value.

func RouteRewrite

func RouteRewrite(rewrite *Rewrite) RouteConfigurer

type RouteMustConfigureFunc

type RouteMustConfigureFunc func(*envoy_config_route.Route)

func (RouteMustConfigureFunc) Configure

type Sorter

type Sorter []Entry

func (Sorter) Len

func (s Sorter) Len() int

func (Sorter) Less

func (s Sorter) Less(i, j int) bool

func (Sorter) Swap

func (s Sorter) Swap(i, j int)

type Table

type Table struct {
	Entries []Entry
}

Table stores a collection of routing Entries, aka. a routing table.

A route table is a simplified model of a collection of Envoy routes. Although extracting a model is duplicative of the actual Envoy model, this approach makes it possible to support different APIs that combine to make a coherent routing table.

The different elements of the routing table are deliberately defined without any behavior or internal consistency checks. The API that generates these elements should apply validation to ensure that it generates route table elements that make sense and accurately capture the right semantics.

Jump to

Keyboard shortcuts

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