Commit Graph

788 Commits

Author SHA1 Message Date
Ryan McGeary
7f384ebd51 Refactored two code paths of GridIO#gets into well-named methods 2011-05-03 11:54:18 -04:00
Ryan McGeary
c672168236 Fixed GridIO#gets to handle the end of a file
Neither a multi-character nor single-character separator search returned nil
after hitting the EOF.
2011-05-03 11:36:33 -04:00
Steve Randy Tantra
3a3a31a3dc get_md5 should return @server_md5 when putting file in safe mode. 2011-05-02 01:55:54 +08:00
Kyle Banker
ba1e4679fa Leave hash arguments unmodified. 2011-04-27 11:10:48 -04:00
Kyle Banker
8887402ca8 Don't modify hash arguments. 2011-04-26 07:48:17 -04:00
Kyle Banker
9cc6bad613 Simplify GridIO#read_all 2011-04-26 07:48:16 -04:00
Kyle Banker
140dfa9f32 minor: fixes 2011-04-26 07:48:16 -04:00
Kyle Banker
9c30de332f minor: test fix 2011-04-15 10:58:37 -04:00
Kyle Banker
6b9eef0d1f RUBY-240 minor fix for RUBY 1.8 2011-03-29 16:01:46 -04:00
Kyle Banker
002ddb06fc RUBY-240 Add StringIO methods to GridIO 2011-03-29 15:27:13 -04:00
Kyle Banker
3509926071 Remove Connection#reset_connection (private) and deprecate
ReplSetConnection#reset_connection (public)
2011-03-29 12:18:58 -04:00
Kyle Banker
a6cc09e50c RUBY-236 more timeout tweaks and tests 2011-03-29 11:46:29 -04:00
Kyle Banker
f3174550b7 RUBY-236 Create timeout block only when timeout is set 2011-03-29 11:06:46 -04:00
Kyle Banker
025e56732e minor: test and doc fixes 2011-03-29 10:39:01 -04:00
Mauro Pompilio
baa1d0b802 Method *create_colletion* behaves the same way as *collection*
when options are passed.
2011-03-28 11:23:03 -04:00
Kent Sibilev
c9da58965a properly log sorting option 2011-03-28 11:18:14 -04:00
Kyle Banker
e49d50acc2 RUBY-236 set op_timeout for socket receive timeouts 2011-03-28 11:09:27 -04:00
Kyle Banker
1ab2f171c8 minor: doc fix 2011-03-23 17:36:03 -04:00
Kyle Banker
272d4835a7 RUBY-252 RUBY-237 re-add Connection#host and Connection#port 2011-03-23 16:34:42 -04:00
Kyle Banker
2bfe205c51 Merged wpiekutowski's commits to enable warnings
on test suite and clean up some code.

Conflicts:
	test/cursor_test.rb
2011-03-23 16:02:04 -04:00
Kyle Banker
37f285bf0c minor: docs 2011-03-23 15:30:27 -04:00
John Nunemaker
53ad43fedc Added transformer concept.
Can be passed to find/find_one, which in turn is passed to cursor. It is an optional block that makes it easier to turn documents that are returned into hashes.

cursor = collection.find({...}, :transformer => Proc.new { |doc| User.load(doc) })
cursor.next # returns instance of User instead of ordered hash

