scale

package
v0.0.0-...-19e231a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2017 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Constant constant

Constant scaler that does not allow scaling.

Functions

This section is empty.

Types

type Exponential

type Exponential float32

Exponential scaling mode specifies the factor by which the number of instances should be increased during each scaling attempt. Must be greater than 1.0.

func (Exponential) Apply

func (s Exponential) Apply(n uint32) uint32

Apply scales the supplied value by its factor and returns the result. The result is guaranteed to be greater than the input by at least 1.

func (Exponential) ApplyInverse

func (s Exponential) ApplyInverse(n uint32) uint32

Apply scales the supplied value by its inverse factor and returns the result. The result is guaranteed to be 0 or to be less than the nonzero input by at least 1.

func (Exponential) IsValid

func (s Exponential) IsValid() bool

IsValid checks that its value is greater than 1.

type Incremental

type Incremental uint32

Incremental scaling mode specifies the number of new instances to be added during each scaling attempt. Must be 1 or greater.

func (Incremental) Apply

func (s Incremental) Apply(n uint32) uint32

Apply adds itself to the supplied value and returns the sum.

func (Incremental) ApplyInverse

func (s Incremental) ApplyInverse(n uint32) uint32

If Incremental is greater or equal to the supplied value, ApplyInverse subtracts itself to the argument and returns the difference. Otherwise 0 is returned.

func (Incremental) IsValid

func (s Incremental) IsValid() bool

IsValid checks that its value is greater than 1.

type Scale

type Scale interface {
	IsValid() bool
	Apply(n uint32) uint32
	ApplyInverse(n uint32) uint32
}

Scale must be implemented by scale-up and wind-down calculators. Three scale calculators come predefined: Incremental, Exponential and Constant.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL