engine

package
v0.8.0-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2014 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package model defines interfaces and structures controlling the proxy configuration.

Index

Constants

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

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 Anomaly

type Anomaly struct {
	Code    int
	Message string
}

func (Anomaly) String

func (a Anomaly) String() string

type Backend

type Backend struct {
	Id       string
	Type     string
	Stats    *RoundTripStats `json:",omitempty"`
	Settings interface{}
}

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

func BackendFromJSON

func BackendFromJSON(in []byte, id ...string) (*Backend, error)

func BackendsFromJSON

func BackendsFromJSON(in []byte) ([]Backend, error)

func NewHTTPBackend

func NewHTTPBackend(id string, s HTTPBackendSettings) (*Backend, error)

NewBackend creates a new instance of the backend object

func (*Backend) GetId

func (b *Backend) GetId() string

func (*Backend) GetUniqueId

func (b *Backend) GetUniqueId() BackendKey

func (*Backend) HTTPSettings

func (b *Backend) HTTPSettings() HTTPBackendSettings

func (*Backend) String

func (b *Backend) String() string

func (*Backend) TransportSettings

func (b *Backend) TransportSettings() (*TransportSettings, error)

type BackendDeleted

type BackendDeleted struct {
	BackendKey BackendKey
}

func (*BackendDeleted) String

func (b *BackendDeleted) String() string

type BackendKey

type BackendKey struct {
	Id string
}

func (BackendKey) String

func (u BackendKey) String() string

type BackendUpserted

type BackendUpserted struct {
	Backend Backend
}

func (*BackendUpserted) String

func (b *BackendUpserted) String() string

type Bracket

type Bracket struct {
	Quantile float64
	Value    time.Duration
}

func NewBrackets

func NewBrackets(h *memmetrics.HDRHistogram) []Bracket

type Counters

type Counters struct {
	Period      time.Duration
	NetErrors   int64
	Total       int64
	StatusCodes []StatusCode
}

type Engine

type Engine interface {
	GetHosts() ([]Host, error)
	GetHost(HostKey) (*Host, error)
	UpsertHost(Host) error
	DeleteHost(HostKey) error

	GetListeners() ([]Listener, error)
	GetListener(ListenerKey) (*Listener, error)
	UpsertListener(Listener) error
	DeleteListener(ListenerKey) error

	GetFrontends() ([]Frontend, error)
	GetFrontend(FrontendKey) (*Frontend, error)
	UpsertFrontend(Frontend, time.Duration) error
	DeleteFrontend(FrontendKey) error

	GetMiddlewares(FrontendKey) ([]Middleware, error)
	GetMiddleware(MiddlewareKey) (*Middleware, error)
	UpsertMiddleware(FrontendKey, Middleware, time.Duration) error
	DeleteMiddleware(MiddlewareKey) error

	GetBackends() ([]Backend, error)
	GetBackend(BackendKey) (*Backend, error)
	UpsertBackend(Backend) error
	DeleteBackend(BackendKey) error

	GetServers(BackendKey) ([]Server, error)
	GetServer(ServerKey) (*Server, error)
	UpsertServer(BackendKey, Server, time.Duration) error
	DeleteServer(ServerKey) error

	// Subscribe 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.
	Subscribe(events chan interface{}, cancel chan bool) error

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

	// Close
	Close()
}

Engine is an interface for storage and configuration engine, e.g. Etcd.

type Frontend

type Frontend struct {
	Id        string
	Route     string
	Type      string
	BackendId string

	Stats    *RoundTripStats `json:",omitempty"`
	Settings interface{}     `json:",omitempty"`
}

Frontend is connected to a backend and vulcand will use the servers from this backend.

func FrontendFromJSON

func FrontendFromJSON(in []byte, id ...string) (*Frontend, error)

func FrontendsFromJSON

func FrontendsFromJSON(in []byte) ([]Frontend, error)

func NewHTTPFrontend

func NewHTTPFrontend(id, backendId string, routeExpr string, settings HTTPFrontendSettings) (*Frontend, error)

func (*Frontend) GetId

func (l *Frontend) GetId() string

func (*Frontend) GetKey

func (l *Frontend) GetKey() FrontendKey

func (*Frontend) HTTPSettings

func (f *Frontend) HTTPSettings() HTTPFrontendSettings

