Documentation ¶
Overview ¶
Package backend defines interfaces and structures controlling the proxy configuration and changes.
Index ¶
- Constants
- type Address
- type AlreadyExistsError
- type Anomaly
- type Backend
- type Bracket
- type Counters
- type Endpoint
- type EndpointAdded
- type EndpointDeleted
- type EndpointKey
- type EndpointUpdated
- type Host
- type HostAdded
- type HostDeleted
- type HostKeyPairUpdated
- type HostListenerAdded
- type HostListenerDeleted
- type HostOptions
- type KeyPair
- type LatencyBrackets
- type Listener
- type Location
- func LocationFromJSON(in []byte, getter plugin.SpecGetter) (*Location, error)
- func LocationsFromJSON(in []byte, getter plugin.SpecGetter) ([]*Location, error)
- func NewLocation(hostname, id, path, upstreamId string) (*Location, error)
- func NewLocationWithOptions(hostname, id, path, upstreamId string, options LocationOptions) (*Location, error)
- type LocationAdded
- type LocationDeleted
- type LocationKey
- type LocationLimits
- type LocationMiddlewareAdded
- type LocationMiddlewareDeleted
- type LocationMiddlewareUpdated
- type LocationOptions
- type LocationOptionsUpdated
- type LocationPathUpdated
- type LocationUpstreamUpdated
- type MiddlewareInstance
- type NewBackendFn
- type NotFoundError
- type RoundTripStats
- type StatsProvider
- type StatusCode
- type Upstream
- type UpstreamAdded
- type UpstreamDeleted
- type UpstreamKeepAlive
- type UpstreamKey
- type UpstreamOptions
- type UpstreamOptionsUpdated
- type UpstreamTimeouts
- type Verdict
Constants ¶
const ( HTTP = "http" HTTPS = "https" TCP = "tcp" UNIX = "unix" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Address ¶
func NewAddress ¶
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) UpdateUpstreamOptions(upId string, o UpstreamOptions) (*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 Bracket ¶
func NewBrackets ¶
type Counters ¶
type Counters struct { Period time.Duration NetErrors int64 Total int64 StatusCodes []StatusCode }
type Endpoint ¶
type Endpoint struct { Id string Url string UpstreamId string Stats RoundTripStats }
Endpoint is a final destination of the request
func EndpointFromJSON ¶
func NewEndpoint ¶
func (*Endpoint) GetUniqueId ¶
func (e *Endpoint) GetUniqueId() EndpointKey
type EndpointAdded ¶
type EndpointDeleted ¶
type EndpointKey ¶
func MustParseEndpointKey ¶
func MustParseEndpointKey(v string) EndpointKey
func ParseEndpointKey ¶
func ParseEndpointKey(v string) (*EndpointKey, error)
func (EndpointKey) String ¶
func (e EndpointKey) String() string
type EndpointUpdated ¶
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)
type HostDeleted ¶
type HostDeleted struct {
Name string
}
type HostKeyPairUpdated ¶
type HostKeyPairUpdated struct {
Host *Host
}
type HostListenerAdded ¶
type HostListenerDeleted ¶
type HostOptions ¶
type HostOptions struct {
Default 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 NewListener ¶
type Location ¶
type Location struct { Hostname string Path string Id string Upstream *Upstream Middlewares []*MiddlewareInstance Options LocationOptions // Combined stats from all endpoints in the location Stats RoundTripStats }
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 LocationsFromJSON ¶
func LocationsFromJSON(in []byte, getter plugin.SpecGetter) ([]*Location, error)
func NewLocation ¶
func NewLocationWithOptions ¶
func NewLocationWithOptions(hostname, id, path, upstreamId string, options LocationOptions) (*Location, error)
func (*Location) GetUniqueId ¶
func (l *Location) GetUniqueId() LocationKey
type LocationAdded ¶
type LocationDeleted ¶
type LocationKey ¶
func (LocationKey) String ¶
func (l LocationKey) String() string
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 LocationMiddlewareUpdated ¶
type LocationMiddlewareUpdated struct { Host *Host Location *Location Middleware *MiddlewareInstance }
type LocationOptions ¶
type LocationOptions struct { // 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 LocationPathUpdated ¶
type LocationUpstreamUpdated ¶
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 NotFoundError ¶
type NotFoundError struct {
Message string
}
func (*NotFoundError) Error ¶
func (n *NotFoundError) Error() string
type RoundTripStats ¶
type RoundTripStats struct { Verdict Verdict Counters Counters LatencyBrackets LatencyBrackets }
RoundTrip stats contain real time statistics about performance of Endpoint or Location such as latency, processed and failed requests.
func NewRoundTripStats ¶
func NewRoundTripStats(m *metrics.RoundTripMetrics) (*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 StatsProvider ¶
type StatsProvider interface { GetLocationStats(l *Location) (*RoundTripStats, error) GetEndpointStats(e *Endpoint) (*RoundTripStats, error) GetUpstreamStats(u *Upstream) (*RoundTripStats, error) // GetTopLocations returns locations sorted by criteria (faulty, slow, most used) // if hostname or upstreamId is present, will filter out locations for that host or upstreamId GetTopLocations(hostname, upstreamId string) ([]*Location, error) // GetTopEndpoints returns endpoints sorted by criteria (faulty, slow, mos used) // if upsrtreamId is not empty, will filter out endpoints for that upstreamId GetTopEndpoints(upstreamId string) ([]*Endpoint, error) }
StatsProvider provides realtime stats abount endpoints, upstreams and locations
type StatusCode ¶
type Upstream ¶
type Upstream struct { Id string Endpoints []*Endpoint Options UpstreamOptions }
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 ¶
NewUpstream creates a new instance of the upstream object with default options applied
func NewUpstreamWithOptions ¶
func NewUpstreamWithOptions(id string, o UpstreamOptions) (*Upstream, error)
NewUpstreamWithOptions creates a new instance of the upstream object
func UpstreamFromJSON ¶
func (*Upstream) GetTransportOptions ¶
func (u *Upstream) GetTransportOptions() (*httploc.TransportOptions, error)
func (*Upstream) GetUniqueId ¶
func (u *Upstream) GetUniqueId() UpstreamKey
type UpstreamAdded ¶
type UpstreamAdded struct {
Upstream *Upstream
}
type UpstreamDeleted ¶
type UpstreamDeleted struct {
UpstreamId string
}
type UpstreamKeepAlive ¶
type UpstreamKey ¶
type UpstreamKey struct {
Id string
}
func (UpstreamKey) String ¶
func (u UpstreamKey) String() string
type UpstreamOptions ¶
type UpstreamOptions struct { Timeouts UpstreamTimeouts // Controls KeepAlive settins for backend servers KeepAlive UpstreamKeepAlive }
Additional options to control this location, such as timeouts
func UpstreamOptionsFromJSON ¶
func UpstreamOptionsFromJSON(in []byte) (*UpstreamOptions, error)
func (*UpstreamOptions) Equals ¶
func (u *UpstreamOptions) Equals(o UpstreamOptions) bool
type UpstreamOptionsUpdated ¶
type UpstreamOptionsUpdated struct {
Upstream *Upstream
}
type UpstreamTimeouts ¶
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 |