discoverychain

package
v1.15.1 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compile

Compile assembles a discovery chain in the form of a graph of nodes using raw config entries and local context.

"Node" referenced in this file refers to a node in a graph and not to the Consul construct called a "Node".

Omitting router and splitter entries for services not using an L7 protocol (like HTTP) happens during initial fetching, but for sanity purposes a quick reinforcement of that happens here, too.

May return a *structs.ConfigEntryGraphError, but that is only expected when being used to validate modifications to the config entry graph. It should not be expected when compiling existing entries at runtime that are already valid.

func TestCompileConfigEntries

func TestCompileConfigEntries(t testing.T,
	serviceName string,
	evaluateInNamespace string,
	evaluateInPartition string,
	evaluateInDatacenter string,
	evaluateInTrustDomain string,
	setup func(req *CompileRequest), entries ...structs.ConfigEntry) *structs.CompiledDiscoveryChain

Types

type CompileRequest

type CompileRequest struct {
	ServiceName           string
	EvaluateInNamespace   string
	EvaluateInPartition   string
	EvaluateInDatacenter  string
	EvaluateInTrustDomain string

	// OverrideMeshGateway allows for the setting to be overridden for any
	// resolver in the compiled chain.
	OverrideMeshGateway structs.MeshGatewayConfig

	// OverrideProtocol allows for the final protocol for the chain to be
	// altered.
	//
	// - If the chain ordinarily would be TCP and an L7 protocol is passed here
	// the chain will not include Routers or Splitters.
	//
	// - If the chain ordinarily would be L7 and TCP is passed here the chain
	// will not include Routers or Splitters.
	OverrideProtocol string

	// OverrideConnectTimeout allows for the ConnectTimeout setting to be
	// overridden for any resolver in the compiled chain.
	OverrideConnectTimeout time.Duration

	Entries *configentry.DiscoveryChainSet
}

type GatewayChainSynthesizer added in v1.15.0

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

GatewayChainSynthesizer is used to synthesize a discovery chain for a gateway from its configuration and multiple other discovery chains.

func NewGatewayChainSynthesizer added in v1.15.0

func NewGatewayChainSynthesizer(datacenter, trustDomain, suffix string, gateway *structs.APIGatewayConfigEntry) *GatewayChainSynthesizer

NewGatewayChainSynthesizer creates a new GatewayChainSynthesizer for the given gateway and datacenter.

func (*GatewayChainSynthesizer) AddHTTPRoute added in v1.15.0

func (l *GatewayChainSynthesizer) AddHTTPRoute(route structs.HTTPRouteConfigEntry)

AddHTTPRoute takes a new route and flattens its rule matches out per hostname. This is required since a single route can specify multiple hostnames, and a single hostname can be specified in multiple routes. Routing for a given hostname must behave based on the aggregate of all rules that apply to it.

func (*GatewayChainSynthesizer) AddTCPRoute added in v1.15.0

func (l *GatewayChainSynthesizer) AddTCPRoute(route structs.TCPRouteConfigEntry)

AddTCPRoute adds a TCPRoute to use in synthesizing a discovery chain

func (*GatewayChainSynthesizer) SetHostname added in v1.15.0

func (l *GatewayChainSynthesizer) SetHostname(hostname string)

SetHostname sets the base hostname for a listener that this is being synthesized for

func (*GatewayChainSynthesizer) Synthesize added in v1.15.0

Synthesize assembles a synthetic discovery chain from multiple other discovery chains that have StartNodes that are referenced by routers or splitters in the entries for the given CompileRequest.

This is currently used to help API gateways masquarade as ingress gateways by providing a set of virtual config entries that change the routing behavior to upstreams referenced in the given HTTPRoutes or TCPRoutes.

Jump to

Keyboard shortcuts

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