func generateRandomEvents(q queue.Queue, n int) { for id := 1; id <= n; id++ { jsonVal, _ := json.Marshal(Event{Username: "******", Timestamp: time.Now().Unix(), Event: "Start", OrderID: id, ItemID: 0, Quantity: 0, Container: 0, PicklistID: id}) q.AddTask(id, string(jsonVal)) jsonVal, _ = json.Marshal(Event{Username: "******", Timestamp: time.Now().Unix(), Event: "Pick", OrderID: id, ItemID: 1100, Quantity: 1, Container: 5, PicklistID: id}) q.AddTask(id, string(jsonVal)) jsonVal, _ = json.Marshal(Event{Username: "******", Timestamp: time.Now().Unix(), Event: "Skip", OrderID: id, ItemID: 1101, Quantity: 1, Container: 5, PicklistID: id}) q.AddTask(id, string(jsonVal)) jsonVal, _ = json.Marshal(Event{Username: "******", Timestamp: time.Now().Unix(), Event: "Stop", OrderID: id, ItemID: 0, Quantity: 0, Container: 0, PicklistID: id}) r := rand.New(rand.NewSource(time.Now().UnixNano())) if r.Int()%2 != 4 { q.AddTask(id, string(jsonVal)) } } }
func main() { var q queue.Queue q.Urls([]string{"redis://redisqueue.kaveh.me:6379"}) if *mode == "device" { generateRandomEvents(q, *insert) } else { if *workers != 0 { q.AnalyzerBuff = *workers } wsStress := analyse exitOnEmpty := func() bool { return false } q.AnalysePool(*id, exitOnEmpty, wsStress) } }