generator

package
v0.6.6 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MetricConstant

type MetricConstant struct {
	// contains filtered or unexported fields
}

func NewMetricConstant

func NewMetricConstant(_ time.Duration, is map[string]any) (*MetricConstant, error)

func (*MetricConstant) Emit

func (m *MetricConstant) Emit(_ *state.RunState, incoming float64) float64

func (*MetricConstant) Reconfigure

func (m *MetricConstant) Reconfigure(_ time.Duration, is map[string]any) error

type MetricConstantSpec

type MetricConstantSpec struct {
	MetricGeneratorSpec `mapstructure:",squash"`
	Value               float64 `mapstructure:"value" yaml:"value" json:"value"`
}

type MetricGenerator

type MetricGenerator interface {
	Emit(state *state.RunState, initial float64) float64
	Reconfigure(at time.Duration, spec map[string]any) error
}

func CreateMetricGenerator

func CreateMetricGenerator(mes scriptaction.ScriptAction) (MetricGenerator, error)

type MetricGeneratorSpec

type MetricGeneratorSpec struct {
	Type string `mapstructure:"type" yaml:"type" json:"type"`
}

type MetricNormalNoise added in v0.4.0

type MetricNormalNoise struct {
	// contains filtered or unexported fields
}

func NewMetricNormalNoise added in v0.4.0

func NewMetricNormalNoise(_ time.Duration, is map[string]any) (*MetricNormalNoise, error)

func (*MetricNormalNoise) Emit added in v0.4.0

func (m *MetricNormalNoise) Emit(st *state.RunState, incoming float64) float64

func (*MetricNormalNoise) Reconfigure added in v0.4.0

func (m *MetricNormalNoise) Reconfigure(_ time.Duration, is map[string]any) error

type MetricNormalNoiseSpec added in v0.4.0

type MetricNormalNoiseSpec struct {
	MetricGeneratorSpec `mapstructure:",squash"`

	// Target is the mean around which Normal noise is drawn.
	Target float64 `mapstructure:"target" yaml:"target" json:"target"`
	// StdDev is the standard deviation of the normal distribution.
	StdDev float64 `mapstructure:"stdDev"   yaml:"stdDev"   json:"stdDev"`
	// Variation is the allowed max deviation from Target (for clamping).
	Variation float64 `mapstructure:"variation" yaml:"variation" json:"variation"`
	// Direction is the direction of the noise. Can be "positive", "negative", or
	// "both".  "both" is the default.
	Direction string `mapstructure:"direction" yaml:"direction" json:"direction"`
}

MetricNormalNoise emits independent normal noise centered on Target. On each Emit(), it samples:

x ~ Normal(Target, StdDev²)

then clamps x into [Target-Variation, Target+Variation]. Emit(in) returns in + x.

type MetricPoissonNoise

type MetricPoissonNoise struct {
	// contains filtered or unexported fields
}

func NewMetricPoissonNoise

func NewMetricPoissonNoise(_ time.Duration, is map[string]any) (*MetricPoissonNoise, error)

func (*MetricPoissonNoise) Emit

func (*MetricPoissonNoise) Reconfigure

func (m *MetricPoissonNoise) Reconfigure(_ time.Duration, is map[string]any) error

type MetricPoissonNoiseSpec

type MetricPoissonNoiseSpec struct {
	MetricGeneratorSpec `mapstructure:",squash"`

	// Target is the expected events per Emit() interval.
	Target float64 `mapstructure:"target" yaml:"target" json:"target"`
	// Variation is the absolute max deviation from Target.
	Variation float64 `mapstructure:"variation" yaml:"variation" json:"variation"`
	// Direction: "positive" (default), "negative", or "both".
	Direction string `mapstructure:"direction" yaml:"direction" json:"direction"`
}

MetricPoissonNoiseSpec drives a discrete-event noise generator. On each Emit(), it draws a Poisson count with mean = Target, then clamps it to [max(0,Target−Variation) … Target+Variation] and applies directionality.

