contour

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package contour contains the translation business logic that listens to Kubernetes ResourceEventHandler events and translates those into additions/deletions in caches connected to the Envoy xDS gRPC API server.

Index

Examples

Constants

View Source
const (
	ENVOY_HTTP_LISTENER            = "ingress_http"
	ENVOY_HTTPS_LISTENER           = "ingress_https"
	DEFAULT_HTTP_LISTENER_ADDRESS  = "0.0.0.0"
	DEFAULT_HTTP_LISTENER_PORT     = 8080
	DEFAULT_HTTPS_LISTENER_ADDRESS = DEFAULT_HTTP_LISTENER_ADDRESS
	DEFAULT_HTTPS_LISTENER_PORT    = 8443
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterCache

type ClusterCache struct {
	Cond
	// contains filtered or unexported fields
}

ClusterCache manage the contents of the gRPC SDS cache.

func (*ClusterCache) Add added in v0.3.0

func (cc *ClusterCache) Add(clusters ...*v2.Cluster)

Add adds an entry to the cache. If a Cluster with the same name exists, it is replaced.

func (*ClusterCache) Remove added in v0.3.0

func (cc *ClusterCache) Remove(names ...string)

Remove removes the named entry from the cache. If the entry is not present in the cache, the operation is a no-op.

func (*ClusterCache) Values

func (cc *ClusterCache) Values() []*v2.Cluster

Values returns a copy of the contents of the cache.

type ClusterLoadAssignmentCache

type ClusterLoadAssignmentCache struct {
	Cond
	// contains filtered or unexported fields
}

ClusterLoadAssignmentCache manage the contents of the gRPC EDS cache.

func (*ClusterLoadAssignmentCache) Add added in v0.3.0

func (c *ClusterLoadAssignmentCache) Add(assignments ...*v2.ClusterLoadAssignment)

Add adds an entry to the cache. If a ClusterLoadAssignment with the same name exists, it is replaced.

func (*ClusterLoadAssignmentCache) Remove added in v0.3.0

func (c *ClusterLoadAssignmentCache) Remove(names ...string)

Remove removes the named entry from the cache. If the entry is not present in the cache, the operation is a no-op.

func (*ClusterLoadAssignmentCache) Values

func (c *ClusterLoadAssignmentCache) Values() []*v2.ClusterLoadAssignment

Values returns a copy of the contents of the cache.

type Cond added in v0.3.0

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

Cond implements a condition variable, a rendezvous point for goroutines waiting for or announcing the occurence of an event.

Unlike sync.Cond, Cond communciates with waiters via channels registered by the waiters. This permits goroutines to wait on Cond events using select.

Example
package main

import (
	"context"
	"fmt"
	"time"

	"github.com/heptio/contour/internal/contour"
)

func main() {
	ctx, _ := context.WithTimeout(context.Background(), 1*time.Second)
	ch := make(chan int, 1)
	last := 0
	var c contour.Cond
	go func() {
		for {
			time.Sleep(100 * time.Millisecond)
			c.Notify()
		}
	}()

	for {
		c.Register(ch, last)
		select {
		case last = <-ch:
			fmt.Println("notification received:", last)
		case <-ctx.Done():
			fmt.Println("timeout")
			return
		}
	}
}
Output:

func (*Cond) Notify added in v0.3.0

func (c *Cond) Notify()

Notify notifies all registered waiters that an event has occured.

func (*Cond) Register added in v0.3.0

func (c *Cond) Register(ch chan int, last int)

Register registers ch to receive a value when Notify is called. The value of last is the count of the times Notify has been called on this Cond. It functions of a sequence counter, if the value of last supplied to Register is less than the Conds internal counter, then the caller has missed at least one notification and will fire immediately.

Sends by the broadcaster to ch must not block, therefor ch must have a capacity of at least 1.

type ListenerCache

type ListenerCache struct {

	// Envoy's HTTP (non TLS) listener address.
	// If not set, defaults to DEFAULT_HTTP_LISTENER_ADDRESS.
	HTTPAddress string

	// Envoy's HTTP (non TLS) listener port.
	// If not set, defaults to DEFAULT_HTTP_LISTENER_PORT.
	HTTPPort int

	// Envoy's HTTPS (TLS) listener address.
	// If not set, defaults to DEFAULT_HTTPS_LISTENER_ADDRESS.
	HTTPSAddress string

	// Envoy's HTTPS (TLS) listener port.
	// If not set, defaults to DEFAULT_HTTPS_LISTENER_PORT.
	HTTPSPort int

	// UseProxyProto configurs all listeners to expect a PROXY protocol
	// V1 header on new connections.
	// If not set, defaults to false.
	UseProxyProto bool

	Cond
	// contains filtered or unexported fields
}

ListenerCache manages the contents of the gRPC LDS cache.

func (*ListenerCache) Add added in v0.3.0

func (lc *ListenerCache) Add(listeners ...*v2.Listener)

Add adds an entry to the cache. If a Listener with the same name exists, it is replaced.

func (*ListenerCache) Remove added in v0.3.0

func (lc *ListenerCache) Remove(names ...string)

Remove removes the named entry from the cache. If the entry is not present in the cache, the operation is a no-op.

func (*ListenerCache) Values

func (lc *ListenerCache) Values() []*v2.Listener

Values returns a copy of the contents of the cache.

type Translator added in v0.3.0

type Translator struct {

	// The logger for this Translator. There is no valid default, this value
	// must be supplied by the caller.
	log.Logger

	ClusterCache
	ClusterLoadAssignmentCache
	ListenerCache
	VirtualHostCache
	// contains filtered or unexported fields
}

Translator receives notifications from the Kubernetes API and translates those objects into additions and removals entries of Envoy gRPC objects from a cache.

func (*Translator) OnAdd added in v0.3.0

func (t *Translator) OnAdd(obj interface{})

func (*Translator) OnDelete added in v0.3.0

func (t *Translator) OnDelete(obj interface{})

func (*Translator) OnUpdate added in v0.3.0

func (t *Translator) OnUpdate(oldObj, newObj interface{})

type VirtualHostCache

type VirtualHostCache struct {
	HTTP  virtualHostCache
	HTTPS virtualHostCache
	Cond
}

VirtualHostCache manage the contents of the gRPC RDS cache.

Jump to

Keyboard shortcuts

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