Skip to content

Commit

Permalink
random origins added to demo mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter committed Apr 2, 2024
1 parent 8558e1e commit f558c6b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion modes/demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package modes
import (
"context"
"encoding/json"
"math/rand"
"strings"
"time"

Expand Down Expand Up @@ -33,7 +34,20 @@ func GenerateRandomData(jsonFormat bool, numPerSec int, ch chan Message, ctx con
} else {
msg = generateTextRandomData()
}
produce(ch, msg, MessageTypeStdout, nil)

mo := MessageOrigin{}

if rand.Intn(100) >= 50 {
mo.File = []string{"foo1.log", "foo2.log", "foo3.log"}[rand.Intn(3)]
} else {
mo.Port = []string{"4356", "4333", "4262"}[rand.Intn(3)]
}
if rand.Intn(100) >= 90 {
mo.File = ""
mo.Port = ""
}

produce(ch, msg, MessageTypeStdout, &mo)
time.Sleep(time.Duration((1 / float64(numPerSec)) * float64(time.Second)))
}

Expand Down

0 comments on commit f558c6b

Please sign in to comment.