Permalink
Browse files

RUBY-494 rename all the things! standardizing class names across drivers

Mongo::Connection -> Mongo::MongoClient
Mongo::ReplSetConnection -> Mongo::MongoReplicaSetClient
Mongo::ShardedConnection -> Mongo::MongoShardedClient
  • Loading branch information...
1 parent eedcf8e commit d3563557f0e55d310d7678085a13f1d06845f63e @brandonblack brandonblack committed Nov 21, 2012
Showing with 270 additions and 270 deletions.
  1. +9 −9 README.md
  2. +2 −2 bin/mongo_console
  3. +2 −2 examples/admin.rb
  4. +2 −2 examples/capped.rb
  5. +2 −2 examples/cursor.rb
  6. +2 −2 examples/gridfs.rb
  7. +2 −2 examples/index_test.rb
  8. +2 −2 examples/info.rb
  9. +2 −2 examples/queries.rb
  10. +1 −1 examples/replica_set.rb
  11. +2 −2 examples/simple.rb
  12. +2 −2 examples/strict.rb
  13. +2 −2 examples/types.rb
  14. +1 −1 examples/web/thin/load.rb
  15. +1 −1 examples/web/unicorn/load.rb
  16. +1 −1 examples/web/unicorn/unicorn.rb.template
  17. +3 −3 lib/mongo.rb
  18. +6 −6 lib/mongo/db.rb
  19. +2 −2 lib/mongo/gridfs/grid.rb
  20. +2 −2 lib/mongo/gridfs/grid_file_system.rb
  21. +6 −6 lib/mongo/legacy.rb
  22. +24 −24 lib/mongo/{client.rb → mongo_client.rb}
  23. +17 −17 lib/mongo/{repl_set_client.rb → mongo_replica_set_client.rb}
  24. +6 −6 lib/mongo/{sharded_client.rb → mongo_sharded_client.rb}
  25. +2 −2 lib/mongo/networking.rb
  26. +1 −1 lib/mongo/util/node.rb
  27. +7 −7 lib/mongo/util/uri_parser.rb
  28. +1 −1 tasks/benchmark/batch_size_benchmark
  29. +1 −1 tasks/benchmark/exp_series.rb
  30. +1 −1 tasks/benchmark/gridstore_benchmark
  31. +1 −1 tasks/benchmark/profile_array.rb
  32. +2 −2 tasks/benchmark/standard_benchmark
  33. +2 −2 tasks/testing.rake
  34. +1 −1 test/auxillary/1.4_feature_test.rb
  35. +1 −1 test/auxillary/authentication_test.rb
  36. +1 −1 test/auxillary/autoreconnect_test.rb
  37. +3 −3 test/auxillary/repl_set_auth_test.rb
  38. +5 −5 test/auxillary/slave_connection_test.rb
  39. +2 −2 test/functional/collection_test.rb
  40. +11 −11 test/functional/connection_test.rb
  41. +2 −2 test/functional/db_connection_test.rb
  42. +2 −2 test/functional/db_test.rb
  43. +11 −11 test/replica_set/basic_test.rb
  44. +22 −22 test/replica_set/client_test.rb
  45. +2 −2 test/replica_set/complex_connect_test.rb
  46. +2 −2 test/replica_set/count_test.rb
  47. +3 −3 test/replica_set/cursor_test.rb
  48. +1 −1 test/replica_set/insert_test.rb
  49. +1 −1 test/replica_set/query_test.rb
  50. +6 −6 test/replica_set/refresh_test.rb
  51. +2 −2 test/replica_set/replication_ack_test.rb
  52. +5 −5 test/sharded_cluster/basic_test.rb
  53. +2 −2 test/test_helper.rb
  54. +4 −4 test/tools/mongo_config.rb
  55. +2 −2 test/tools/mongo_config_test.rb
  56. +30 −30 test/unit/client_test.rb
  57. +11 −11 test/unit/collection_test.rb
  58. +1 −1 test/unit/connection_test.rb
  59. +2 −2 test/unit/cursor_test.rb
  60. +2 −2 test/unit/grid_test.rb
  61. +7 −7 test/unit/node_test.rb
  62. +1 −1 test/unit/pool_manager_test.rb
  63. +3 −3 test/unit/read_test.rb
  64. +3 −3 test/unit/write_concern_test.rb
