Documentation
¶
Index ¶
- Constants
- func MakeHorizontalScalingHandler(next http.HandlerFunc) http.HandlerFunc
- type CachedFunctionQuery
- type Call
- type FunctionCache
- type FunctionCacher
- type FunctionMeta
- type FunctionQuery
- type FunctionScaleResult
- type FunctionScaler
- type ScalingConfig
- type ServiceQuery
- type ServiceQueryResponse
- type SingleFlight
- type SingleFlightResult
Constants ¶
const ( // DefaultMinReplicas is the minimal amount of replicas for a service. DefaultMinReplicas = 1 // DefaultMaxReplicas is the amount of replicas a service will auto-scale up to. DefaultMaxReplicas = 5 // DefaultScalingFactor is the defining proportion for the scaling increments. DefaultScalingFactor = 10 DefaultTypeScale = "rps" // MinScaleLabel label indicating min scale for a function MinScaleLabel = "com.openfaas.scale.min" // MaxScaleLabel label indicating max scale for a function MaxScaleLabel = "com.openfaas.scale.max" // ScalingFactorLabel label indicates the scaling factor for a function ScalingFactorLabel = "com.openfaas.scale.factor" )
Variables ¶
This section is empty.
Functions ¶
func MakeHorizontalScalingHandler ¶
func MakeHorizontalScalingHandler(next http.HandlerFunc) http.HandlerFunc
Types ¶
type CachedFunctionQuery ¶
type CachedFunctionQuery struct {
// contains filtered or unexported fields
}
func (*CachedFunctionQuery) Get ¶
func (c *CachedFunctionQuery) Get(fn string, ns string) (ServiceQueryResponse, error)
func (*CachedFunctionQuery) GetAnnotations ¶
type FunctionCache ¶
FunctionCache provides a cache of Function replica counts
func (*FunctionCache) Get ¶
func (fc *FunctionCache) Get(functionName, namespace string) (ServiceQueryResponse, bool)
Get replica count for functionName
func (*FunctionCache) Set ¶
func (fc *FunctionCache) Set(functionName, namespace string, queryRes ServiceQueryResponse)
Set replica count for functionName
type FunctionCacher ¶
type FunctionCacher interface {
Set(functionName, namespace string, serviceQueryResponse ServiceQueryResponse)
Get(functionName, namespace string) (ServiceQueryResponse, bool)
}
FunctionCacher queries functions and caches the results
func NewFunctionCache ¶
func NewFunctionCache(cacheExpiry time.Duration) FunctionCacher
NewFunctionCache creates a function cache to query function metadata
type FunctionMeta ¶
type FunctionMeta struct {
LastRefresh time.Time
ServiceQueryResponse ServiceQueryResponse
}
FunctionMeta holds the last refresh and any other meta-data needed for caching.
type FunctionQuery ¶
type FunctionQuery interface {
Get(name string, namespace string) (ServiceQueryResponse, error)
GetAnnotations(name string, namespace string) (annotations map[string]string, err error)
}
func NewCachedFunctionQuery ¶
func NewCachedFunctionQuery(cache FunctionCacher, serviceQuery ServiceQuery) FunctionQuery
type FunctionScaleResult ¶
FunctionScaleResult holds the result of scaling from zero
type FunctionScaler ¶
type FunctionScaler struct {
Cache FunctionCacher
Config ScalingConfig
SingleFlight *singleflight.Group
}
FunctionScaler scales from zero
func NewFunctionScaler ¶
func NewFunctionScaler(config ScalingConfig, functionCacher FunctionCacher) FunctionScaler
NewFunctionScaler create a new scaler with the specified ScalingConfig
func (*FunctionScaler) Scale ¶
func (f *FunctionScaler) Scale(functionName, namespace string) FunctionScaleResult
Scale scales a function from zero replicas to 1 or the value set in the minimum replicas metadata
type ScalingConfig ¶
type ScalingConfig struct {
// MaxPollCount attempts to query a function before giving up
MaxPollCount uint
// FunctionPollInterval delay or interval between polling a function's
// readiness status
FunctionPollInterval time.Duration
// CacheExpiry life-time for a cache entry before considering invalid
CacheExpiry time.Duration
// ServiceQuery queries available/ready replicas for function
ServiceQuery ServiceQuery
// SetScaleRetries is the number of times to try scaling a function before
// giving up due to errors
SetScaleRetries uint
}
ScalingConfig for scaling behaviours
type ServiceQuery ¶
type ServiceQuery interface {
GetReplicas(service, namespace string) (response ServiceQueryResponse, err error)
SetReplicas(service, namespace 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
Annotations *map[string]string
}
ServiceQueryResponse response from querying a function status
type SingleFlight ¶
type SingleFlight struct {
// contains filtered or unexported fields
}
func NewSingleFlight ¶
func NewSingleFlight() *SingleFlight
type SingleFlightResult ¶
type SingleFlightResult struct {
Result interface{}
Error error
}