backend

package
v0.0.0-...-572ac14 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2014 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package backend defines interfaces and structures controlling the proxy configuration and changes.

Index

Constants

View Source
const (
	HTTP  = "http"
	HTTPS = "https"
	TCP   = "tcp"
	UNIX  = "unix"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Network string
	Address string
}

func NewAddress

func NewAddress(network, address string) (*Address, error)

func (*Address) Equals

func (a *Address) Equals(o Address) bool

type AlreadyExistsError

type AlreadyExistsError struct {
	Message string
}

func (*AlreadyExistsError) Error

func (n *AlreadyExistsError) Error() string

type Backend

type Backend interface {
	GetHosts() ([]*Host, error)
	AddHost(*Host) (*Host, error)
	DeleteHost(name string) error
	UpdateHostKeyPair(hostname string, keyPair *KeyPair) (*Host, error)

	GetHost(name string) (*Host, error)

	AddHostListener(hostname string, listener *Listener) (*Listener, error)
	DeleteHostListener(hostname string, listenerId string) error

	AddLocation(*Location) (*Location, error)
	GetLocation(hostname, id string) (*Location, error)
	UpdateLocationUpstream(hostname, id string, upstream string) (*Location, error)
	UpdateLocationOptions(hostname, locationId string, o LocationOptions) (*Location, error)
	DeleteLocation(hostname, id string) error

	AddLocationMiddleware(hostname, locationId string, m *MiddlewareInstance) (*MiddlewareInstance, error)
	GetLocationMiddleware(hostname, locationId string, mType, id string) (*MiddlewareInstance, error)
	UpdateLocationMiddleware(hostname, locationId string, m *MiddlewareInstance) (*MiddlewareInstance, error)
	DeleteLocationMiddleware(hostname, locationId, mType, id string) error

	GetUpstreams() ([]*Upstream, error)
	AddUpstream(*Upstream) (*Upstream, error)
	GetUpstream(id string) (*Upstream, error)
	DeleteUpstream(id string) error

	AddEndpoint(*Endpoint) (*Endpoint, error)
	GetEndpoint(upstreamId, id string) (*Endpoint, error)
	DeleteEndpoint(upstreamId, id string) error

	// WatchChanges is an entry point for getting the configuration changes as well as the initial configuration.
	// It should be a blocking function generating events from change.go to the changes channel.
	WatchChanges(changes chan interface{}, cancel chan bool) error

	// GetRegistry returns registry with the supported plugins.
	GetRegistry() *plugin.Registry

	Close()
}

type Endpoint

type Endpoint struct {
	Id         string
	Url        string
	UpstreamId string
	Stats      *EndpointStats
}

Endpoint is a final destination of the request

func EndpointFromJSON

func EndpointFromJSON(in []byte) (*Endpoint, error)

func NewEndpoint

func NewEndpoint(upstreamId, id, url string) (*Endpoint, error)

func (*Endpoint) GetId

func (e *Endpoint) GetId() string

func (*Endpoint) GetUniqueId

func (e *Endpoint) GetUniqueId() string

func (*Endpoint) String

func (e *Endpoint) String() string

type EndpointAdded

type EndpointAdded struct {
	Upstream          *Upstream
	Endpoint          *Endpoint
	AffectedLocations []*Location
}

type EndpointDeleted

type EndpointDeleted struct {
	Upstream          *Upstream
	EndpointId        string
	AffectedLocations []*Location
}

type EndpointStats

type EndpointStats struct {
	Successes     int64
	Failures      int64
	FailRate      float64
	PeriodSeconds int
}

Endpoint's realtime stats

func (*EndpointStats) String

func (e *EndpointStats) String() string

type EndpointUpdated

type EndpointUpdated struct {
	Upstream          *Upstream
	Endpoint          *Endpoint
	AffectedLocations []*Location
}

type Host

type Host struct {
	Name      string
	Locations []*Location
	KeyPair   *KeyPair
	Listeners []*Listener
	Options   HostOptions
}

Incoming requests are matched by their hostname first. Hostname is defined by incoming 'Host' header. E.g. curl http://example.com/alice will be matched by the host example.com first.

func HostFromJSON

func HostFromJSON(in []byte, getter plugin.SpecGetter) (*Host, error)

func HostsFromJSON

func HostsFromJSON(in []byte, getter plugin.SpecGetter) ([]*Host, error)

func NewHost

func NewHost(name string) (*Host, error)

func (*Host) GetId

func (h *Host) GetId() string

func (*Host) String

func (h *Host) String() string

type HostAdded

type HostAdded struct {
	Host *Host
}

type HostDeleted

type HostDeleted struct {
	Name string
}

type HostKeyPairUpdated

type HostKeyPairUpdated struct {
	Host *Host
}

type HostListenerAdded

type HostListenerAdded struct {
	Host     *Host
	Listener *Listener
}

type HostListenerDeleted

type HostListenerDeleted struct {
	Host       *Host
	ListenerId string
}

type HostOptions

type HostOptions struct {
	Default bool
}

type KeyPair

type KeyPair struct {
	Key  []byte
	Cert []byte
}

func KeyPairFromJSON

func KeyPairFromJSON(in []byte) (*KeyPair, error)

func NewKeyPair

func NewKeyPair(cert, key []byte) (*KeyPair, error)

func (*KeyPair) Equals

func (c *KeyPair) Equals(o *KeyPair) bool

type Listener

type Listener struct {
	Id string
	// HTTP or HTTPS
	Protocol string
	// Adddress specifies network (tcp or unix) and address (ip:port or path to unix socket)
	Address Address
}

