2011-02-10 19:42:29 +00:00
|
|
|
require File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'mongo')
|
|
|
|
require 'logger'
|
|
|
|
|
2011-11-18 21:13:19 +00:00
|
|
|
$con = Mongo::ReplSetConnection.new(['localhost', 30000], ['localhost', 30001], :read => :secondary, :refresh_mode => :sync, :refresh_interval => 30)
|
2011-02-10 19:42:29 +00:00
|
|
|
$db = $con['foo']
|
|
|
|
|
|
|
|
class Load < Sinatra::Base
|
|
|
|
|
|
|
|
configure do
|
|
|
|
LOGGER = Logger.new("sinatra.log")
|
|
|
|
enable :logging, :dump_errors
|
|
|
|
set :raise_errors, true
|
|
|
|
end
|
|
|
|
|
|
|
|
get '/' do
|
2011-11-07 22:44:51 +00:00
|
|
|
$db['test'].insert({:a => rand(1000)})
|
|
|
|
$db['test'].find({:a => {'$gt' => rand(2)}}, :read => :secondary).limit(2).to_a
|
|
|
|
"ok"
|
2011-02-10 19:42:29 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|