func handlePerQueue(queue *goqless.Queue, num int) { client, err := goqless.Dial("127.0.0.1", "6379") if err != nil { log.Println("Dial err:", err) } defer client.Close() queueStr := "queue_name_" + strconv.Itoa(num) readyQueue := client.Queue(queueStr) for i := 0; i < queues_capacity; i++ { jobs, err := queue.Pop(1) if err != nil { log.Println("pop failed, count:", len(jobs), " err:", err) return } else { // log.Printf("jobs :%+v", jobs[0].History) } jobPut, err := readyQueue.Put(queueStr+"lll_"+strconv.Itoa(i), jobs[0].Klass, "***dataJsondddd", delay, jobs[0].Priority, jobs[0].Tags, jobs[0].Retries, jobs[0].Dependents) if err != nil { log.Println("put failed, err:", err) continue } //testJobMoveFailRetry(i, jobs[0]) jobs[0].Complete() //log.Printf("---jobPut:%+v, queue:%+v", jobs[0], jobs[0].Queue) log.Println("==jobPut : ", jobPut, " jobsPut.Priority:", jobs[0].Priority, "\n") } startWorkers(queueStr) }
func startWorkers(queueStr string) (err error) { log.Println("worker queues", queueStr) startWorker := func(queueStr string) { client, err := goqless.Dial("127.0.0.1", "6379") if err != nil { log.Println("Dial err:", err) } defer client.Close() worker_x, err := initWorker(client, queueStr) if err != nil { log.Println("initWorker failed, err:", err) } log.Printf("qStr:%v, cli:%+v", queueStr, client) // client.SetConfig("heartbeat", 120) worker_x.Start() } go startWorker(queueStr) go startWorker(queueStr) time.Sleep(10 * time.Second) return }
func main() { log.SetFlags(log.Lshortfile | log.Ltime) client, err := goqless.Dial("127.0.0.1", "6379") if err != nil { log.Println("Dial err:", err) } defer client.Close() originalQueue := client.Queue(original_queue) err = initOriginalQueue(originalQueue) if err != nil { log.Println("initQueue failed, err:", err) } batchJobs(originalQueue) select {} }