Documentation ¶
Overview ¶
Package generation provides builders to easily build groups, entities and their resource and affinity requirements and placement orderings. All builders have methods to set each specific field of the type being build and a generate method which will then create an instance of the type from the specifications given to the builder.
Building a group can look like this:
random := rand.New(rand.NewSource(42)) // Create a template for the group name nameTemplate := labels.NewLabelTemplate("schemadock$id$-$dc$") // Create the builder builder := NewGroupBuilder(). Name(nameTemplate) // Bind values to the names in the template, this makes reusing the builder to generate groups with different // names easy. nameTemplate. Bind("id", "42"). Bind("dc", "dc1") // Generate a group with name "schemadock42-dc1" group := builder.Generate(random, time.Now())
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Constant ¶
type Constant struct {
// contains filtered or unexported fields
}
Constant represents a constant distribution which always returns the same value, though the value to return can be changed using the new value method.
func NewConstant ¶
NewConstant creates a new constant distribution.
func (*Constant) CurrentValue ¶
CurrentValue returns the current value of the constant distribution.
type Discrete ¶
Discrete represents a discrete distribution with varying probabilities for each value throughout time.
func NewDiscrete ¶
NewDiscrete creates a new discrete distribution which returns each value with a probability distributed that corresponds to the weight of the value.
func NewUniformDiscrete ¶
NewUniformDiscrete creates a new Discrete which returns a set of values with a uniform probability distribution throughout time.
type Distribution ¶
Distribution represents a probability distribution which can change according to time but always returns the same value for the same point in time.
type Gaussian ¶
type Gaussian struct { Mean func(gtime time.Duration) float64 StandardDeviation func(gtime time.Duration) float64 }
Gaussian represents a gaussian distribution with varying mean and standard deviation throughout time.
func NewConstantGaussian ¶
NewConstantGaussian creates a new GaussianDistribution with constant mean and standard deviation.
type Random ¶
type Random interface { // Uniform returns a value in the range [0;1[. Uniform(gtime time.Duration) float64 // Norm returns a normal distributed value in the range [-math.MaxFloat64, +math.MaxFloat64] with mean 0.0 and // stddev 1.0. Norm(gtime time.Duration) float64 // Exp returns a exponentially distributed value in the range [0, +math.MaxFloat64] with an exponential distribution // whose rate parameter (lambda) is 1 and whose mean is 1/lambda (1). Exp(gtime time.Duration) float64 // Perm returns permutation of the numbers 0, 1, ..., n-1. Perm(gtime time.Duration, n int) []int }
Random is source of randomness that varies throughout time, but will always return the same value for the same instance in time.