hostindex

package
v3.11.0-0.35.0+incompa... Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OldestFirst

func OldestFirst(changed Changed, active []*routev1.Route, inactive ...*routev1.Route) (updated, displaced []*routev1.Route)

OldestFirst identifies all unique host+port combinations in active and inactive, ordered by oldest first. Duplicates are returned in displaced in order. It assumes all provided route have the same spec.host value.

func SameNamespace

func SameNamespace(changed Changed, active []*routev1.Route, inactive ...*routev1.Route) (updated, displaced []*routev1.Route)

SameNamespace identifies all unique host+port combinations in active and inactive that are from the same namespace as the oldest route (creation timestamp and then uid ordering). Duplicates and non matching routes are returned in displaced and are unordered. It assumes all provided routes have the same spec.host value.

Types

type Changed

type Changed interface {
	// Activated should be invoked if the route was previously inactive and is now active.
	Activated(route *routev1.Route)
	// Displaced should be invoked if the route was previously active and is now inactive.
	Displaced(route *routev1.Route)
}

Changed allows a route activation function to record which routes moved from inactive to active or vice versa.

type Changes

type Changes interface {
	GetActivated() []*routev1.Route
	GetDisplaced() []*routev1.Route
}

Changes lists all routes either activated or displaced by the operation.

type Interface

type Interface interface {
	// Add attempts to add the route to the index, returning a set of
	// changes if the index. Constraints on the index may result in
	// the route being in the Displaced list. The provided route may
	// be in either the Activated or Displaced lists or neither.
	// newRoute is true if a route with the given namespace and name
	// was not in the index prior to this call.
	Add(route *routev1.Route) (changes Changes, newRoute bool)
	// Remove attempts to remove the route from the index, returning
	// any changes that occurred due to that operation. The provided
	// route will never be in the Activated or Displaced lists on the
	// Changes object.
	Remove(route *routev1.Route) Changes
	// RoutesForHost returns all currently active hosts for the provided
	// route.
	RoutesForHost(host string) ([]*routev1.Route, bool)
	// Filter iterates over all routes in the index, keeping only those
	// for which fn returs true.
	Filter(fn func(*routev1.Route) (keep bool)) Changes
	// HostLen returns the number of hosts in the index.
	HostLen() int
}

Interface allows access to routes in the index and makes it easy to know when changes to routes alter the index.

func New

New returns a new host index that uses the provided route activation function to determine which routes for a given host should be active.

type RouteActivationFunc

type RouteActivationFunc func(changed Changed, active []*routev1.Route, inactive ...*routev1.Route) (activated, displaced []*routev1.Route)

RouteActivationFunc attempts to add routes from inactive into the active set. Any routes that are not valid must be returned in the displaced list. All routes that are added into active should be passed to Changed.Activated() and any route in active that ends up in the displaced list should be passed to Changed.Displaced(). It is the caller's responsiblity to invoke Activated or Displaced for inactive routes. Routes must be provided to the function in lowest to highest order and the ordering should be preserved in activated.

Jump to

Keyboard shortcuts

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