Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #42 from bkeepers/kill-requeue

Requeue is not in use. Removing it from spec and use.
  • Loading branch information...
commit d004be174caa5e400b17026dd06a83d382f200b2 2 parents 6fb98c8 + 2ac9cd9
@bkeepers authored
View
12 lib/qu/backend/mongo.rb
@@ -96,16 +96,6 @@ def failed(payload, error)
def completed(payload)
end
- def requeue(id)
- logger.debug "Requeuing job #{id}"
- doc = jobs('failed').find_and_modify(:query => {:_id => id}, :remove => true) || raise(::Mongo::OperationFailure)
- jobs(doc.delete('queue')).insert(doc)
- doc['id'] = doc.delete('_id')
- Payload.new(doc)
- rescue ::Mongo::OperationFailure
- false
- end
-
def register_worker(worker)
logger.debug "Registering worker #{worker.id}"
self[:workers].insert(worker.attributes.merge(:id => worker.id))
@@ -153,4 +143,4 @@ def rescue_connection_failure
end
end
-end
+end
View
11 lib/qu/backend/redis.rb
@@ -71,17 +71,6 @@ def completed(payload)
redis.del("job:#{payload.id}")
end
- def requeue(id)
- logger.debug "Requeuing job #{id}"
- if payload = get(id)
- redis.lrem('queue:failed', 1, id)
- redis.rpush("queue:#{payload.queue}", id)
- payload
- else
- false
- end
- end
-
def register_worker(worker)
logger.debug "Registering worker #{worker.id}"
redis.set("worker:#{worker.id}", encode(worker.attributes))
View
38 lib/qu/backend/spec.rb
@@ -200,44 +200,6 @@ def timeout(count = 0.1, &block)
end
end
- describe 'requeue' do
- context 'with a failed job' do
- before do
- subject.enqueue(payload)
- subject.reserve(worker).id.should == payload.id
- subject.failed(payload, Exception.new)
- end
-
- it 'should add the job back on the queue' do
- subject.length(payload.queue).should == 0
- subject.requeue(payload.id)
- subject.length(payload.queue).should == 1
-
- p = subject.reserve(worker)
- p.should be_instance_of(Qu::Payload)
- p.id.should == payload.id
- p.klass.should == payload.klass
- p.args.should == payload.args
- end
-
- it 'should remove the job from the failed jobs' do
- subject.length('failed').should == 1
- subject.requeue(payload.id)
- subject.length('failed').should == 0
- end
-
- it 'should return the job' do
- subject.requeue(payload.id).id.should == payload.id
- end
- end
-
- context 'without a failed job' do
- it 'should return false' do
- subject.requeue('1').should be_false
- end
- end
- end
-
describe 'register_worker' do
it 'should add worker to array of workers' do
subject.register_worker(worker)
Please sign in to comment.
Something went wrong with that request. Please try again.