This will allow MongoMapper, ToyStore and other object mappers to take better advantage of Cursors. No more calling to_a and mapping to instances.
2011-03-23 15:26:34 -04:00
Kyle Banker
997d9b8ae2 RUBY-231 RUBY-250 Validate socket against pid 2011-03-17 22:15:14 -04:00
Kyle Banker
8df0ff23f5 RUBY-249 Alias Cursor#next for Cursor#next_document 2011-03-15 14:24:34 -04:00
Kyle Banker
6a46bf7aef RUBY-247 Improved replica set docs. 2011-03-12 08:40:29 -05:00
Mauro Pompilio
e64f91e013 Implementation of the 'ping' command. Probably better suited for the 'active?' method. 2011-03-04 10:51:18 -05:00
Mauro Pompilio
1ad3285767 Add a mechanism to check if the connection is active/healthy. 2011-03-03 10:17:47 -05:00
Kyle Banker
4f3937d6a4 Map-reduce doc update for v1.8 2011-02-23 14:43:23 -05:00
Mauro Pompilio
fa0a933780 Fix the exception message shown when there's an IOError
while closing a socket in the pool.
2011-02-23 12:43:20 -05:00
Kyle Banker
24cfde5ef6 Updated map-reduce tests and docs for v1.8 map-reduce options 2011-02-22 17:47:47 -05:00
Wojciech Piekutowski
2971793b48 Remove dead code 2011-02-20 17:12:46 +01:00
Wojciech Piekutowski
d12987bf7a Always initialize @metadata and @aliases 2011-02-20 17:09:18 +01:00
Wojciech Piekutowski
62900acb4b Initialize @cursor_id 2011-02-20 17:03:32 +01:00
Wojciech Piekutowski
5dfac28dd4 Fix Mongo::Cursor#query_options_hash 2011-02-20 16:22:39 +01:00
Wojciech Piekutowski
e4867b542e Initialize instance variables for available options 2011-02-20 16:12:30 +01:00
Wojciech Piekutowski
b541972bdc Remove duplicating character classes from URI regexp in Mongo::URIParser 2011-02-20 15:36:15 +01:00
Mani Tadayon
9772328948 Fix typo in error message for Collection#group 2011-02-17 10:20:03 -05:00
Kyle Banker
ed44a7490c Improved replica set failover tests. A few
improved exception messages.
2011-02-15 16:48:29 -05:00
Kyle Banker
e55cf2b7d1 minor: doc fix 2011-02-10 17:09:03 -05:00
Kyle Banker
0c574b9975 minor: alias Connection#reconnect to Connection#connect 2011-02-02 11:36:56 -05:00
Kyle Banker
e8e617e95f Test for replica set authentication; bug fix. 2011-02-02 11:26:31 -05:00
Kyle Banker
d63cf18042 minor: note 2011-02-02 09:51:13 -05:00
Kyle Banker
9c83ca6b3e minor style and doc fixes. warning about logging performance issues. 2011-01-31 15:51:39 -05:00
Steve Sloan
8a7296599b Refactored logging of DB operations to use Connection#instrument.
This allows for easy overriding, e.g. to ActiveSupport notifications.
2011-01-31 15:13:12 -05:00
Kyle Banker
7c4740c47c RUBY-232 handle authentication with connection pooling 2011-01-31 14:47:38 -05:00
Andy Gregorowicz
285752a7ad Switching parameter name in Collection#group from key to opts to fix YARD doc 2011-01-21 14:20:52 -07:00
Andy Gregorowicz
153bedf5f6 Switching parameter name from key to opts to fix YARD doc 2011-01-21 14:20:44 -07:00
Kyle Banker
fab538ed5e minor: alias #read_primary? with #primary? 2011-01-17 13:37:41 -05:00
Kyle Banker
0d91faf6b1 RUBY-226 minor: license update 2011-01-17 12:26:32 -05:00
Kyle Banker
af43e9c2ce RUBY-255 2011-01-17 12:06:03 -05:00
Kyle Banker
2b835c0e48 RUBY-227 passwords in URIs can contain all
characters excepts commas now.
2011-01-17 11:05:24 -05:00
Kyle Banker
65f59ba2d6 RUBY-222 Collection#group gets a new, reasonable API 2011-01-06 10:05:19 -05:00
Kyle Banker
a197ea7852 RUBY-219 minor: use opts instead of options throughout 2011-01-05 11:30:20 -05:00
Kyle Banker
af0ecde925 RUBY-204 Collection construct now has analogous API
to DB constructor (i.e., name comes first)
2011-01-05 09:44:46 -05:00
Kyle Banker
fa583762e7 RUBY-203 Use Hash#fetch when possible 2011-01-05 09:34:09 -05:00
Kyle Banker
e55136e056 minor: doc and Collection#update clarification 2011-01-04 18:08:29 -05:00
Kyle Banker
ae202d590e RUBY-192; Updates for Collection#ensure_index 2011-01-03 16:16:24 -05:00
Kyle Banker
70bbb6f1fc minor: claification 2011-01-03 14:11:29 -05:00
Kyle Banker
4d2d0a26af minor: docs 2011-01-03 14:06:41 -05:00
Kyle Banker
b83877527e minor: docs 2010-12-30 15:45:24 -05:00
Kyle Banker
4e5b1a7d23 RUBY-205 RUBY-150 Support new connection URI options 2010-12-30 15:40:50 -05:00
Kyle Banker
9da68bb3db RUBY-189 use result of ismaster's maxBsonObjectSize 2010-12-29 18:06:31 -05:00
Kyle Banker
b77b3fe1e6 RUBY-215 added Connection#read_primary? and ReplSetConnection#read_primary? 2010-12-29 13:01:05 -05:00
Nick Stielau
b3b1cd091a Updating docs about using :fields to exclude _id. 2010-12-29 12:10:24 -05:00
Kyle Banker
8b1f20b3cb RUBY-210 GridIO#seek with GridIO#read_all 2010-12-15 15:07:30 -05:00
Kyle Banker
70135a6b67 minor: docs 2010-12-15 14:15:49 -05:00
Kyle Banker
6196c8728a RUBY-206 handle wtimeout behavior on 1.7.3 2010-12-15 14:15:20 -05:00
Kyle Banker
a825500784 Updated ReplSetConnection docs 2010-12-15 14:14:06 -05:00
Kyle Banker
7ee45f4340 Removed three unused methods from Connection 2010-12-15 12:41:33 -05:00
Kyle Banker
9ea8fe98b7 minor: cleanup and organization of Connection classes 2010-12-15 12:36:43 -05:00
Kyle Banker
39b9656fc4 Fixed request id checking for threaded inserts. 2010-12-15 12:12:51 -05:00
Kyle Banker
2d2122d5f4 Fix for when port isn't specified on rs nodes (Alex Stupka) 2010-12-14 17:46:40 -05:00
Kyle Banker
5860265cc9 Merge branch 'repl_set_connection' 2010-12-14 17:40:49 -05:00
Kyle Banker
95c0fe088f Fully-automated replica set tests. 2010-12-14 17:38:52 -05:00
Kyle Banker
7629cf30f0 Ensure that we close connection if receive raises any errors. 2010-12-14 15:53:59 -05:00
Kyle Banker
236d4a821f More connection refactoring. Updates to repl_set_manager. 2010-12-14 13:14:45 -05:00
Kyle Banker
6db5bb2f51 Test request and response ids match 2010-12-13 17:54:28 -05:00
Kyle Banker
27b410f869 ReplSetConnection updates 2010-12-13 14:07:32 -05:00
Kyle Banker
08b7cddc81 Initial ReplSetConnection checking. Refactoring. 2010-12-10 16:00:35 -05:00
Kyle Banker
b63250e6e4 Fix for connections to replica sets with 1 secondary and 1 arbiter 2010-12-10 11:12:18 -05:00
Kyle Banker
03bf0a18de minor: Collection#remove returns true on nonsafe remove 2010-12-02 12:47:50 -05:00
Kyle Banker
13a27771b0 minor: ensure_index fix for 1.9.1 2010-12-02 11:24:21 -05:00
Kyle Banker
9a8d83ad24 Tests for GridIO#each 2010-12-01 13:30:57 -05:00
Jonathan Tron
c80cd285fa Add Mongo::GridIO#each which yield each chunks of a file, allowing Rack streaming 2010-12-01 12:55:55 -05:00
Kyle Banker
5930c500b4 RUBY-208 test for connection failure. Minor test fix. 2010-11-30 12:36:45 -05:00
Kyle Banker
1a14156206 minor: cleanup 2010-11-29 14:06:38 -05:00
Kyle Banker
e621db732e minor: cleanup 2010-11-24 14:01:26 -05:00
Daniel Cooper
df80704f77 Cursor#count now has optional argument to make it take notice of skip and limit 2010-11-24 13:51:05 -05:00
Kyle Banker
8aaed130d6 Cleanup for distributed reads on replica sets. 2010-11-24 13:49:34 -05:00
Kyle Banker
c5862da061 minor: test fix 2010-11-23 13:37:29 -05:00
Kyle Banker
add9779fa0 Select secondary read node randomly 2010-11-19 18:26:38 -05:00
Kyle Banker
1e57ca90e1 Initial commit for reads from rs secondaries 2010-11-16 15:43:59 -05:00
Kyle Banker
29dfe390c5 RUBY-196 tweaks to Collection#ensure_index 2010-11-11 17:41:31 -05:00
Matthew Rathbone
d33ddfb8e0 added ensure_index 2010-11-11 16:21:23 -05:00
Ijonas Kisselbach
2188522687 removed argument type checks from Cursor.skip() and Cursor.limit() due to clash with JRuby's redefining of Integer 2010-11-11 15:20:08 -05:00
Steve Ardis
ffab7ba5a3 Fixed issue with grid.rb where 'put' was duplicating the filename attribute on the file 2010-11-11 15:18:52 -05:00
Evgeny Shadchnev
8c96f5d52f removed batch_size accessor that's overridden by a method anyway 2010-11-11 15:08:24 -05:00
Evgeny Shadchnev
af0822f476 initializing query_run and closed before they are first used 2010-11-11 15:08:01 -05:00
Kyle Banker
9d25efece4 Bug fix on Collection#rename 2010-11-09 13:45:33 -05:00
Kyle Banker
b4d5448179 Create index concurrency fix 2010-11-09 13:34:28 -05:00
Kyle Banker
ced3bfbfe8 Update and remove return error object in safe mode 2010-11-09 13:07:01 -05:00
Kyle Banker
8125e26c4d minor: fix prev commit 2010-11-04 17:35:58 -04:00
Kyle Banker
c984af4ff0 Fixed bug passing :timeout to Cursor. Added tests. 2010-11-04 17:26:21 -04:00
Kyle Banker
8b1fbbb868 minor: cleanup 2010-11-03 19:02:03 -04:00
Kyle Banker
a2f501924e Specify pk factory on Collection.new as a :pk option 2010-11-03 18:36:29 -04:00
Kyle Banker
68af3dbe8f Allow the setting of safe mode globally on the Connection,
DB, and Collection levels. The safe mode setting will
automatically be inherited down the hierarchy Connection ->
DB -> Collection -> (insert, update, remove). This default
can be overridden at any time. Connection#safe, DB#safe, and
Collection#safe will yield the current default value.
2010-11-03 17:36:08 -04:00
Kyle Banker
f7d151c8dc minor: doc fixes 2010-11-03 15:32:19 -04:00
Kyle Banker
d6f8f9d41a Allow specification of replica set name on connect.
Raise ReplicaSetConnectionError if expected name doesn't match set.
2010-11-03 15:12:15 -04:00
Kyle Banker
5aa8721b25 Allow idiomatic :drop_dups in addition to :dropDups
on index creation.

