config

package
v1.5.8-beta.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2017 License: Apache-2.0 Imports: 9 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

func NewEndpointsStore added in v1.3.0

func NewEndpointsStore(store cache.Store, ch chan<- EndpointsUpdate) cache.Store

NewEndpointsStore creates an undelta store that expands updates to the store into EndpointsUpdate events on the channel. If no store is passed, a default store will be initialized. Allows reuse of a cache store across multiple components.

func NewServiceStore added in v1.3.0

func NewServiceStore(store cache.Store, ch chan<- ServiceUpdate) cache.Store

NewServiceStore creates an undelta store that expands updates to the store into ServiceUpdate events on the channel. If no store is passed, a default store will be initialized. Allows reuse of a cache store across multiple components.

func NewSourceAPI

func NewSourceAPI(c cache.Getter, period time.Duration, servicesChan chan<- ServiceUpdate, endpointsChan chan<- EndpointsUpdate)

NewSourceAPI creates config source that watches for changes to the services and endpoints.

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() *EndpointsConfig

NewEndpointsConfig creates a new EndpointsConfig. It immediately runs the created EndpointsConfig.

func (*EndpointsConfig) Channel

func (c *EndpointsConfig) Channel(source string) chan EndpointsUpdate

func (*EndpointsConfig) Config

func (c *EndpointsConfig) Config() []api.Endpoints

func (*EndpointsConfig) RegisterHandler

func (c *EndpointsConfig) RegisterHandler(handler EndpointsConfigHandler)

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.
	OnEndpointsUpdate(endpoints []api.Endpoints)
}

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

type EndpointsUpdate

type EndpointsUpdate struct {
	Endpoints []api.Endpoints
	Op        Operation
}

EndpointsUpdate describes an operation of endpoints, sent on the channel. You can add or remove single endpoints by sending an array of size one and Op == ADD|REMOVE. For setting the state of the system to a given state for this source configuration, set Endpoints as desired and Op to SET, which will reset the system state to that specified in this operation for this source channel. To remove all endpoints, set Endpoints to empty array and Op to SET

type Operation

type Operation int

Operation is a type of operation of services or endpoints.

const (
	SET Operation = iota
	ADD
	REMOVE
)

These are the available operation types.

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() *ServiceConfig

NewServiceConfig creates a new ServiceConfig. It immediately runs the created ServiceConfig.

func (*ServiceConfig) Channel

func (c *ServiceConfig) Channel(source string) chan ServiceUpdate

func (*ServiceConfig) Config

func (c *ServiceConfig) Config() []api.Service

func (*ServiceConfig) RegisterHandler

func (c *ServiceConfig) RegisterHandler(handler ServiceConfigHandler)

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.

type ServiceUpdate

type ServiceUpdate struct {
	Services []api.Service
	Op       Operation
}

ServiceUpdate describes an operation of services, sent on the channel. You can add or remove single services by sending an array of size one and Op == ADD|REMOVE. For setting the state of the system to a given state for this source configuration, set Services as desired and Op to SET, which will reset the system state to that specified in this operation for this source channel. To remove all services, set Services to empty array and Op to SET

Jump to

Keyboard shortcuts

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