Beispiel #1
0
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)
}
Beispiel #2
0
func initOriginalQueue(queue *goqless.Queue) (err error) {

	var klass string
	depends := []string{}

	for i := 0; i < jobs_count; i++ {
		if i%2 == 0 {
			klass = "klass.Add"
		} else {
			klass = "klass.Sub"
		}
		tags := []string{"e", "__call", "_haha", strconv.Itoa(i)}
		queue.Put("", klass, `"dataJson"`, delay, i, tags, retries, depends)
	}

	return
}