Documentation
¶
Index ¶
- Constants
- func CalculateReplicas(status string, currentReplicas uint64, maxReplicas uint64, minReplicas uint64, ...) uint64
- func DecorateWithBasicAuth(next http.HandlerFunc, credentials *types.BasicAuthCredentials) http.HandlerFunc
- func DecorateWithCORS(upstream http.Handler, allowedHost string) http.Handler
- func MakeAlertHandler(service ServiceQuery) http.HandlerFunc
- func MakeAsyncReport(metrics metrics.MetricOptions) http.HandlerFunc
- func MakeCallIDMiddleware(next http.HandlerFunc) http.HandlerFunc
- func MakeForwardingProxyHandler(proxy *types.HTTPClientReverseProxy, notifiers []HTTPNotifier, ...) http.HandlerFunc
- func MakeInfoHandler(h http.Handler) http.HandlerFunc
- func MakeQueuedProxy(metrics metrics.MetricOptions, wildcard bool, ...) http.HandlerFunc
- func MakeScalingHandler(next http.HandlerFunc, upstream http.HandlerFunc, config ScalingConfig) http.HandlerFunc
- type BaseURLResolver
- type CORSHandler
- type FunctionAsHostBaseURLResolver
- type FunctionCache
- type FunctionMeta
- type HTTPNotifier
- type LoggingNotifier
- type PrometheusFunctionNotifier
- type ScalingConfig
- type ServiceQuery
- type ServiceQueryResponse
- type SingleHostBaseURLResolver
Constants ¶
const DefaultMaxReplicas = 20
DefaultMaxReplicas is the amount of replicas a service will auto-scale up to.
const DefaultMinReplicas = 1
DefaultMinReplicas is the minimal amount of replicas for a service.
const DefaultScalingFactor = 20
DefaultScalingFactor is the defining proportion for the scaling increments.
const MaxScaleLabel = "com.openfaas.scale.max"
MaxScaleLabel label indicating max scale for a function
const MinScaleLabel = "com.openfaas.scale.min"
MinScaleLabel label indicating min scale for a function
const ScalingFactorLabel = "com.openfaas.scale.factor"
ScalingFactorLabel label indicates the scaling factor for a function
Variables ¶
This section is empty.
Functions ¶
func CalculateReplicas ¶
func CalculateReplicas(status string, currentReplicas uint64, maxReplicas uint64, minReplicas uint64, scalingFactor uint64) uint64
CalculateReplicas decides what replica count to set depending on current/desired amount
func DecorateWithBasicAuth ¶
func DecorateWithBasicAuth(next http.HandlerFunc, credentials *types.BasicAuthCredentials) http.HandlerFunc
DecorateWithBasicAuth enforces basic auth as a middleware with given credentials
func DecorateWithCORS ¶
DecorateWithCORS decorate a handler with CORS-injecting middleware
func MakeAlertHandler ¶
func MakeAlertHandler(service ServiceQuery) http.HandlerFunc
MakeAlertHandler handles alerts from Prometheus Alertmanager
func MakeAsyncReport ¶
func MakeAsyncReport(metrics metrics.MetricOptions) http.HandlerFunc
MakeAsyncReport makes a handler for asynchronous invocations to report back into.
func MakeCallIDMiddleware ¶
func MakeCallIDMiddleware(next http.HandlerFunc) http.HandlerFunc
MakeCallIDMiddleware middleware tags a request with a uid
func MakeForwardingProxyHandler ¶
func MakeForwardingProxyHandler(proxy *types.HTTPClientReverseProxy, notifiers []HTTPNotifier, baseURLResolver BaseURLResolver) http.HandlerFunc
MakeForwardingProxyHandler create a handler which forwards HTTP requests
func MakeInfoHandler ¶
func MakeInfoHandler(h http.Handler) http.HandlerFunc
MakeInfoHandler is responsible for display component version information
func MakeQueuedProxy ¶
func MakeQueuedProxy(metrics metrics.MetricOptions, wildcard bool, canQueueRequests queue.CanQueueRequests) http.HandlerFunc
MakeQueuedProxy accepts work onto a queue
func MakeScalingHandler ¶
func MakeScalingHandler(next http.HandlerFunc, upstream http.HandlerFunc, config ScalingConfig) http.HandlerFunc
MakeScalingHandler creates handler which can scale a function from zero to 1 replica(s).
Types ¶
type BaseURLResolver ¶
BaseURLResolver URL resolver for upstream requests
type CORSHandler ¶
CORSHandler set custom CORS instructions for the store.
func (CORSHandler) ServeHTTP ¶
func (c CORSHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type FunctionAsHostBaseURLResolver ¶
type FunctionAsHostBaseURLResolver struct {
FunctionSuffix string
}
FunctionAsHostBaseURLResolver resolves URLs using a function from the URL as a host
type FunctionCache ¶
FunctionCache provides a cache of Function replica counts
func (*FunctionCache) Get ¶
func (fc *FunctionCache) Get(functionName string) (ServiceQueryResponse, bool)
Get replica count for functionName
func (*FunctionCache) Set ¶
func (fc *FunctionCache) Set(functionName string, serviceQueryResponse ServiceQueryResponse)
Set replica count for functionName
type FunctionMeta ¶
type FunctionMeta struct { LastRefresh time.Time ServiceQueryResponse ServiceQueryResponse }
FunctionMeta holds the last refresh and any other meta-data needed for caching.
type HTTPNotifier ¶
type HTTPNotifier interface {
Notify(method string, URL string, statusCode int, duration time.Duration)
}
HTTPNotifier notify about HTTP request/response
type LoggingNotifier ¶
type LoggingNotifier struct { }
LoggingNotifier notifies a log about a request
type PrometheusFunctionNotifier ¶
type PrometheusFunctionNotifier struct {
Metrics *metrics.MetricOptions
}
PrometheusFunctionNotifier records metrics to Prometheus
type ScalingConfig ¶
type ScalingConfig struct { MaxPollCount uint FunctionPollInterval time.Duration CacheExpiry time.Duration ServiceQuery ServiceQuery }
ScalingConfig for scaling behaviours
type ServiceQuery ¶
type ServiceQuery interface { GetReplicas(service string) (response ServiceQueryResponse, err error) SetReplicas(service string, count uint64) error }
ServiceQuery provides interface for replica querying/setting
type ServiceQueryResponse ¶
type ServiceQueryResponse struct { Replicas uint64 MaxReplicas uint64 MinReplicas uint64 ScalingFactor uint64 AvailableReplicas uint64 }
ServiceQueryResponse response from querying a function status
type SingleHostBaseURLResolver ¶
type SingleHostBaseURLResolver struct {
BaseURL string
}
SingleHostBaseURLResolver resolves URLs against a single BaseURL