Permalink
Browse files

Fix close transaction issue.

  • Loading branch information...
Evan Weaver
Evan Weaver committed Oct 6, 2010
1 parent dc4f115 commit 5656a962455b46b65abdeb1fd490b2c6b104b646
Showing with 11 additions and 7 deletions.
  1. +9 −6 lib/kestrel/client/transactional.rb
  2. +2 −1 spec/kestrel/client/transactional_spec.rb
@@ -79,16 +79,19 @@ def retry(item = nil)
job.retries += 1
- if should_retry = job.retries < @max_retries
+ if job.retries == 1
client.set(current_queue + "_errors", job)
+ close_transaction(current_queue)
+ true
+ elsif job.retries < @max_retries
+ client.set(current_queue + "_errors", job)
+ close_transaction(current_queue + "_errors")
+ true
else
+ close_transaction(current_queue + "_errors")
+ # No longer have an active job
@current_queue = nil
end
-
- # close the transaction on the original queue
- close_transaction(job.retries == 1 ? current_queue : "#{current_queue}_errors")
-
- should_retry
end
private
@@ -150,8 +150,9 @@
Kestrel::Client::Transactional::RetryableJob.new(Kestrel::Client::Transactional::DEFAULT_RETRIES - 1, :mcmuffin)
end
mock(@raw_kestrel_client).set(@queue + "_errors", anything).never
+ mock(@raw_kestrel_client).get_from_last(@queue + "_errors/close")
@kestrel.get(@queue)
- @kestrel.retry.should be_false
+ @kestrel.retry.should be_nil
end
it "closes an open transaction with no retries" do

0 comments on commit 5656a96

Please sign in to comment.