Listener specifies the listening point - the network and interface for each host. Host can have multiple interfaces.

func ListenerFromJSON

func ListenerFromJSON(in []byte) (*Listener, error)

func NewListener

func NewListener(id, protocol, network, address string) (*Listener, error)

func (*Listener) String

func (l *Listener) String() string

type Location

type Location struct {
	Hostname    string
	Path        string
	Id          string
	Upstream    *Upstream
	Middlewares []*MiddlewareInstance
	Options     LocationOptions
}

Hosts contain one or several locations. Each location defines a path - simply a regular expression that will be matched against request's url. Location contains link to an upstream and vulcand will use the endpoints from this upstream to serve the request. E.g. location loc1 will serve the request curl http://example.com/alice because it matches the path /alice:

func LocationFromJSON

func LocationFromJSON(in []byte, getter plugin.SpecGetter) (*Location, error)

func NewLocation

func NewLocation(hostname, id, path, upstreamId string) (*Location, error)

func NewLocationWithOptions

func NewLocationWithOptions(hostname, id, path, upstreamId string, options LocationOptions) (*Location, error)

func (*Location) GetId

func (l *Location) GetId() string

func (*Location) GetOptions

func (l *Location) GetOptions() (*httploc.Options, error)

func (*Location) String

func (l *Location) String() string

type LocationAdded

type LocationAdded struct {
	Host     *Host
	Location *Location
}

type LocationDeleted

type LocationDeleted struct {
	Host       *Host
	LocationId string
}

type LocationKeepAlive

type LocationKeepAlive struct {
	// Keepalive period
	Period string
	// How many idle connections will be kept per host
	MaxIdleConnsPerHost int
}

type LocationLimits

type LocationLimits struct {
	MaxMemBodyBytes int64 // Maximum size to keep in memory before buffering to disk
	MaxBodyBytes    int64 // Maximum size of a request body in bytes
}

Limits contains various limits one can supply for a location.

type LocationMiddlewareAdded

type LocationMiddlewareAdded struct {
	Host       *Host
	Location   *Location
	Middleware *MiddlewareInstance
}

type LocationMiddlewareDeleted

type LocationMiddlewareDeleted struct {
	Host           *Host
	Location       *Location
	MiddlewareId   string
	MiddlewareType string
}

type LocationMiddlewareUpdated

type LocationMiddlewareUpdated struct {
	Host       *Host
	Location   *Location
	Middleware *MiddlewareInstance
}

type LocationOptions

type LocationOptions struct {
	Timeouts LocationTimeouts
	// Controls KeepAlive settins for backend servers
	KeepAlive LocationKeepAlive
	// Limits contains various limits one can supply for a location.
	Limits LocationLimits
	// Predicate that defines when requests are allowed to failover
	FailoverPredicate string
	// Used in forwarding headers
	Hostname string
	// In this case appends new forward info to the existing header
	TrustForwardHeader bool
}

Additional options to control this location, such as timeouts

func LocationOptionsFromJSON

func LocationOptionsFromJSON(in []byte) (*LocationOptions, error)

type LocationOptionsUpdated

type LocationOptionsUpdated struct {
	Host     *Host
	Location *Location
}

type LocationPathUpdated

type LocationPathUpdated struct {
	Host     *Host
	Location *Location
	Path     string
}

type LocationTimeouts

type LocationTimeouts struct {
	// Socket read timeout (before we receive the first reply header)
	Read string
	// Socket connect timeout
	Dial string
	// TLS handshake timeout
	TlsHandshake string
}

type LocationUpstreamUpdated

type LocationUpstreamUpdated struct {
	Host     *Host
	Location *Location
}

type MiddlewareInstance

type MiddlewareInstance struct {
	Id         string
	Priority   int
	Type       string
	Middleware plugin.Middleware
}

Wrapper that contains information about this middleware backend-specific data used for serialization/deserialization

func MiddlewareFromJSON

func MiddlewareFromJSON(in []byte, getter plugin.SpecGetter) (*MiddlewareInstance, error)

type NewBackendFn

type NewBackendFn func() (Backend, error)

type NotFoundError

type NotFoundError struct {
	Message string
}

func (*NotFoundError) Error

func (n *NotFoundError) Error() string

type StatsGetter

type StatsGetter interface {
	GetStats(hostname string, locationId string, e *Endpoint) *EndpointStats
}

StatsGetter provides realtime stats about endpoint specific to a particular location.

type Upstream

type Upstream struct {
	Id        string
	Endpoints []*Endpoint
}

Upstream is a collection of endpoints. Each location is assigned an upstream. Changing assigned upstream of the location gracefully redirects the traffic to the new endpoints of the upstream.

func NewUpstream

func NewUpstream(id string) (*Upstream, error)

func UpstreamFromJSON

func UpstreamFromJSON(in []byte) (*Upstream, error)

func (*Upstream) GetId

func (u *Upstream) GetId() string

func (*Upstream) String

func (u *Upstream) String() string

type UpstreamAdded

type UpstreamAdded struct {
	Upstream *Upstream
}

type UpstreamDeleted

type UpstreamDeleted struct {
	UpstreamId string
}

Directories

Path Synopsis
Etcd implementation of the backend, where all vulcand properties are implemented as directories or keys.
Etcd implementation of the backend, where all vulcand properties are implemented as directories or keys.
Provides in memory backend implementation, mostly used for test purposes
Provides in memory backend implementation, mostly used for test purposes

Jump to

Keyboard shortcuts

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