type MetricRamp

type MetricRamp struct {
	// contains filtered or unexported fields
}

func NewMetricRamp

func NewMetricRamp(at time.Duration, is map[string]any) (*MetricRamp, error)

func (*MetricRamp) Emit

func (m *MetricRamp) Emit(rs *state.RunState, value float64) float64

func (*MetricRamp) Reconfigure

func (m *MetricRamp) Reconfigure(at time.Duration, is map[string]any) error

type MetricRampSpec

type MetricRampSpec struct {
	MetricGeneratorSpec `mapstructure:",squash"`
	Start               float64       `mapstructure:"start" yaml:"start" json:"start"`
	Target              float64       `mapstructure:"target" yaml:"target" json:"target"`
	Duration            time.Duration `mapstructure:"duration" yaml:"duration" json:"duration"`
	PostEndZero         bool          `mapstructure:"postend_zero" yaml:"postend_zero" json:"postend_zero"`
}

type MetricRandomWalk

type MetricRandomWalk struct {
	// contains filtered or unexported fields
}

func NewMetricRandomWalk

func NewMetricRandomWalk(_ time.Duration, is map[string]any) (*MetricRandomWalk, error)

func (*MetricRandomWalk) Emit

func (m *MetricRandomWalk) Emit(state *state.RunState, incoming float64) float64

func (*MetricRandomWalk) Reconfigure

func (m *MetricRandomWalk) Reconfigure(_ time.Duration, is map[string]any) error

type MetricRandomWalkSpec

type MetricRandomWalkSpec struct {
	MetricGeneratorSpec `mapstructure:",squash"`
	Target              float64 `mapstructure:"target" yaml:"target" json:"target"`
	Elasticity          float64 `mapstructure:"elasticity" yaml:"elasticity" json:"elasticity"`
	StepSize            float64 `mapstructure:"stepSize" yaml:"stepSize" json:"stepSize"`
	Variation           float64 `mapstructure:"variation" yaml:"variation" json:"variation"`
}

MetricRandomWalk emits an additive, mean-reverting noise term. On each Emit(), the internal state steps like:

x ← x + elasticity*(target - x) + Uniform(−stepSize,+stepSize)

then clamps into [target−variation, target+variation]. Emit(in) returns in + x.

type MetricSpikyNoise

type MetricSpikyNoise struct {
	// contains filtered or unexported fields
}

func NewMetricSpikyNoise

func NewMetricSpikyNoise(_ time.Duration, is map[string]any) (*MetricSpikyNoise, error)

func (*MetricSpikyNoise) Emit

func (m *MetricSpikyNoise) Emit(st *state.RunState, incoming float64) float64

func (*MetricSpikyNoise) Reconfigure

func (m *MetricSpikyNoise) Reconfigure(_ time.Duration, is map[string]any) error

type MetricSpikyNoiseSpec

type MetricSpikyNoiseSpec struct {
	MetricGeneratorSpec `mapstructure:",squash"`

	// PStart: chance per interval to transition from OFF→ON (0–1).
	PStart float64 `mapstructure:"pStart" yaml:"pStart" json:"pStart"`
	// PEnd:   chance per interval to transition from ON→OFF (0–1).
	PEnd float64 `mapstructure:"pEnd"   yaml:"pEnd"   json:"pEnd"`
	// PeakTarget: mean count while in a spike.
	PeakTarget float64 `mapstructure:"peakTarget" yaml:"peakTarget" json:"peakTarget"`
	// Variation: max ± deviation around PeakTarget (clamped).
	Variation float64 `mapstructure:"variation"  yaml:"variation"  json:"variation"`
	// Direction: "positive" (default), "negative", or "both"
	Direction string `mapstructure:"direction"  yaml:"direction"  json:"direction"`
}

MetricSpikyNoiseSpec configures a mostly‐zero generator that randomly spikes with Poisson‐distributed counts when “ON”.

Jump to

Keyboard shortcuts

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