func (*Frontend) String

func (f *Frontend) String() string

type FrontendDeleted

type FrontendDeleted struct {
	FrontendKey FrontendKey
}

func (*FrontendDeleted) String

func (f *FrontendDeleted) String() string

type FrontendKey

type FrontendKey struct {
	Id string
}

func (FrontendKey) String

func (f FrontendKey) String() string

type FrontendUpserted

type FrontendUpserted struct {
	Frontend Frontend
}

func (*FrontendUpserted) String

func (f *FrontendUpserted) String() string

type HTTPBackendKeepAlive

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

type HTTPBackendSettings

type HTTPBackendSettings struct {
	Timeouts HTTPBackendTimeouts
	// Controls KeepAlive settins for backend servers
	KeepAlive HTTPBackendKeepAlive
}

func (*HTTPBackendSettings) Equals

type HTTPBackendTimeouts

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

type HTTPFrontendLimits

type HTTPFrontendLimits 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 HTTPFrontendSettings

type HTTPFrontendSettings struct {
	// Limits contains various limits one can supply for a location.
	Limits HTTPFrontendLimits
	// 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 (HTTPFrontendSettings) Equals

type Host

type Host struct {
	Name     string
	Settings HostSettings
}

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, name ...string) (*Host, error)

func HostsFromJSON

func HostsFromJSON(in []byte) ([]Host, error)

func NewHost

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

func (*Host) GetId

func (h *Host) GetId() string

func (*Host) String

func (h *Host) String() string

type HostDeleted

type HostDeleted struct {
	HostKey HostKey
}

func (*HostDeleted) String

func (h *HostDeleted) String() string

type HostKey

type HostKey struct {
	Name string
}

func (HostKey) String

func (h HostKey) String() string

type HostSettings

type HostSettings struct {
	KeyPair *KeyPair
	Default bool
}

type HostUpserted

type HostUpserted struct {
	Host Host
}

func (*HostUpserted) String

func (h *HostUpserted) String() string

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 LatencyBrackets

type LatencyBrackets []Bracket

func (LatencyBrackets) GetQuantile

func (l LatencyBrackets) GetQuantile(q float64) (*Bracket, error)

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, id ...string) (*Listener, error)

func ListenersFromJSON

func ListenersFromJSON(in []byte) ([]Listener, error)

func NewListener

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

func (*Listener) String

func (l *Listener) String() string

type ListenerDeleted

type ListenerDeleted struct {
	ListenerKey ListenerKey
}

func (*ListenerDeleted) String

func (l *ListenerDeleted) String() string

type ListenerKey

type ListenerKey struct {
	Id string
}

func (ListenerKey) String

func (l ListenerKey) String() string

type ListenerUpserted

type ListenerUpserted struct {
	HostKey  HostKey
	Listener Listener
}

func (*ListenerUpserted) String

func (l *ListenerUpserted) String() string

type Middleware

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

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

func MiddlewareFromJSON

func MiddlewareFromJSON(in []byte, getter plugin.SpecGetter, id ...string) (*Middleware, error)

func MiddlewaresFromJSON

func MiddlewaresFromJSON(in []byte, getter plugin.SpecGetter) ([]Middleware, error)

type MiddlewareDeleted

type MiddlewareDeleted struct {
	MiddlewareKey MiddlewareKey
}

func (*MiddlewareDeleted) String

func (m *MiddlewareDeleted) String() string

type MiddlewareKey

type MiddlewareKey struct {
	FrontendKey FrontendKey
	Id          string
}

func (MiddlewareKey) String

func (m MiddlewareKey) String() string

type MiddlewareUpserted

type MiddlewareUpserted struct {
	FrontendKey FrontendKey
	Middleware  Middleware
}

func (*MiddlewareUpserted) String

func (m *MiddlewareUpserted) String() string

type NewEngineFn

type NewEngineFn func() (Engine, error)

type NotFoundError

type NotFoundError struct {
	Message string
}

func (*NotFoundError) Error

func (n *NotFoundError) Error() string

type RawMiddleware

type RawMiddleware struct {
	Id         string
	Type       string
	Priority   int
	Middleware json.RawMessage
}

type RoundTripStats

type RoundTripStats struct {
	Verdict         Verdict
	Counters        Counters
	LatencyBrackets LatencyBrackets
}

