Documentation ¶
Index ¶
- Variables
- type Const
- func (b *Const) Deviation() float64
- func (b *Const) Name() string
- func (c *Const) Next() error
- func (b *Const) Point() []byte
- func (b *Const) RandomizeStart(randomizeStart bool)
- func (b *Const) SetStop(stop uint)
- func (b *Const) Step() uint
- func (b *Const) Stop() uint
- func (b *Const) Time() uint
- func (b *Const) Type() Type
- func (b *Const) TypeName() string
- func (b *Const) Value() float64
- func (b *Const) WithDeviation(deviation float64) *base
- func (b *Const) WithName(name string) *base
- func (b *Const) WithStep(step uint) *base
- func (b *Const) WriteTo(w io.Writer) (int64, error)
- type Counter
- func (b *Counter) Deviation() float64
- func (b *Counter) Name() string
- func (c *Counter) Next() error
- func (b *Counter) Point() []byte
- func (b *Counter) RandomizeStart(randomizeStart bool)
- func (b *Counter) SetStop(stop uint)
- func (b *Counter) Step() uint
- func (b *Counter) Stop() uint
- func (b *Counter) Time() uint
- func (b *Counter) Type() Type
- func (b *Counter) TypeName() string
- func (b *Counter) Value() float64
- func (b *Counter) WithDeviation(deviation float64) *base
- func (b *Counter) WithName(name string) *base
- func (b *Counter) WithStep(step uint) *base
- func (b *Counter) WriteTo(w io.Writer) (int64, error)
- type Generator
- type Generators
- func (gg *Generators) List() []Generator
- func (gg *Generators) Next() error
- func (gg *Generators) Point() []byte
- func (gg *Generators) Randomized() bool
- func (gg *Generators) SetList(gens []Generator)
- func (gg *Generators) SetStop(stop uint)
- func (gg *Generators) Step() uint
- func (gg *Generators) WriteAllTo(w io.Writer) (int64, error)
- func (gg *Generators) WriteAllToWithContext(ctx context.Context, w io.Writer) (int64, error)
- func (gg *Generators) WriteTo(w io.Writer) (n int64, err error)
- type Probability
- type Random
- func (b *Random) Deviation() float64
- func (b *Random) Name() string
- func (r *Random) Next() error
- func (b *Random) Point() []byte
- func (b *Random) RandomizeStart(randomizeStart bool)
- func (b *Random) SetStop(stop uint)
- func (b *Random) Step() uint
- func (b *Random) Stop() uint
- func (b *Random) Time() uint
- func (b *Random) Type() Type
- func (b *Random) TypeName() string
- func (b *Random) Value() float64
- func (b *Random) WithDeviation(deviation float64) *base
- func (b *Random) WithName(name string) *base
- func (b *Random) WithStep(step uint) *base
- func (b *Random) WriteTo(w io.Writer) (int64, error)
- type Type
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyGens = fmt.Errorf("no Generators")
ErrEmptyGens represents that there are no Generators
var ErrGenOver = fmt.Errorf("the last point reached")
ErrGenOver shows the generation is over
var ErrNewCounter = fmt.Errorf("value and deviation are meaningless")
ErrNewCounter means that the value and the deviation are meaningless
var ErrNotImplemented = fmt.Errorf("generator type is not implemented")
ErrNotImplemented represents the generator is not implemented yet
var ErrProbabilityStart = fmt.Errorf("Probability start is uncorrect")
ErrProbabilityStart is uncorrect
var ErrWrongType error = fmt.Errorf("type is not valid")
ErrWrongType represents the bad generator type name
Functions ¶
This section is empty.
Types ¶
type Const ¶
type Const struct {
// contains filtered or unexported fields
}
Const represents generator for constant values. When deviation is set, each value is calculated around the first value
func NewConst ¶
func NewConst(name string, start, stop, step uint, randomizeStart bool, value, deviation float64, probabilityStart uint8) (*Const, error)
NewConst returns new generator for constant points. Possibly it can randomize values around constant.
func (*Const) Deviation ¶
func (b *Const) Deviation() float64
Deviation returns the generator's deviation
func (*Const) Point ¶
func (b *Const) Point() []byte
Point returns the metric in carbon format, e.g. 'metric.name 123.33 1234567890\n'
func (*Const) RandomizeStart ¶
func (b *Const) RandomizeStart(randomizeStart bool)
func (*Const) TypeName ¶
func (b *Const) TypeName() string
TypeName returns the name for generator type
func (*Const) WithDeviation ¶
func (b *Const) WithDeviation(deviation float64) *base
WithDeviation deviation for the generator
func (*Const) WithName ¶
func (b *Const) WithName(name string) *base
WithName sets the metric name for generator
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter represents generator for growing-up metrics
func NewCounter ¶
func NewCounter(name string, start, stop, step uint, randomizeStart bool, value, deviation float64, probabilityStart uint8) (*Counter, error)
NewCounter returns new generator for growing points. Starting value is an increment as well. Possibly it can randomize values around increment. When deviation is set, it the next value won't be less then previous.
func (*Counter) Deviation ¶
func (b *Counter) Deviation() float64
Deviation returns the generator's deviation
func (*Counter) Point ¶
func (b *Counter) Point() []byte
Point returns the metric in carbon format, e.g. 'metric.name 123.33 1234567890\n'
func (*Counter) RandomizeStart ¶
func (b *Counter) RandomizeStart(randomizeStart bool)
func (*Counter) Stop ¶
func (b *Counter) Stop() uint
Stop returns value of stop field for the generator
func (*Counter) TypeName ¶
func (b *Counter) TypeName() string
TypeName returns the name for generator type
func (*Counter) WithDeviation ¶
func (b *Counter) WithDeviation(deviation float64) *base
WithDeviation deviation for the generator
func (*Counter) WithName ¶
func (b *Counter) WithName(name string) *base
WithName sets the metric name for generator
type Generator ¶
type Generator interface { // Next calculates next value of generator and returns ErrGenOver when the latest point is reached Next() error // Point returns the metric in carbon format, e.g. 'metric.name 123.33 1234567890\n' Point() []byte // SetStop sets the stop field for the Generator SetStop(stop uint) // Stop returns the current value for the stop field Stop() uint // WriteTo writes the point []byte representation to a given io.Writer WriteTo(io.Writer) (int64, error) }
Generator represents
type Generators ¶
type Generators struct {
// contains filtered or unexported fields
}
Generators is a slice of Generator. Next() and Point() works accordingly
func NewExpand ¶
func NewExpand(typeName, expandableName string, start, stop, step uint, randomizeStart bool, value, deviation float64, probabilityStrat uint8) (Generators, error)
NewExpand expands name as shell expansion (e.g. metric.name{1..3} will produce 3 metrics metric.name1, metric.name2 and metric.name3) and creates slice of Generator with names.
func (*Generators) List ¶
func (gg *Generators) List() []Generator
List returns the list of []Generator
func (*Generators) Next ¶
func (gg *Generators) Next() error
Next iterates over each element and calls Next. If any of calls returns an error, it breaks
func (*Generators) Point ¶
func (gg *Generators) Point() []byte
Point returns []byte representation of all generator Point() calls
func (*Generators) Randomized ¶
func (gg *Generators) Randomized() bool
Randomized shows if expanded generators have randomized start timestamp
func (*Generators) SetList ¶
func (gg *Generators) SetList(gens []Generator)
SetList replaces existing []Generator with a given one
func (*Generators) SetStop ¶
func (gg *Generators) SetStop(stop uint)
SetStop invokes the according method for each Generagor
func (*Generators) Step ¶
func (gg *Generators) Step() uint
Step returns the common step for Generators
func (*Generators) WriteAllTo ¶
func (gg *Generators) WriteAllTo(w io.Writer) (int64, error)
WriteAllTo writes all points for Generators to io.Writer
func (*Generators) WriteAllToWithContext ¶
WriteAllToWithContext writes all points, but may be stopped by the passing a struct to a stop channel
type Probability ¶ added in v0.3.0
type Probability struct {
// contains filtered or unexported fields
}
type Random ¶
type Random struct {
// contains filtered or unexported fields
}
Random works like Const, but each next value is calculated like value±deviation
func NewRandom ¶
func NewRandom(name string, start, stop, step uint, randomizeStart bool, value, deviation float64, probabilityStart uint8) (*Random, error)
NewRandom returns new generator for growing points. Without deviation it behaves like constant.
func (*Random) Deviation ¶
func (b *Random) Deviation() float64
Deviation returns the generator's deviation
func (*Random) Point ¶
func (b *Random) Point() []byte
Point returns the metric in carbon format, e.g. 'metric.name 123.33 1234567890\n'
func (*Random) RandomizeStart ¶
func (b *Random) RandomizeStart(randomizeStart bool)
func (*Random) Stop ¶
func (b *Random) Stop() uint
Stop returns value of stop field for the generator
func (*Random) TypeName ¶
func (b *Random) TypeName() string
TypeName returns the name for generator type
func (*Random) WithDeviation ¶
func (b *Random) WithDeviation(deviation float64) *base
WithDeviation deviation for the generator
func (*Random) WithName ¶
func (b *Random) WithName(name string) *base
WithName sets the metric name for generator