Documentation ¶
Overview ¶
Package model defines interfaces and structures controlling the proxy configuration.
Index ¶
- Constants
- func NewTLSConfig(s *TLSSettings) (*tls.Config, error)
- func NewTLSSessionCache(s *TLSSessionCache) (tls.ClientSessionCache, error)
- func ParseCipherSuite(cs string) (uint16, error)
- func ParseTLSVersion(version string) (uint16, error)
- type Address
- type AlreadyExistsError
- type Anomaly
- type Backend
- type BackendDeleted
- type BackendKey
- type BackendUpserted
- type Bracket
- type Counters
- type Engine
- type Frontend
- type FrontendDeleted
- type FrontendKey
- type FrontendUpserted
- type HTTPBackendKeepAlive
- type HTTPBackendSettings
- type HTTPBackendTimeouts
- type HTTPFrontendLimits
- type HTTPFrontendSettings
- type HTTPSListenerSettings
- type Host
- type HostDeleted
- type HostKey
- type HostSettings
- type HostUpserted
- type InvalidFormatError
- type KeyPair
- type LRUSessionCacheSettings
- type LatencyBrackets
- type Listener
- type ListenerDeleted
- type ListenerKey
- type ListenerUpserted
- type Middleware
- type MiddlewareDeleted
- type MiddlewareKey
- type MiddlewareUpserted
- type NewEngineFn
- type NotFoundError
- type OCSPSettings
- type RawMiddleware
- type RoundTripStats
- type Server
- type ServerDeleted
- type ServerKey
- type ServerUpserted
- type StatsProvider
- type StatusCode
- type TLSSessionCache
- type TLSSettings
- type TransportKeepAlive
- type TransportSettings
- type TransportTimeouts
- type Verdict
Constants ¶
const ( HTTP = "http" HTTPS = "https" TCP = "tcp" UNIX = "unix" NoTTL = 0 )
const DefaultLRUCapacity = 1024
const LRUCacheType = "LRU"
Variables ¶
This section is empty.
Functions ¶
func NewTLSConfig ¶
func NewTLSConfig(s *TLSSettings) (*tls.Config, error)
NewTLSConfig validates the TLSSettings and returns the tls.Config with the converted parameters
func NewTLSSessionCache ¶
func NewTLSSessionCache(s *TLSSessionCache) (tls.ClientSessionCache, error)
NewTLSSessionCache validates parameters and creates a new TLS session cache
func ParseCipherSuite ¶
func ParseTLSVersion ¶
Types ¶
type Address ¶
func NewAddress ¶
type AlreadyExistsError ¶
type AlreadyExistsError struct {
Message string
}
func (*AlreadyExistsError) Error ¶
func (n *AlreadyExistsError) Error() 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 BackendsFromJSON ¶
func NewHTTPBackend ¶
func NewHTTPBackend(id string, s HTTPBackendSettings) (*Backend, error)
NewBackend creates a new instance of the backend object
func (*Backend) GetUniqueId ¶
func (b *Backend) GetUniqueId() BackendKey
func (*Backend) HTTPSettings ¶
func (b *Backend) HTTPSettings() HTTPBackendSettings
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 ¶
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 returns list of hosts registered in the sotrage engine // Returns empty list in case if there are no hosts. GetHosts() ([]Host, error) // GetHost returns host by given key, or engine.NotFoundError if it's not found GetHost(HostKey) (*Host, error) // UpsertHost updates or inserts the host, make sure to supply valid hostname UpsertHost(Host) error // DeleteHost deletes host by given key or returns engine.NotFoundError if it's not found DeleteHost(HostKey) error // GetListeners returns list of listeners registered in the storage engine // Returns empty list in case if there are no listeners GetListeners() ([]Listener, error) // GetListener returns a listener by key or engine.NotFoundError if it's not found GetListener(ListenerKey) (*Listener, error) // Updates or inserts a new listener, Listener.Id should not be empty UpsertListener(Listener) error // DeleteListener deletes a listener by key, returns engine.NotFoundError if it's not found DeleteListener(ListenerKey) error // GetFrontends returns a list of frontends registered in Vulcand // Returns empty list in case if there are no frontends GetFrontends() ([]Frontend, error) // GetFrontend returns a frontend by given key, or engine.NotFoundError if it's not found GetFrontend(FrontendKey) (*Frontend, error) // UpsertFrontend updates or inserts the frontend. Frontend.Id should not be empty. The second field specifies TTL, will be set to 0 // in case if the frontend should not expire. UpsertFrontend(Frontend, time.Duration) error // DeleteFrontend deletes a frontend by a given key, returns engine.NotFoundError if it's not found DeleteFrontend(FrontendKey) error // GetMiddlewares retunrns middlewares registered for a given frontend // Returns empty list if there are no registered middlewares GetMiddlewares(FrontendKey) ([]Middleware, error) // GetMiddleware returns middleware by a given key, returns engine.NotFoundError if it's not there GetMiddleware(MiddlewareKey) (*Middleware, error) // UpsertMiddleware updates or inserts a middleware for a frontend. FrontendKey.Id and Middleware.Id should not be empty UpsertMiddleware(FrontendKey, Middleware, time.Duration) error // Delete middleware by given key, returns engine.NotFoundError if its not found DeleteMiddleware(MiddlewareKey) error // GetBackends returns list of registered backends. Returns empty list if there are no backends GetBackends() ([]Backend, error) // GetBackend returns backend by given key, returns engine.NotFoundError if its not found GetBackend(BackendKey) (*Backend, error) // UpsertBackend updates or inserts a new backend. Backend.Id should not be empty UpsertBackend(Backend) error // DeleteBackend deletes backend by it's key. BackendKey.Id should not be empty. In case if backend is being used by frontends // this method should fail to preserve integrity, otherwise it will leave frontends in broken state DeleteBackend(BackendKey) error // GetServers returns servers assigned to the backend. BackendKey.Id should not be empty // Returns empty list if there are not assigned servers. Returns engine.NotFoundError if Backend does not exist GetServers(BackendKey) ([]Server, error) // GetServer returns server by given key or engine.NotFoundError if server is not found GetServer(ServerKey) (*Server, error) // UpsertServer updates or inserts a server. BackendKey.Id and Server.Id should not be empty. // TTL provides time to expire, in case if it's 0 server is permanent. UpsertServer(BackendKey, Server, time.Duration) error // DeleteServer deletes a server by given key. ServerKey.Id should not be empty. // Returns engine.NotFoundError if server not found 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. // Each change should be an instance of the struct provided in events.go // In case if cancel channel is closed, the subscribe events should no longer be generated. Subscribe(events chan interface{}, cancel chan bool) error // GetRegistry returns registry with the supported plugins. It should be stored by Engine instance. GetRegistry() *plugin.Registry // Close should close all underlying resources such as connections, files, etc. Close() }
Engine is an interface for storage and configuration engine, e.g. Etcd. Simple in memory implementation is available at engine/memng package Engines should pass the following acceptance suite to be compatible: engine/test/suite.go, see engine/etcdng/etcd_test.go and engine/memng/mem_test.go for details
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 FrontendsFromJSON ¶
func NewHTTPFrontend ¶
func NewHTTPFrontend(id, backendId string, routeExpr string, settings HTTPFrontendSettings) (*Frontend, error)
func (*Frontend) GetKey ¶
func (l *Frontend) GetKey() FrontendKey
func (*Frontend) HTTPSettings ¶
func (f *Frontend) HTTPSettings() HTTPFrontendSettings
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 HTTPBackendSettings ¶
type HTTPBackendSettings struct { // Timeouts provides timeout settings for backend servers Timeouts HTTPBackendTimeouts // KeepAlive controls keep-alive settings for backend servers KeepAlive HTTPBackendKeepAlive // TLS provides optional TLS settings for HTTP backend TLS *TLSSettings `json:",omitempty"` }
func (*HTTPBackendSettings) Equals ¶
func (s *HTTPBackendSettings) Equals(o HTTPBackendSettings) bool
type HTTPBackendTimeouts ¶
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 ¶
func (l HTTPFrontendSettings) Equals(o HTTPFrontendSettings) bool
type HTTPSListenerSettings ¶
type HTTPSListenerSettings struct {
TLS TLSSettings
}
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 HostsFromJSON ¶
type HostDeleted ¶
type HostDeleted struct {
HostKey HostKey
}
func (*HostDeleted) String ¶
func (h *HostDeleted) String() string
type HostSettings ¶
type HostSettings struct { Default bool KeyPair *KeyPair OCSP OCSPSettings }
type HostUpserted ¶
type HostUpserted struct {
Host Host
}
func (*HostUpserted) String ¶
func (h *HostUpserted) String() string
type InvalidFormatError ¶
type InvalidFormatError struct {
Message string
}
func (*InvalidFormatError) Error ¶
func (n *InvalidFormatError) Error() string
type LRUSessionCacheSettings ¶
type LRUSessionCacheSettings struct { // LRU Capacity default is 1024 Capacity int }
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 // Scope is optional expression that limits the operational scope of this listener Scope string // Settings provides listener-type specific settings, e.g. TLS settings for HTTPS listener Settings *HTTPSListenerSettings `json:",omitempty"` }
Listener specifies the listening point - the network and interface for each host. Host can have multiple interfaces.
func ListenersFromJSON ¶
func NewListener ¶
func NewListener(id, protocol, network, address, scope string, settings *HTTPSListenerSettings) (*Listener, error)
func (*Listener) SettingsEquals ¶
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 ¶
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 NotFoundError ¶
type NotFoundError struct {
Message string
}
func (*NotFoundError) Error ¶
func (n *NotFoundError) Error() string
type OCSPSettings ¶
type OCSPSettings struct { Enabled bool Period string // Optional responders. Responder is the CA-operated HTTP server that responds with revocation status // If set, this field will override Responders []string SkipSignatureCheck bool }
Sets up OCSP stapling, see http://en.wikipedia.org/wiki/OCSP_stapling
func (*OCSPSettings) Equals ¶
func (o *OCSPSettings) Equals(other *OCSPSettings) bool
func (*OCSPSettings) RefreshPeriod ¶
func (o *OCSPSettings) RefreshPeriod() (time.Duration, error)
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 ServersFromJSON ¶
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 ParseServerKey ¶
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 TLSSessionCache ¶
type TLSSessionCache struct { // Session cache implementation, default is 'LRU' with capacity 1024 Type string Settings *LRUSessionCacheSettings }
TLSSessionCache sets up parameters for TLS session cache
func (*TLSSessionCache) Equals ¶
func (c *TLSSessionCache) Equals(o *TLSSessionCache) bool
type TLSSettings ¶
type TLSSettings struct { // PreferServerCipherSuites controls whether the server selects the CipherSuites PreferServerCipherSuites bool // SkipVerify skips certificate check, very insecure InsecureSkipVerify bool // MinVersion is minimal TLS version "VersionTLS10" is default MinVersion string // MaxVersion is max supported TLS version, "VersionTLS12" is default MaxVersion string // SessionTicketsDisabled disables session ticket resumption support SessionTicketsDisabled bool // SessionCache specifies TLS session cache, default it 'LRU' with capacity 1024 SessionCache TLSSessionCache // Preferred CipherSuites, default is: // // TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 // TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 // TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA // TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA // TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA // TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA // TLS_RSA_WITH_AES_256_CBC_SHA // TLS_RSA_WITH_AES_128_CBC_SHA CipherSuites []string }
TLSSettings is a JSON and API friendly version of some of the tls.Config parameters
func (*TLSSettings) Equals ¶
func (s *TLSSettings) Equals(other *TLSSettings) bool
type TransportKeepAlive ¶
type TransportSettings ¶
type TransportSettings struct { Timeouts TransportTimeouts KeepAlive TransportKeepAlive TLS *tls.Config }
type TransportTimeouts ¶
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 |