func write() { goenv := goenv.DefaultGoenv() testQueue := redismq.NewQueue(goenv, "example") payload := randomString(1024 * 1) //adjust for size for { testQueue.Put(payload) } }
func main() { runtime.GOMAXPROCS(5) goenv := goenv.DefaultGoenv() go write() go read("1") go read("2") //go read("3") redismq.NewOverseer(goenv) select {} }
func read(prefix string) { goenv := goenv.DefaultGoenv() testQueue := redismq.NewQueue(goenv, "example") consumer, err := testQueue.AddConsumer("testconsumer" + prefix) if err != nil { panic(err) } consumer.ResetWorking() for { p, err := consumer.Get() if err != nil { log.Println(err) continue } err = p.Ack() } }
func main() { goenv := goenv.DefaultGoenv() testQueue := redismq.NewQueue(goenv, "clicks") for i := 0; i < 10; i++ { testQueue.Put("testpayload") } consumer, err := testQueue.AddConsumer("testconsumer") if err != nil { panic(err) } for i := 0; i < 10; i++ { p, err := consumer.Get() if err != nil { fmt.Println(err) continue } fmt.Println(p.CreatedAt) err = p.Ack() if err != nil { fmt.Println(err) } } }