Don't raise exception if :dropDups results in duplicate key error.
2010-11-02 14:50:02 -04:00
Kyle Banker
2939932526 close connection when safe mode insert results in 'not master' 2010-10-29 23:18:49 -04:00
Kyle Banker
424f08af5e close connection on exception on safe insert 2010-10-29 17:52:15 -04:00
Kyle Banker
2720206f77 minor: docs 2010-10-22 13:27:56 -04:00
Kyle Banker
e416e05fc7 RUBY-190 bug fix for unavailable nodes on Connection#multi 2010-10-21 14:33:48 -04:00
Kyle Banker
a905c3f1f2 RUBY-191 fix to pass options to new db with Connection#db 2010-10-21 13:27:57 -04:00
Kyle Banker
afe8fe3167 RUBY-193 don't create gridfs indexes when slave_ok 2010-10-21 13:01:32 -04:00
Kyle Banker
68cadc1987 minor: patch for JRuby 1.9 MD5 comparison bug 2010-10-14 16:35:13 -04:00
Kyle Banker
80044b9a58 RUBY-187 All tests can now use custom host and port;
Minor test fixes.
2010-10-13 17:09:23 -04:00
Kyle Banker
3a0cdf64af remove deprecated support for implicit 2010-10-04 14:37:19 -04:00
Kyle Banker
bd4b6060f7 Removed deprecated DB methods 2010-10-04 12:16:40 -04:00
Kyle Banker
f7a97a0db0 Removed deprecated Connection methods 2010-10-04 12:16:11 -04:00
Kyle Banker
7ad280c2cb RUBY-184 Connection#locked? 2010-10-04 11:38:20 -04:00
Kyle Banker
4141331f79 RUBY-184 fsync lock helpers 2010-09-28 12:15:45 -04:00
Hongli Lai (Phusion)
b474b29d35 Optimize Mongo::Connection#receive_message_on_socket and #receive_and_discard_message_on_socket: avoid creating initial input buffer up front so that IO#read only needs to allocate the buffer once. 2010-09-14 10:37:08 -04:00
Hongli Lai (Phusion)
6316c939d5 Optimize Mongo::Connection#send_message_on_socket: don't slice the input when not necessary. 2010-09-14 10:36:54 -04:00
Hongli Lai (Phusion)
87e6d578c1 Optimize Mongo::Connection#add_message_headers by packing data directly instead of using ByteBuffer. 2010-09-14 10:36:40 -04:00
Hongli Lai (Phusion)
0585aa1aae Fix MongoDB::Collection #insert_documents, #update and #remove and MongoDB::Connection #receive_header and #last_error_message: usage strings as much as possible instead of byte arrays, otherwise performance really suffers. 2010-09-13 10:51:53 -04:00
Hongli Lai (Phusion)
c8726ca150 Optimize MongoDB::Cursor#construct_query_message. 2010-09-13 10:51:15 -04:00
Hongli Lai (Phusion)
c6206eddf4 Optimize MongoDB::Connection#receive_response_header by using raw string operations and unpack() instead of the slower ByteBuffer. 2010-09-13 10:50:39 -04:00
Hongli Lai (Phusion)
e1bf168767 Optimize MongoDB::Connection#receive.
It doesn't do anything with the header. So instead of parsing the header,
just read the header data and discard it.
2010-09-13 10:50:25 -04:00
Hongli Lai (Phusion)
2291a59fcc Optimize Mongo::Connection#read_documents by using raw string operations and unpack() instead of the slower ByteBuffer. 2010-09-13 10:50:16 -04:00
Hongli Lai (Phusion)
117ce2389c Optimize receive_message_on_socket for the optimistic average case where 1 socket.read() operation receives all requested data. Also fix some Ruby 1.9 encoding issues in that function while we're at it. 2010-09-13 10:48:32 -04:00
Mislav Marohnić
56f37e49b6 replace usage of returning with each_with_object
`each_with_object` is a Ruby 1.9 method, here re-implemented in core_ext.rb
in case it's missing (for older Ruby versions). Using `returning` is bad in
combination with Ruby on Rails because each usage of the method will emit
a Rails deprecation warning. This might be considered an Active Support bug,
but it's better to avoid using `returning` altogether and use `tap` from
Ruby 1.8.7, also re-implemented here in case it's missing.

