Documentation
¶
Overview ¶
Package eventsim enables deploying event simulation streams, by setting the "source" field in the stream spec to "eventsim".
Index ¶
Constants ¶
const ( SourceTypeId = "eventsim" DefaultMaxFractionDigits = 2 DefaultSimResolutionMilliseconds = 5000 EventGenTypeRandom = "random" EventGenTypeSinusoid = "sinusoid" TimestampLayoutIsoSeconds = "2006-01-02T15:04:05Z" TimestampLayoutIsoMillis = "2006-01-02T15:04:05.000Z" TimestampLayoutIsoMicros = "2006-01-02T15:04:05.000000Z" )
Variables ¶
var DefaultCharset = []rune("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")
Functions ¶
func NewExtractorFactory ¶
func NewExtractorFactory(charsets map[string][]rune) entity.ExtractorFactory
Types ¶
type EventGeneration ¶
type EventGeneration struct { Type string `json:"type"` MinCount int `json:"minCount"` MaxCount int `json:"maxCount"` PeriodSeconds int `json:"periodSeconds"` PeakTime string `json:"peakTime"` }
EventGeneration specifies how many events should be generated for each trigger.
"Type" can be one of the following:
"random" --> random value between "MinCount" and "MaxCount" "sinosoid" --> the number of events generated over time has a sine wave form with period specified in "PeriodSeconds", peak-to-peak amplitude in "MaxCount" - "MinCount", and the timestamp for a peak time in "PeakTime" (required layout: TimestampLayoutIsoSeconds). To achieve a less perfect wave, use the Jitter option with a specified randomized timestamp field. "" --> If empty string (or json field omitted) a single event will be generated for each sim resolution trigger.
type EventSpec ¶
type EventSpec struct {
Fields []FieldSpec `json:"fields"`
}
EventSpec specifies the event schema
type ExtractorFactory ¶
type ExtractorFactory struct {
// contains filtered or unexported fields
}
func (*ExtractorFactory) NewExtractor ¶
func (*ExtractorFactory) SourceId ¶
func (ef *ExtractorFactory) SourceId() string
type FieldFrequencyRange ¶
FieldFrequencyRange is used for internal conversion of any provided dimensions that should be randomized with a given distribution.
type FieldSpec ¶
type FieldSpec struct { // Name of the field on sjson format (see github.com/tidwall/sjson) Field string `json:"field"` // One of the below options can be present in each field spec PredefinedValues []PredefinedValue `json:"predefinedValues"` RandomizedValue *RandomizedValue `json:"randomizedValue"` }
FieldSpec specifies how each field should be generated
type PredefinedValue ¶
type PredefinedValue struct { // Value can be any json scalar value (string, number, boolean, null) Value any `json:"value"` // FrequencyFactor specifies the probability of each provided pre-defined value // to be set. Any value can be used here, but obviously having the sum for all // items being 10 or 100 is the easiest for achieving expected distribution. FrequencyFactor int `json:"frequencyFactor"` }
PredefinedValue enables a field to have one of many provided values set with a probability based on the FrequencyFactor.
type RandomizedValue ¶
type RandomizedValue struct { // Type is mandatory and have the following supported values: // // "int", "integer" // "float" // "string" // "bool" // "isoTimestampMilliseconds" // "isoTimestampMicroseconds" // "uuid" // // Any other value will lead to an error notification on the notify chan. // Type string `json:"type"` // Min and Max specifies the range of the randomized value Min float64 `json:"min"` Max float64 `json:"max"` // Charset is only applicable for "string" type and specifies which character set // to use for string generation. If omitted a default character set will be used. // If a value is provided here it needs to have a matching character set added as // part of factory creation input config. Charset string `json:"charset"` // MaxFractionDigits is only applicable for "float" type and specifies how many // fraction digits should be provided. If omitted DefaultMaxFractionDigits will // be used. MaxFractionDigits int `json:"maxFractionDigits"` // only applicable for float types // JitterMilliseconds is only applicable for the timestamp types and adds a +-delta // duration to the current timestamp, based on a random value from 0 to JitterMilliseconds. JitterMilliseconds int `json:"jitterMilliseconds"` }
RandomizedValue generates a random value for a field.
type SourceSpec ¶ added in v0.6.3
type SourceSpec struct { // The trigger interval for each event generation execution. If set to 0 or omitted // in the spec, it will be set to DefaultSimResolutionMilliseconds. SimResolutionMilliseconds int `json:"simResolutionMilliseconds"` // Event schema and field generation specifications EventGeneration EventGeneration `json:"eventGeneration"` EventSpec EventSpec `json:"eventSpec"` }
SourceSpec specifies the schema of the source part of the stream spec