Browse files

rename Reliable proxy to Transactional proxy

  • Loading branch information...
1 parent c6d100d commit 7f1eafa7f2528aa687d200003bd16176f484d930 @freels committed Sep 29, 2010
View
8 lib/kestrel/client.rb
@@ -10,7 +10,7 @@ class Client < Memcached
autoload :Unmarshal, 'kestrel/client/unmarshal'
autoload :Namespace, 'kestrel/client/namespace'
autoload :Json, 'kestrel/client/json'
- autoload :Reliable, "kestrel/client/reliable"
+ autoload :Transactional, "kestrel/client/transactional"
KESTREL_OPTIONS = [:gets_per_server, :exception_retry_limit, :get_timeout_ms].freeze
@@ -100,9 +100,9 @@ def set(key, value, ttl=0, raw=false)
# allows collision-avoiding options support.
#
# ==== Options (opts)
- # :open<Boolean>:: Begins a reliable read.
- # :close<Boolean>:: Ends a reliable read.
- # :abort<Boolean>:: Cancels an existing reliable read
+ # :open<Boolean>:: Begins a transactional read.
+ # :close<Boolean>:: Ends a transactional read.
+ # :abort<Boolean>:: Cancels an existing transactional read
# :peek<Boolean>:: Return the head of the queue, without removal
# :timeout<Integer>:: Milliseconds to block for a new item
# :raw<Boolean>:: Toggles Marshalling. Equivalent to the "old
View
2 lib/kestrel/client/reliable.rb → lib/kestrel/client/transactional.rb
@@ -1,4 +1,4 @@
-class Kestrel::Client::Reliable < Kestrel::Client::Proxy
+class Kestrel::Client::Transactional < Kestrel::Client::Proxy
# Raised when a caller attempts to use this proxy across
# multiple queues.
View
28 spec/kestrel/client/reliable_spec.rb → spec/kestrel/client/transactional_spec.rb
@@ -1,10 +1,10 @@
require 'spec/spec_helper'
-describe "Kestrel::Client::Reliable" do
+describe "Kestrel::Client::Transactional" do
describe "Instance Methods" do
before do
@raw_kestrel_client = Kestrel::Client.new(*Kestrel::Config.default)
- @kestrel = Kestrel::Client::Reliable.new(@raw_kestrel_client, nil, nil, 1)
+ @kestrel = Kestrel::Client::Transactional.new(@raw_kestrel_client, nil, nil, 1)
stub(@kestrel).rand { 1 }
@queue = "some_queue"
end
@@ -17,35 +17,35 @@
end
it "gets from the error queue ERROR_PROCESSING_RATE pct. of the time" do
- mock(@kestrel).rand { Kestrel::Client::Reliable::ERROR_PROCESSING_RATE - 0.05 }
+ mock(@kestrel).rand { Kestrel::Client::Transactional::ERROR_PROCESSING_RATE - 0.05 }
mock(@raw_kestrel_client).get(@queue + "_errors", anything) { :mcguffin }
mock(@raw_kestrel_client).get(@queue, anything).never
@kestrel.get(@queue).should == :mcguffin
end
it "falls through to the normal queue when error queue is empty" do
- mock(@kestrel).rand { Kestrel::Client::Reliable::ERROR_PROCESSING_RATE - 0.05 }
+ mock(@kestrel).rand { Kestrel::Client::Transactional::ERROR_PROCESSING_RATE - 0.05 }
mock(@raw_kestrel_client).get(@queue + "_errors", anything) { nil }
mock(@raw_kestrel_client).get(@queue, anything) { :mcguffin }
@kestrel.get(@queue).should == :mcguffin
end
it "gets from the normal queue most of the time" do
- mock(@kestrel).rand { Kestrel::Client::Reliable::ERROR_PROCESSING_RATE + 0.05 }
+ mock(@kestrel).rand { Kestrel::Client::Transactional::ERROR_PROCESSING_RATE + 0.05 }
mock(@raw_kestrel_client).get(@queue, anything) { :mcguffin }
mock(@raw_kestrel_client).get(@queue + "_errors", anything).never
@kestrel.get(@queue).should == :mcguffin
end
it "falls through to the error queue when normal queue is empty" do
- mock(@kestrel).rand { Kestrel::Client::Reliable::ERROR_PROCESSING_RATE + 0.05 }
+ mock(@kestrel).rand { Kestrel::Client::Transactional::ERROR_PROCESSING_RATE + 0.05 }
mock(@raw_kestrel_client).get(@queue, anything) { nil }
mock(@raw_kestrel_client).get(@queue + "_errors", anything) { :mcguffin }
@kestrel.get(@queue).should == :mcguffin
end
it "is nil when both queues are empty" do
- mock(@kestrel).rand { Kestrel::Client::Reliable::ERROR_PROCESSING_RATE + 0.05 }
+ mock(@kestrel).rand { Kestrel::Client::Transactional::ERROR_PROCESSING_RATE + 0.05 }
mock(@raw_kestrel_client).get(@queue, anything) { nil }
mock(@raw_kestrel_client).get(@queue + "_errors", anything) { nil }
@kestrel.get(@queue).should be_nil
@@ -54,7 +54,7 @@
it "returns the payload of a RetryableJob" do
stub(@kestrel).rand { 0 }
mock(@raw_kestrel_client).get(@queue + "_errors", anything) do
- Kestrel::Client::Reliable::RetryableJob.new(1, :mcmuffin)
+ Kestrel::Client::Transactional::RetryableJob.new(1, :mcmuffin)
end
@kestrel.get(@queue).should == :mcmuffin
@@ -72,7 +72,7 @@
it "closes an open transaction with retries" do
stub(@kestrel).rand { 0 }
stub(@raw_kestrel_client).get(@queue + "_errors", anything) do
- Kestrel::Client::Reliable::RetryableJob.new(1, :mcmuffin)
+ Kestrel::Client::Transactional::RetryableJob.new(1, :mcmuffin)
end
@kestrel.get(@queue)
@@ -86,7 +86,7 @@
lambda do
@kestrel.get("transaction_fail")
- end.should raise_error(Kestrel::Client::Reliable::MultipleQueueException)
+ end.should raise_error(Kestrel::Client::Transactional::MultipleQueueException)
end
end
@@ -105,7 +105,7 @@
it "returns 1 plus the number of tries for a RetryableJob" do
stub(@kestrel).rand { 0 }
mock(@raw_kestrel_client).get(@queue + "_errors", anything) do
- Kestrel::Client::Reliable::RetryableJob.new(1, :mcmuffin)
+ Kestrel::Client::Transactional::RetryableJob.new(1, :mcmuffin)
end
@kestrel.get(@queue)
@kestrel.current_try.should == 2
@@ -131,7 +131,7 @@
it "increments the retry count and re-enqueues the retried job" do
stub(@kestrel).rand { 0 }
stub(@raw_kestrel_client).get(@queue + "_errors", anything) do
- Kestrel::Client::Reliable::RetryableJob.new(1, :mcmuffin)
+ Kestrel::Client::Transactional::RetryableJob.new(1, :mcmuffin)
end
mock(@raw_kestrel_client).set(@queue + "_errors", anything) do |queue, job|
@@ -146,7 +146,7 @@
it "does not enqueue the retried job after too many tries" do
stub(@kestrel).rand { 0 }
stub(@raw_kestrel_client).get(@queue + "_errors", anything) do
- Kestrel::Client::Reliable::RetryableJob.new(Kestrel::Client::Reliable::DEFAULT_RETRIES - 1, :mcmuffin)
+ Kestrel::Client::Transactional::RetryableJob.new(Kestrel::Client::Transactional::DEFAULT_RETRIES - 1, :mcmuffin)
end
mock(@raw_kestrel_client).set(@queue + "_errors", anything).never
@kestrel.get(@queue)
@@ -164,7 +164,7 @@
it "closes an open transaction with retries" do
stub(@kestrel).rand { 0 }
stub(@raw_kestrel_client).get(@queue + "_errors", anything) do
- Kestrel::Client::Reliable::RetryableJob.new(1, :mcmuffin)
+ Kestrel::Client::Transactional::RetryableJob.new(1, :mcmuffin)
end
@kestrel.get(@queue)

0 comments on commit 7f1eafa

Please sign in to comment.