// Process processes the circular work queue and dump jobs into the linear work queue func (redisProcessQueue *RedisProcessQueue) Process() error { conn, err := redisProcessQueue.conn() if err != nil { return err } queue := circularqueue.New(conn) job, err := queue.Pop() if err != nil { return err } claimableJob := claimablejob.NewFromJob(job, conn) if claimed, err := claimableJob.Claim(); err != nil { return err } else if !claimed { return nil } claimableJob.PushKeyIntoQueue("linear-job-queue") return nil }
var result interface{} var sut circularqueue.Queue BeforeEach(func() { var err error redisConn, err = redis.Dial("tcp", ":6379") Expect(err).To(BeNil()) }) AfterEach(func() { redisConn.Close() }) Context("Pop", func() { It("should have a Pop", func() { sut := circularqueue.New(redisConn) job, err := sut.Pop() Expect(err).To(BeNil()) Expect(job).NotTo(BeNil()) }) Context("When there are two records in redis", func() { BeforeEach(func() { var err error _, err = redisConn.Do("DEL", "circular-job-queue") Expect(err).To(BeNil()) _, err = redisConn.Do("RPUSH", "circular-job-queue", "A", "B") Expect(err).To(BeNil())