config

package
v0.0.0-...-4f3658d Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package config provides decoupling between various configuration sources (etcd, files,...) and the pieces that actually care about them (loadbalancer, proxy). Config takes 1 or more configuration sources and allows for incremental (add/remove) and full replace (set) changes from each of the sources, then creates a union of the configuration and provides a unified view for both service handlers as well as endpoint handlers. There is no attempt to resolve conflicts of any sort. Basic idea is that each configuration source gets a channel from the Config service and pushes updates to it via that channel. Config then keeps track of incremental & replace changes and distributes them to listeners as appropriate.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EndpointsConfig

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

EndpointsConfig tracks a set of endpoints configurations. It accepts "set", "add" and "remove" operations of endpoints via channels, and invokes registered handlers on change.

func NewEndpointsConfig

func NewEndpointsConfig(c cache.Getter, period time.Duration) *EndpointsConfig

NewEndpointsConfig creates a new EndpointsConfig.

func (*EndpointsConfig) RegisterHandler

func (c *EndpointsConfig) RegisterHandler(handler EndpointsConfigHandler)

RegisterHandler registers a handler which is called on every endpoints change.

func (*EndpointsConfig) Run

func (c *EndpointsConfig) Run(stopCh <-chan struct{})

Run starts the underlying informer and goroutine responsible for calling registered handlers.

type EndpointsConfigHandler

type EndpointsConfigHandler interface {
	// OnEndpointsUpdate gets called when endpoints configuration is changed for a given
	// service on any of the configuration sources. An example is when a new
	// service comes up, or when containers come up or down for an existing service.
	//
	// NOTE: For efficiency, endpoints are being passed by reference, thus,
	// OnEndpointsUpdate should NOT modify pointers of a given slice.
	// Those endpoints objects are shared with other layers of the system and
	// are guaranteed to be immutable with the assumption that are also
	// not mutated by those handlers. Make a deep copy if you need to modify
	// them in your code.
	OnEndpointsUpdate(endpoints []*api.Endpoints)
}

EndpointsConfigHandler is an abstract interface of objects which receive update notifications for the set of endpoints.

type ServiceConfig

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

ServiceConfig tracks a set of service configurations. It accepts "set", "add" and "remove" operations of services via channels, and invokes registered handlers on change.

func NewServiceConfig

func NewServiceConfig(c cache.Getter, period time.Duration) *ServiceConfig

NewServiceConfig creates a new ServiceConfig.

func (*ServiceConfig) RegisterHandler

func (c *ServiceConfig) RegisterHandler(handler ServiceConfigHandler)

RegisterHandler registers a handler which is called on every services change.

func (*ServiceConfig) Run

func (c *ServiceConfig) Run(stopCh <-chan struct{})

Run starts the underlying informer and goroutine responsible for calling registered handlers.

type ServiceConfigHandler

type ServiceConfigHandler interface {
	// OnServiceUpdate gets called when a configuration has been changed by one of the sources.
	// This is the union of all the configuration sources.
	OnServiceUpdate(services []api.Service)
}

ServiceConfigHandler is an abstract interface of objects which receive update notifications for the set of services.

Jump to

Keyboard shortcuts

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