Documentation
¶
Index ¶
Constants ¶
View Source
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 = 20 // DefaultScalingFactor is the defining proportion for the scaling increments. DefaultScalingFactor = 20 // 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 ¶
This section is empty.
Types ¶
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 FunctionScaleResult ¶
FunctionScaleResult holds the result of scaling from zero
type FunctionScaler ¶
type FunctionScaler struct { Cache *FunctionCache Config ScalingConfig }
FunctionScaler scales from zero
func NewFunctionScaler ¶
func NewFunctionScaler(config ScalingConfig) FunctionScaler
NewFunctionScaler create a new scaler with the specified ScalingConfig
func (*FunctionScaler) Scale ¶
func (f *FunctionScaler) Scale(functionName 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 string) (response ServiceQueryResponse, err error) SetReplicas(service string, count uint64) error }
ServiceQuery provides interface for replica querying/setting
Click to show internal directories.
Click to hide internal directories.