// 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 }
Context("called with a key and a conn", func() { BeforeEach(func() { sut = claimablejob.New("old-map", redisConn) }) It("should set the key", func() { Expect(sut.GetKey()).To(Equal("old-map")) }) }) }) Describe("NewFromJob", func() { Context("called with a job", func() { BeforeEach(func() { job := new(DumbJob) sut = claimablejob.NewFromJob(job, redisConn) }) It("should set the key", func() { Expect(sut.GetKey()).To(Equal("I am dumb")) }) }) }) Describe("Claim", func() { Context("When the job is unset", func() { BeforeEach(func() { sut = claimablejob.New("faulty", redisConn) _, err := redisConn.Do("DEL", "[namespace]-faulty") Expect(err).To(BeNil()) })