Permalink
Browse files

minor: rename send_message_with_acknowledge to send_message_with_gle

  • Loading branch information...
1 parent 43c6c1f commit 0e746be65455281ed48b2337a9af79ead38cb1e8 @TylerBrock TylerBrock committed Nov 19, 2012
View
@@ -420,7 +420,7 @@ def remove(selector={}, opts={})
instrument(:remove, :database => @db.name, :collection => @name, :selector => selector) do
if Mongo::WriteConcern.gle?(write_concern)
- @connection.send_message_with_acknowledge(Mongo::Constants::OP_DELETE, message, @db.name, nil, write_concern)
+ @connection.send_message_with_gle(Mongo::Constants::OP_DELETE, message, @db.name, nil, write_concern)
else
@connection.send_message(Mongo::Constants::OP_DELETE, message)
true
@@ -475,7 +475,7 @@ def update(selector, document, opts={})
instrument(:update, :database => @db.name, :collection => @name, :selector => selector, :document => document) do
if Mongo::WriteConcern.gle?(write_concern)
- @connection.send_message_with_acknowledge(Mongo::Constants::OP_UPDATE, message, @db.name, nil, write_concern)
+ @connection.send_message_with_gle(Mongo::Constants::OP_UPDATE, message, @db.name, nil, write_concern)
else
@connection.send_message(Mongo::Constants::OP_UPDATE, message)
end
@@ -1048,7 +1048,7 @@ def insert_documents(documents, collection_name=@name, check_keys=true, write_co
instrument(:insert, :database => @db.name, :collection => collection_name, :documents => documents) do
if Mongo::WriteConcern.gle?(write_concern)
- @connection.send_message_with_acknowledge(Mongo::Constants::OP_INSERT, message, @db.name, nil, write_concern)
+ @connection.send_message_with_gle(Mongo::Constants::OP_INSERT, message, @db.name, nil, write_concern)
else
@connection.send_message(Mongo::Constants::OP_INSERT, message)
end
View
@@ -56,7 +56,7 @@ def send_message(operation, message, opts={})
# @see DB#get_last_error for valid last error params.
#
# @return [Hash] The document returned by the call to getlasterror.
- def send_message_with_acknowledge(operation, message, db_name, log_message=nil, last_error_params=false)
+ def send_message_with_gle(operation, message, db_name, log_message=nil, last_error_params=false)
docs = num_received = cursor_id = ''
add_message_headers(message, operation)
@@ -210,7 +210,7 @@ def read_documents(number_received, sock)
end
# Constructs a getlasterror message. This method is used exclusively by
- # Client#send_message_with_acknowledge.
+ # Client#send_message_with_gle.
#
# Because it modifies message by reference, we don't need to return it.
def build_last_error_message(message, db_name, opts)
@@ -361,7 +361,7 @@ def test_connection_activity
end
end
- should "close the connection on send_message_with_acknowledge for major exceptions" do
+ should "close the connection on send_message_with_gle for major exceptions" do
@con.expects(:checkout_writer).raises(SystemStackError)
@con.expects(:close)
begin
@@ -98,7 +98,7 @@ def test_accessors
end
end
- should "close the connection on send_message_with_acknowledge for major exceptions" do
+ should "close the connection on send_message_with_gle for major exceptions" do
@client.expects(:checkout_writer).raises(SystemStackError)
@client.expects(:close)
begin
View
@@ -14,7 +14,7 @@ class ClientTest < Test::Unit::TestCase
@client.connect
end
- should "acknowledge writes by default" do
+ should "gle writes by default" do
assert_equal 1, @client.write_concern[:w]
end
@@ -13,7 +13,7 @@ class CollectionTest < Test::Unit::TestCase
@client = Client.new('localhost', 27017, :logger => @logger, :connect => false)
@db = @client['testing']
@coll = @db.collection('books')
- @client.expects(:send_message_with_acknowledge).with do |op, msg, log|
+ @client.expects(:send_message_with_gle).with do |op, msg, log|
op == 2001
end
@coll.stubs(:log_operation)
@@ -24,7 +24,7 @@ class CollectionTest < Test::Unit::TestCase
@client = Client.new('localhost', 27017, :logger => @logger, :connect => false)
@db = @client['testing']
@coll = @db.collection('books')
- @client.expects(:send_message_with_acknowledge).with do |op, msg, log|
+ @client.expects(:send_message_with_gle).with do |op, msg, log|
op == 2002
end
@coll.expects(:log_operation).with do |name, payload|
@@ -50,7 +50,7 @@ class CollectionTest < Test::Unit::TestCase
@db = @client['testing']
@coll = @db.collection('books')
data = BSON::Binary.new(("BINARY " * 1000).unpack("c*"))
- @client.expects(:send_message_with_acknowledge).with do |op, msg, log|
+ @client.expects(:send_message_with_gle).with do |op, msg, log|
op == 2002
end
@coll.expects(:log_operation).with do |name, payload|
@@ -63,7 +63,7 @@ class CollectionTest < Test::Unit::TestCase
@client = Client.new('localhost', 27017, :logger => @logger, :connect => false)
@db = @client['testing']
@coll = @db.collection('books')
- @client.expects(:send_message_with_acknowledge).with do |op, msg, db_name, log|
+ @client.expects(:send_message_with_gle).with do |op, msg, db_name, log|
op == 2001
end
@coll.expects(:log_operation).with do |name, payload|
@@ -76,7 +76,7 @@ class CollectionTest < Test::Unit::TestCase
@client = Connection.new('localhost', 27017, :logger => @logger, :connect => false)
@db = @client['testing']
@coll = @db.collection('books')
- @client.expects(:send_message_with_acknowledge).with do |op, msg, db_name, log|
+ @client.expects(:send_message_with_gle).with do |op, msg, db_name, log|
op == 2001
end
@coll.expects(:log_operation).with do |name, payload|
@@ -89,7 +89,7 @@ class CollectionTest < Test::Unit::TestCase
@client = Client.new('localhost', 27017, :logger => @logger, :connect => false)
@db = @client['testing']
@coll = @db.collection('books')
- @client.expects(:send_message_with_acknowledge).with do |op, msg, db_name, log|
+ @client.expects(:send_message_with_gle).with do |op, msg, db_name, log|
op == 2001
end
@coll.stubs(:log_operation)
@@ -100,7 +100,7 @@ class CollectionTest < Test::Unit::TestCase
@client = Connection.new('localhost', 27017, :logger => @logger, :connect => false)
@db = @client['testing']
@coll = @db.collection('books')
- @client.expects(:send_message_with_acknowledge).with do |op, msg, db_name, log|
+ @client.expects(:send_message_with_gle).with do |op, msg, db_name, log|
op == 2001
end
@coll.stubs(:log_operation)
View
@@ -59,15 +59,15 @@ class WriteConcernTest < Test::Unit::TestCase
end
should "use default value on insert" do
- @client.expects(:send_message_with_acknowledge).with do |op, msg, log, n, safe|
+ @client.expects(:send_message_with_gle).with do |op, msg, log, n, safe|
safe == @safe_value
end
@col.insert({:a => 1})
end
should "allow override alternate value on insert" do
- @client.expects(:send_message_with_acknowledge).with do |op, msg, log, n, safe|
+ @client.expects(:send_message_with_gle).with do |op, msg, log, n, safe|
safe == {:w => 100, :j => false, :fsync => false, :wtimeout => false}
end
@@ -80,15 +80,15 @@ class WriteConcernTest < Test::Unit::TestCase
end
should "use default value on update" do
- @client.expects(:send_message_with_acknowledge).with do |op, msg, log, n, safe|
+ @client.expects(:send_message_with_gle).with do |op, msg, log, n, safe|
safe == @safe_value
end
@col.update({:a => 1}, {:a => 2})
end
should "allow override alternate value on update" do
- @client.expects(:send_message_with_acknowledge).with do |op, msg, log, n, safe|
+ @client.expects(:send_message_with_gle).with do |op, msg, log, n, safe|
safe == {:w => 100, :j => false, :fsync => false, :wtimeout => false}
end
@@ -101,15 +101,15 @@ class WriteConcernTest < Test::Unit::TestCase
end
should "use default value on remove" do
- @client.expects(:send_message_with_acknowledge).with do |op, msg, log, n, safe|
+ @client.expects(:send_message_with_gle).with do |op, msg, log, n, safe|
safe == @safe_value
end
@col.remove
end
should "allow override alternate value on remove" do
- @client.expects(:send_message_with_acknowledge).with do |op, msg, log, n, safe|
+ @client.expects(:send_message_with_gle).with do |op, msg, log, n, safe|
safe == {:w => 100, :j => false, :fsync => false, :wtimeout => false}
end
@@ -61,21 +61,21 @@ class WriteConcernTest < Test::Unit::TestCase
end
end
- context "on operations supporting 'acknowledged' mode" do
+ context "on operations supporting 'gle' mode" do
setup do
@collection = @client['foo']['bar']
end
should "use default value on insert" do
- @client.expects(:send_message_with_acknowledge).with do |op, msg, log, n, wc|
+ @client.expects(:send_message_with_gle).with do |op, msg, log, n, wc|
wc == @write_concern
end
@collection.insert({:a => 1})
end
should "allow override alternate value on insert" do
- @client.expects(:send_message_with_acknowledge).with do |op, msg, log, n, wc|
+ @client.expects(:send_message_with_gle).with do |op, msg, log, n, wc|
wc == {:w => 100, :j => false, :fsync => false, :wtimeout => false}
end
@@ -88,15 +88,15 @@ class WriteConcernTest < Test::Unit::TestCase
end
should "use default value on update" do
- @client.expects(:send_message_with_acknowledge).with do |op, msg, log, n, wc|
+ @client.expects(:send_message_with_gle).with do |op, msg, log, n, wc|
wc == @write_concern
end
@collection.update({:a => 1}, {:a => 2})
end
should "allow override alternate value on update" do
- @client.expects(:send_message_with_acknowledge).with do |op, msg, log, n, wc|
+ @client.expects(:send_message_with_gle).with do |op, msg, log, n, wc|
wc == {:w => 100, :j => false, :fsync => false, :wtimeout => false}
end
@@ -109,15 +109,15 @@ class WriteConcernTest < Test::Unit::TestCase
end
should "use default value on remove" do
- @client.expects(:send_message_with_acknowledge).with do |op, msg, log, n, wc|
+ @client.expects(:send_message_with_gle).with do |op, msg, log, n, wc|
wc == @write_concern
end
@collection.remove
end
should "allow override alternate value on remove" do
- @client.expects(:send_message_with_acknowledge).with do |op, msg, log, n, wc|
+ @client.expects(:send_message_with_gle).with do |op, msg, log, n, wc|
wc == {:w => 100, :j => false, :fsync => false, :wtimeout => false}
end

5 comments on commit 0e746be

@brandonblack
Contributor

You sure? This is shorter, but it doesn't match the terms we're standardizing on which was my reason for changing it.

w=-1: errors ignored
w=0: unacknowledged
w=1: acknowledged
w=2: replica acknowledged
j=true: journaled
fsync=true: fsynced

@brandonblack
Contributor

I would also discourage the practice of using acronyms like gle for the sake of readability. I don't think that's good at all.

@estolfo
Member
@brandonblack
Contributor

It's true that it's not external (or meant to be anyway) so it's not a huge deal, but what's the harm in standardizing all of our internal terminology as well? Helps with readability, no?

Put another way, what value is added in using different set of terminology internally than our external interface uses? It saves a few characters, but at the cost of inconsistency IMO.

@TylerBrock
Contributor
Please sign in to comment.