Since existing usages or `returning` were better suited for `each_with_object`
than `tap`, they were rewritten using the former instead.
2010-09-13 01:10:38 +08:00
Kyle Banker
3a4134a5c2 RUBY-180 fixed failing test 2010-09-09 14:53:29 -04:00
Kyle Banker
e03ea6b690 minor: typo fix 2010-09-09 14:22:09 -04:00
Kyle Banker
36c71ef48e RUBY-180 Fix batch size 2010-09-09 14:12:12 -04:00
Kyle Banker
b339871eb9 minor: #refresh instead of #refill_via_get_more 2010-09-08 14:34:28 -04:00
Kyle Banker
300b442a94 Create logging message only when a logger is passed to the Connection.
Results in a pretty significant performance improvement.

Many thanks to Matt Taylor for noticing the unusual glut of calls
to ObjectId#to_s. See here: http://unhalting.com/?p=18
2010-09-08 14:27:27 -04:00
Kyle Banker
6b2939f2f7 RUBY-171 allow Cursor#to_a even after iterating; added Cursor#rewind; consistent Enumberable behavior for Cursor 2010-08-26 12:35:42 -04:00
Steve Sloan
dfcf8d9d60 Moved thread and socket classes into Connection for easy overriding.
This is necessary for use under em-synchrony, which uses Fibers instead of Threads and EventMachine instead of blocking sockets.
2010-08-24 14:35:21 -04:00
Kyle Banker
c7c309b00d RUBY-158 deprecate BSON::ObjectID for BSON::ObjectId 2010-08-24 12:49:23 -04:00
Kyle Banker
5cbec4e5b6 RUBY-161 accessors for hosts in a replica set by node type 2010-08-24 11:20:54 -04:00
Kyle Banker
f448946ea6 Merge branch 'master' of github.com:mongodb/mongo-ruby-driver 2010-08-23 14:10:17 -04:00
Mike Dirolf
56aa67f4fe minor: typo 2010-08-17 10:08:48 -04:00
Kyle Banker
9cd7377b00 minor: cleanup 2010-08-09 14:09:51 -04:00
Kyle Banker
7bb59610b7 minor: kill cursors only when necessary 2010-08-06 16:02:51 -04:00
Kyle Banker
db8ddd059b minor: silence some warning due to deprecaton 2010-08-04 16:47:13 -04:00
Kyle Banker
9e223f4510 remove old DB#command arguments 2010-08-04 16:26:29 -04:00
Kyle Banker
f1f0c87b3b minor: fixes for db commands with new DB#command checking response 2010-08-04 16:21:41 -04:00
Kyle Banker
065517ac29 Fixed test bug; better replication ack tests; deprecated DB#error and DB#last_status for DB#get_last_error 2010-08-02 18:19:54 -04:00
Kyle Banker
02e5b77219 minor: cleanup (chriseppstein) 2010-07-28 06:27:42 -04:00