Skip to main content

Generator configuration

timeMultiplier

Commentary​

added in 0.5.7

global configuration

Changes the rate at which wallclock speed advances. Higher numbers speed time up. Lower numbers slow time down.

For example, a factor of 4 speeds time up by 4x, whereas a factor of .25 slows time down by 4x. A value of 1 matches the real clock speed and won't change anything.

The effect is that slower wallclock speeds allow generators to do more work in a given interval of wallclock time, and faster speeds allow generators to do less work.

The factor can be dynamic and chosen from a function. 1


Examples​

Speeding time up​

Use a value greater than 1 to speed time up. This example runs wallclock speed at 4x faster than its normal pace.

{
"generators": [
{
"topic": "sandbox",
"value": {
"now": {
"_gen": "formatDateTime",
"ms": {
"_gen": "now"
}
}
}
}
],
"globalConfigs": {
"timeMultiplier": 4
},
"connections": {
"kafka": {
"kind": "kafka",
"producerConfigs": {
"bootstrap.servers": "localhost:9092",
"key.serializer": "io.shadowtraffic.kafka.serdes.JsonSerializer",
"value.serializer": "io.shadowtraffic.kafka.serdes.JsonSerializer"
}
}
}
}

Slowing time down​

Use a value less than 1 to slow time down. This example runs wallclock speed at 4x slower than its normal pace.

{
"generators": [
{
"topic": "sandbox",
"value": {
"now": {
"_gen": "formatDateTime",
"ms": {
"_gen": "now"
}
}
}
}
],
"globalConfigs": {
"timeMultiplier": 0.25
},
"connections": {
"kafka": {
"kind": "kafka",
"producerConfigs": {
"bootstrap.servers": "localhost:9092",
"key.serializer": "io.shadowtraffic.kafka.serdes.JsonSerializer",
"value.serializer": "io.shadowtraffic.kafka.serdes.JsonSerializer"
}
}
}
}

Varying the speed​

Use functions to dynamically choose the rate. In this example, every other minute slows time down by 2x, and all other moments in time are sped up to 100x.

{
"generators": [
{
"topic": "sandbox",
"value": {
"now": {
"_gen": "formatDateTime",
"ms": {
"_gen": "now"
}
}
}
}
],
"globalConfigs": {
"timeMultiplier": {
"_gen": "intervals",
"intervals": [
[
"*/2 * * * *",
0.5
]
],
"defaultValue": 100
}
},
"connections": {
"kafka": {
"kind": "kafka",
"producerConfigs": {
"bootstrap.servers": "localhost:9092",
"key.serializer": "io.shadowtraffic.kafka.serdes.JsonSerializer",
"value.serializer": "io.shadowtraffic.kafka.serdes.JsonSerializer"
}
}
}
}

Specification​

JSON schema​

{
"oneOf": [
{
"type": "number"
},
{
"type": "object",
"properties": {
"_gen": {
"type": "string"
}
},
"required": [
"_gen"
]
}
]
}