Skip to content

Instantly share code, notes, and snippets.

@fabiob
Created April 12, 2016 07:30
Show Gist options
  • Save fabiob/033e298480c0a7b0b0c32a6a2c7f23e5 to your computer and use it in GitHub Desktop.
Save fabiob/033e298480c0a7b0b0c32a6a2c7f23e5 to your computer and use it in GitHub Desktop.
gem 'mongo', '2.2.4' # this version raises "Cursor not found"
# gem 'mongo', '2.1.2' # this version works
require 'uri'
require 'mongo'
puts "-" * 50
puts "Mongo Driver version: #{Mongo::VERSION}"
puts "-" * 50
uri = "mongodb://user:pass@mongos1:port,mongos2:port/tests"
c = Mongo::Client.new(uri, ssl: true, ssl_verify: false, max_pool_size: 10)
c['samplecol'].drop
c['samplecol'].insert_many(1000.times.map { |i| { someval: 1 } })
10.times.map { Thread.start { c['samplecol'].find({}).batch_size(300).to_a } }.map(&:join)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment