Documentation
¶
Index ¶
- Constants
- func AddRemoveHeadersFromDict(in map[string]interface{}) (http.Header, []string, error)
- func EndpointsFromUpstreams(upstreams []*Upstream) []loadbalance.Endpoint
- func NewCommandFromObj(in interface{}) (interface{}, error)
- func NewForwardFromDict(in map[string]interface{}) (interface{}, error)
- func NewHeadersFromObj(in interface{}) (http.Header, error)
- func NewHeadersListFromObj(in interface{}) ([]string, error)
- func NewRatesFromObj(in interface{}) (map[string][]*Rate, error)
- func NewReplyFromDict(in map[string]interface{}) (interface{}, error)
- func PeriodFromString(u string) (time.Duration, error)
- func UnitTypeFromString(u string) (int, error)
- func UnitTypeToString(u int) string
- type AllUpstreamsDownError
- type Endpoint
- type Failover
- type Forward
- type Rate
- type Reply
- type RetryError
- type Upstream
- func NewUpstream(scheme string, host string, port int) (*Upstream, error)
- func NewUpstreamFromDict(in map[string]interface{}) (*Upstream, error)
- func NewUpstreamFromObj(in interface{}) (*Upstream, error)
- func NewUpstreamFromString(in string) (*Upstream, error)
- func NewUpstreamFromUrl(url *url.URL) (*Upstream, error)
- func NewUpstreamsFromObj(in interface{}) ([]*Upstream, error)
- func NewUpstreamsFromUrls(hosts []string) ([]*Upstream, error)
Constants ¶
const ( // Limit type by the amount of requests in a given time period. UnitTypeRequests = iota // Limit type by the amount by used bandwidth. UnitTypeKilobytes = iota )
Variables ¶
This section is empty.
Functions ¶
func EndpointsFromUpstreams ¶
func EndpointsFromUpstreams(upstreams []*Upstream) []loadbalance.Endpoint
func NewCommandFromObj ¶
func NewCommandFromObj(in interface{}) (interface{}, error)
func NewForwardFromDict ¶
func NewHeadersFromObj ¶
func NewHeadersListFromObj ¶
func NewRatesFromObj ¶
func NewReplyFromDict ¶
func UnitTypeFromString ¶
func UnitTypeToString ¶
Types ¶
type AllUpstreamsDownError ¶
type AllUpstreamsDownError struct { }
func (*AllUpstreamsDownError) Error ¶
func (r *AllUpstreamsDownError) Error() string
type Endpoint ¶
func NewEndpoint ¶
type Failover ¶
type Failover struct { // Whether to activate the failover for the given request Active bool // Whenever vulcan encounters one of the http error codes from the upstream, // it will initiate a failover instead of proxying the response back to the // client, that allows for graceful restarts of the service without timeouts/service disruptions Codes []int }
Failover instructions enable/disable failover and provide more control over the process
func NewFailoverFromDict ¶
func NewFailoverFromObj ¶
type Forward ¶
type Forward struct { // Allows proxy to fall back to the next upstream // if the selected upstream failed Failover *Failover // Each rate key represents a resource to limit, e.g. ip address or account id // or a combination of both. Key is a string with a list of rates attached to it. // If any of the given rates of the reuqest is exceeded, the request will be not allowed. Rates map[string][]*Rate // List of upstreams that can accept this request. Load balancer will // choose an upstream based on the algo, e.g. random, round robin, // or least connections. At least one upstream is required. Upstreams []*Upstream // If supplied, headers will be added to the proxied request. AddHeaders http.Header // These headers will be removed from the request header if met, note that // hop headers will be removed no matter what. RemoveHeaders []string // If not emtpy, the original request path will be replaced with the supplied path RewritePath string }
Forward reply tells proxy to forward the request to the given upstreams
type Rate ¶
type Rate struct { // The amount of unit (e.g. 100 for 100 Kilobytes) Units int64 // Rate's period of time (e.g. second in 100 request/second) Period time.Duration // Unit to measure, e.g. requests or kilobytes UnitType int }
Rates the information on how many hits or bytes per period of time any endpoint can accept.
func NewRateFromDict ¶
func NewRateFromObj ¶
func NewRateFromString ¶
func (*Rate) CurrentBucket ¶
Returns epochSeconds rounded to the rate period e.g. minutes rate would return epoch seconds with seconds set to zero hourly rate would return epoch seconds with minutes and seconds set to zero
func (*Rate) NextBucket ¶
Returns the epoch seconds of the begining of the next time bucket
func (*Rate) RetrySeconds ¶
Calculates when this rate can be hit the next time from the given time t, assuming all the requests in the given
type Reply ¶
type Reply struct { // HTTP status code Code int // Body that should be json serializable Body interface{} }
Reply command tells proxy to reply with a special code and body and do not forward the request.
type RetryError ¶
type RetryError struct {
Seconds int
}
func (*RetryError) Error ¶
func (r *RetryError) Error() string
type Upstream ¶
type Upstream struct { Scheme string Host string Port int Id string Metrics *metrics.UpstreamMetrics }
Upstream is HTTP server that will actually serve the request that would be proxied