RoundTripStats contain real time statistics about performance of Server or Frontend such as latency, processed and failed requests.

func NewRoundTripStats

func NewRoundTripStats(m *memmetrics.RTMetrics) (*RoundTripStats, error)

func (*RoundTripStats) AppErrorRatio

func (e *RoundTripStats) AppErrorRatio() float64

AppErrorRate calculates the ratio of 500 responses that designate internal server errors to success responses - 2xx, it specifically not counts 4xx or any other than 500 error to avoid noisy results.

func (*RoundTripStats) NetErrorRatio

func (e *RoundTripStats) NetErrorRatio() float64

NetErroRate calculates the amont of ntwork errors such as time outs and dropped connection that occured in the given time window

func (*RoundTripStats) RequestsPerSecond

func (e *RoundTripStats) RequestsPerSecond() float64

func (*RoundTripStats) ResponseCodeRatio

func (e *RoundTripStats) ResponseCodeRatio(startA, endA, startB, endB int) float64

ResponseCodeRatio calculates ratio of count(startA to endA) / count(startB to endB)

func (*RoundTripStats) String

func (e *RoundTripStats) String() string

type Server

type Server struct {
	Id    string
	URL   string
	Stats *RoundTripStats `json:",omitempty"`
}

Server is a final destination of the request

func NewServer

func NewServer(id, u string) (*Server, error)

func ServerFromJSON

func ServerFromJSON(in []byte, id ...string) (*Server, error)

func ServersFromJSON

func ServersFromJSON(in []byte) ([]Server, error)

func (*Server) GetId

func (e *Server) GetId() string

func (*Server) String

func (e *Server) String() string

type ServerDeleted

type ServerDeleted struct {
	ServerKey ServerKey
}

func (*ServerDeleted) String

func (s *ServerDeleted) String() string

type ServerKey

type ServerKey struct {
	BackendKey BackendKey
	Id         string
}

func MustParseServerKey

func MustParseServerKey(v string) ServerKey

func ParseServerKey

func ParseServerKey(v string) (*ServerKey, error)

func (ServerKey) String

func (e ServerKey) String() string

type ServerUpserted

type ServerUpserted struct {
	BackendKey BackendKey
	Server     Server
}

func (*ServerUpserted) String

func (s *ServerUpserted) String() string

type StatsProvider

type StatsProvider interface {
	FrontendStats(FrontendKey) (*RoundTripStats, error)
	ServerStats(ServerKey) (*RoundTripStats, error)
	BackendStats(BackendKey) (*RoundTripStats, error)

	// TopFrontends returns locations sorted by criteria (faulty, slow, most used)
	// if hostname or backendId is present, will filter out locations for that host or backendId
	TopFrontends(*BackendKey) ([]Frontend, error)

	// TopServers returns endpoints sorted by criteria (faulty, slow, mos used)
	// if backendId is not empty, will filter out endpoints for that backendId
	TopServers(*BackendKey) ([]Server, error)
}

StatsProvider provides realtime stats abount endpoints, backends and locations

type StatusCode

type StatusCode struct {
	Code  int
	Count int64
}

type TransportKeepAlive

type TransportKeepAlive struct {
	// Keepalive period
	Period time.Duration
	// How many idle connections will be kept per host
	MaxIdleConnsPerHost int
}

type TransportSettings

type TransportSettings struct {
	Timeouts  TransportTimeouts
	KeepAlive TransportKeepAlive
}

type TransportTimeouts

type TransportTimeouts struct {
	// Socket read timeout (before we receive the first reply header)
	Read time.Duration
	// Socket connect timeout
	Dial time.Duration
	// TLS handshake timeout
	TLSHandshake time.Duration
}

type Verdict

type Verdict struct {
	IsBad     bool
	Anomalies []Anomaly
}

func (Verdict) String

func (v Verdict) String() string

Directories

Path Synopsis
package etcdng contains the implementation of the Etcd-backed engine, where all vulcand properties are implemented as directories or keys.
package etcdng contains the implementation of the Etcd-backed engine, where all vulcand properties are implemented as directories or keys.
package memng provides in memory engine implementation, mostly used for test purposes
package memng provides in memory engine implementation, mostly used for test purposes

Jump to

Keyboard shortcuts

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