View
@@ -47,7 +47,7 @@ Here's a quick code sample. Again, see the [MongoDB Ruby Tutorial](https://githu
require 'rubygems'
require 'mongo'
-@client = Mongo::Client.new('localhost', 27017)
+@client = Mongo::MongoClient.new('localhost', 27017)
@db = @client['sample-db']
@coll = @db['test']
@@ -154,7 +154,7 @@ timeout for waiting for old connections to be released to the pool.
To set up a pooled connection to a single MongoDB instance:
```ruby
- @client = Client.new("localhost", 27017, :pool_size => 5, :timeout => 5)
+ @client = MongoClient.new("localhost", 27017, :pool_size => 5, :timeout => 5)
```
Though the pooling architecture will undoubtedly evolve, it currently owes much credit
@@ -168,13 +168,13 @@ of v1.3.0, the Ruby driver detects forking and reconnects automatically.
## Environment variable `MONGODB_URI`
-`Mongo::Client.from_uri`, `Mongo::Client.new` and `Mongo::ReplSetClient.new` will use <code>ENV["MONGODB_URI"]</code> if no other args are provided.
+`Mongo::MongoClient.from_uri`, `Mongo::MongoClient.new` and `Mongo::MongoReplicaSetClient.new` will use <code>ENV["MONGODB_URI"]</code> if no other args are provided.
The URI must fit this specification:
mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]
-If the type of connection (direct or replica set) should be determined entirely from <code>ENV["MONGODB_URI"]</code>, you may want to use `Mongo::Client.from_uri` because it will return either `Mongo::Client` or a `Mongo::ReplSetClient` depending on how many hosts are specified. Trying to use `Mongo::Client.new` with multiple hosts in <code>ENV["MONGODB_URI"]</code> will raise an exception.
+If the type of connection (direct or replica set) should be determined entirely from <code>ENV["MONGODB_URI"]</code>, you may want to use `Mongo::MongoClient.from_uri` because it will return either `Mongo::MongoClient` or a `Mongo::MongoReplicaSetClient` depending on how many hosts are specified. Trying to use `Mongo::MongoClient.new` with multiple hosts in <code>ENV["MONGODB_URI"]</code> will raise an exception.
## String Encoding
@@ -204,10 +204,10 @@ generate _id values. If you want to control _id values or even their types,
using a PK factory lets you do so.
You can tell the Ruby Mongo driver how to create primary keys by passing in
-the :pk option to the Client#db method.
+the :pk option to the MongoClient#db method.
```ruby
-db = Mongo::Client.new('localhost', 27017).db('dbname', :pk => MyPKFactory.new)
+db = Mongo::MongoClient.new('localhost', 27017).db('dbname', :pk => MyPKFactory.new)
```
A primary key factory object must respond to :create_pk, which should
@@ -263,7 +263,7 @@ To turn on strict mode, either pass in :strict => true when obtaining a DB
object or call the `:strict=` method:
```ruby
-db = Client.new('localhost', 27017).db('dbname', :strict => true)
+db = MongoClient.new('localhost', 27017).db('dbname', :strict => true)
# I'm feeling lax
db.strict = false
# No, I'm not!
@@ -287,10 +287,10 @@ Notes:
## Socket timeouts
The Ruby driver support timeouts on socket read operations. To enable them, set the
-`:op_timeout` option when you create a `Mongo::Client` object.
+`:op_timeout` option when you create a `Mongo::MongoClient` object.
If implementing higher-level timeouts, using tools like `Rack::Timeout`, it's very important
-to call `Mongo::Client#close` to prevent the subsequent operation from receiving the previous
+to call `Mongo::MongoClient#close` to prevent the subsequent operation from receiving the previous
request.
# Testing
View
@@ -10,11 +10,11 @@ require 'mongo'
include Mongo
host = org_argv[0] || ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
-port = org_argv[1] || ENV['MONGO_RUBY_DRIVER_PORT'] || Client::DEFAULT_PORT
+port = org_argv[1] || ENV['MONGO_RUBY_DRIVER_PORT'] || MongoClient::DEFAULT_PORT
dbnm = org_argv[2] || ENV['MONGO_RUBY_DRIVER_DB'] || 'ruby-mongo-console'
puts "Connecting to #{host}:#{port} (CLIENT) on with database #{dbnm} (DB)"
-CLIENT = Client.new(host, port)
+CLIENT = MongoClient.new(host, port)
DB = CLIENT.db(dbnm)
puts "Starting IRB session..."
View
@@ -6,10 +6,10 @@
include Mongo
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
-port = ENV['MONGO_RUBY_DRIVER_PORT'] || Client::DEFAULT_PORT
+port = ENV['MONGO_RUBY_DRIVER_PORT'] || MongoClient::DEFAULT_PORT
puts "Connecting to #{host}:#{port}"
-client = Mongo::Client.new(host, port)
+client = Mongo::MongoClient.new(host, port)
db = client.db('ruby-mongo-examples')
coll = db.create_collection('test')
View
@@ -4,10 +4,10 @@
include Mongo
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
-port = ENV['MONGO_RUBY_DRIVER_PORT'] || Client::DEFAULT_PORT
+port = ENV['MONGO_RUBY_DRIVER_PORT'] || MongoClient::DEFAULT_PORT
puts "Connecting to #{host}:#{port}"
-db = Client.new(host, port).db('ruby-mongo-examples')
+db = MongoClient.new(host, port).db('ruby-mongo-examples')
db.drop_collection('test')
# A capped collection has a max size and, optionally, a max number of records.
View
@@ -6,10 +6,10 @@
include Mongo
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
-port = ENV['MONGO_RUBY_DRIVER_PORT'] || Client::DEFAULT_PORT
+port = ENV['MONGO_RUBY_DRIVER_PORT'] || MongoClient::DEFAULT_PORT
puts "Connecting to #{host}:#{port}"
-db = Client.new(host, port).db('ruby-mongo-examples')
+db = MongoClient.new(host, port).db('ruby-mongo-examples')
coll = db.collection('test')
# Erase all records from collection, if any
View
@@ -7,10 +7,10 @@ def assert
include Mongo
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
-port = ENV['MONGO_RUBY_DRIVER_PORT'] || Client::DEFAULT_PORT
+port = ENV['MONGO_RUBY_DRIVER_PORT'] || MongoClient::DEFAULT_PORT
puts "Connecting to #{host}:#{port}"
-db = Client.new(host, port).db('ruby-mongo-examples')
+db = MongoClient.new(host, port).db('ruby-mongo-examples')
data = "hello, world!"
View
@@ -5,10 +5,10 @@
include Mongo
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
-port = ENV['MONGO_RUBY_DRIVER_PORT'] || Client::DEFAULT_PORT
+port = ENV['MONGO_RUBY_DRIVER_PORT'] || MongoClient::DEFAULT_PORT
puts ">> Connecting to #{host}:#{port}"
-db = Client.new(host, port).db('ruby-mongo-index_test')
+db = MongoClient.new(host, port).db('ruby-mongo-index_test')
class Exception
def errmsg
View
@@ -5,10 +5,10 @@
include Mongo
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
-port = ENV['MONGO_RUBY_DRIVER_PORT'] || Client::DEFAULT_PORT
+port = ENV['MONGO_RUBY_DRIVER_PORT'] || MongoClient::DEFAULT_PORT
puts "Connecting to #{host}:#{port}"
-db = Client.new(host, port).db('ruby-mongo-examples')
+db = MongoClient.new(host, port).db('ruby-mongo-examples')
coll = db.collection('test')
# Erase all records from collection, if any
View
@@ -6,10 +6,10 @@
include Mongo
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
-port = ENV['MONGO_RUBY_DRIVER_PORT'] || Client::DEFAULT_PORT
+port = ENV['MONGO_RUBY_DRIVER_PORT'] || MongoClient::DEFAULT_PORT
puts "Connecting to #{host}:#{port}"
-db = Client.new(host, port).db('ruby-mongo-examples')
+db = MongoClient.new(host, port).db('ruby-mongo-examples')
coll = db.collection('test')
# Remove all records, if any
View
@@ -4,7 +4,7 @@
cons = []
10.times do
- cons << Mongo::ReplSetClient(['localhost:27017'], :read => :secondary)
+ cons << Mongo::MongoReplicaSetClient(['localhost:27017'], :read => :secondary)
end
ports = cons.map do |con|
View
@@ -6,10 +6,10 @@
include Mongo
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
-port = ENV['MONGO_RUBY_DRIVER_PORT'] || Client::DEFAULT_PORT
+port = ENV['MONGO_RUBY_DRIVER_PORT'] || MongoClient::DEFAULT_PORT
puts "Connecting to #{host}:#{port}"
-db = Client.new(host, port).db('ruby-mongo-examples')
+db = MongoClient.new(host, port).db('ruby-mongo-examples')
coll = db.collection('test')
# Erase all records from collection, if any
View
@@ -5,10 +5,10 @@
include Mongo
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
-port = ENV['MONGO_RUBY_DRIVER_PORT'] || Client::DEFAULT_PORT
+port = ENV['MONGO_RUBY_DRIVER_PORT'] || MongoClient::DEFAULT_PORT
puts "Connecting to #{host}:#{port}"
-db = Client.new(host, port).db('ruby-mongo-examples')
+db = MongoClient.new(host, port).db('ruby-mongo-examples')
db.drop_collection('does-not-exist')
db.create_collection('test')
View
@@ -6,10 +6,10 @@
include Mongo
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
-port = ENV['MONGO_RUBY_DRIVER_PORT'] || Client::DEFAULT_PORT
+port = ENV['MONGO_RUBY_DRIVER_PORT'] || MongoClient::DEFAULT_PORT
puts "Connecting to #{host}:#{port}"
-db = Client.new(host, port).db('ruby-mongo-examples')
+db = MongoClient.new(host, port).db('ruby-mongo-examples')
coll = db.collection('test')
# Remove all records, if any
@@ -1,7 +1,7 @@
require File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'mongo')
require 'logger'
-$con = Mongo::ReplSetClient.new(['localhost:30000', 'localhost:30001'], :read => :secondary, :refresh_mode => :sync, :refresh_interval => 30)
+$con = Mongo::MongoReplicaSetClient.new(['localhost:30000', 'localhost:30001'], :read => :secondary, :refresh_mode => :sync, :refresh_interval => 30)
$db = $con['foo']
class Load < Sinatra::Base
@@ -1,6 +1,6 @@
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'mongo')
-$client = Mongo::Client.new('localhost', 27017)
+$client = Mongo::MongoClient.new('localhost', 27017)
$db = $client['foo']
class Load < Sinatra::Base
@@ -23,7 +23,7 @@ stdout_path "#{@dir}log/unicorn.stdout.log"
# NOTE: You need this when using forking web servers!
after_fork do |server, worker|
$client.close if $client
- $client = Mongo::Client.new('localhost', 27017)
+ $client = Mongo::MongoClient.new('localhost', 27017)
$db = $client['foo']
STDERR << "FORKED #{server} #{worker}"
end
View
@@ -66,9 +66,9 @@ module Constants
require 'mongo/networking'
-require 'mongo/client'
-require 'mongo/repl_set_client'
-require 'mongo/sharded_client'
+require 'mongo/mongo_client'
+require 'mongo/mongo_replica_set_client'
+require 'mongo/mongo_sharded_client'
require 'mongo/legacy'
require 'mongo/collection'
require 'mongo/cursor'
View
@@ -48,7 +48,7 @@ def strict?; @strict; end
# The name of the database and the local write concern options.
attr_reader :name, :write_concern
- # The Mongo::Client instance connecting to the MongoDB server.
+ # The Mongo::MongoClient instance connecting to the MongoDB server.
attr_reader :connection
# The length of time that Collection.ensure_index should cache index calls
@@ -60,8 +60,8 @@ def strict?; @strict; end
# Instances of DB are normally obtained by calling Mongo#db.
#
# @param [String] name the database name.
- # @param [Mongo::Client] client a connection object pointing to MongoDB. Note
- # that databases are usually instantiated via the Client class. See the examples below.
+ # @param [Mongo::MongoClient] client a connection object pointing to MongoDB. Note
+ # that databases are usually instantiated via the MongoClient class. See the examples below.
#
# @option opts [Boolean] :strict (False) If true, collections must exist to be accessed and must
# not exist to be created. See DB#collection and DB#create_collection.
@@ -73,7 +73,7 @@ def strict?; @strict; end
#
# @option opts [Hash] :w, :j, :wtimeout, :fsync Set the default write concern for this database.
# Propagated to Collection objects instantiated off of this DB. If no
- # options are provided, the default write concern set on this instance's Client object will be used. This
+ # options are provided, the default write concern set on this instance's MongoClient object will be used. This
# default can be overridden upon instantiation of any collection by explicitly setting write concern values
# on initialization
#
@@ -105,7 +105,7 @@ def initialize(name, client, opts={})
# @param [String] username
# @param [String] password
# @param [Boolean] save_auth
- # Save this authentication to the client object using Client#add_auth. This
+ # Save this authentication to the client object using MongoClient#add_auth. This
# will ensure that the authentication will be applied on database reconnect. Note
# that this value must be true when using connection pooling.
#
@@ -215,7 +215,7 @@ def remove_user(username)
end
# Deauthorizes use for this database for this client connection. Also removes
- # any saved authentication in the Client class associated with this
+ # any saved authentication in the MongoClient class associated with this
# database.
#
# @raise [MongoDBError] if logging out fails.
View
@@ -40,8 +40,8 @@ def initialize(db, fs_name=DEFAULT_FS_NAME)
# Create indexes only if we're connected to a primary node.
connection = @db.connection
- if (connection.class == Client && connection.read_primary?) ||
- (connection.class == ReplSetClient && connection.primary)
+ if (connection.class == MongoClient && connection.read_primary?) ||
+ (connection.class == MongoReplicaSetClient && connection.primary)
@chunks.create_index([['files_id', Mongo::ASCENDING], ['n', Mongo::ASCENDING]], :unique => true)
end
end
@@ -41,8 +41,8 @@ def initialize(db, fs_name=Grid::DEFAULT_FS_NAME)
# Create indexes only if we're connected to a primary node.
connection = @db.connection
- if (connection.class == Client && connection.read_primary?) ||
- (connection.class == ReplSetClient && connection.primary)
+ if (connection.class == MongoClient && connection.read_primary?) ||
+ (connection.class == MongoReplicaSetClient && connection.primary)
@files.create_index([['filename', 1], ['uploadDate', -1]])
@chunks.create_index([['files_id', Mongo::ASCENDING], ['n', Mongo::ASCENDING]], :unique => true)
end
View
@@ -42,8 +42,8 @@ def self.from_uri(uri = ENV['MONGODB_URI'], extra_opts={})
end
module Mongo
- # @deprecated Use Mongo::Client instead. Support will be removed after v2.0
- class Connection < Client
+ # @deprecated Use Mongo::MongoClient instead. Support will be removed after v2.0
+ class Connection < MongoClient
include Mongo::LegacyWriteConcern
def initialize(host=nil, port=nil, opts={})
@@ -52,8 +52,8 @@ def initialize(host=nil, port=nil, opts={})
end
end
- # @deprecated Use Mongo::ReplSetClient instead. Support will be removed after v2.0
- class ReplSetConnection < ReplSetClient
+ # @deprecated Use Mongo::MongoReplicaSetClient instead. Support will be removed after v2.0
+ class ReplSetConnection < MongoReplicaSetClient
include Mongo::LegacyWriteConcern
def initialize(*args)
@@ -66,8 +66,8 @@ def initialize(*args)
end
end
- # @deprecated Use Mongo::ShardedClient instead. Support will be removed after v2.0
- class ShardedConnection < ShardedClient
+ # @deprecated Use Mongo::MongoShardedClient instead. Support will be removed after v2.0
+ class ShardedConnection < MongoShardedClient
include Mongo::LegacyWriteConcern
def initialize(*args)
Oops, something went wrong.

0 comments on commit d356355

Please sign in to comment.