RUBY-420 enforce lower bound on refresh interval

This commit is contained in:
Tyler Brock 2012-03-21 19:01:37 -04:00
parent 6944794fb2
commit 0e8eef6cdd
2 changed files with 10 additions and 1 deletions

View File

@ -476,7 +476,10 @@ module Mongo
# Refresh # Refresh
@refresh_mode = opts.fetch(:refresh_mode, false) @refresh_mode = opts.fetch(:refresh_mode, false)
@refresh_interval = opts[:refresh_interval] || 90 @refresh_interval = opts.fetch(:refresh_interval, 90)
if @refresh_mode && @refresh_interval < 60
@refresh_interval = 60
end
if @refresh_mode == :async if @refresh_mode == :async
warn ":async refresh mode has been deprecated. Refresh warn ":async refresh mode has been deprecated. Refresh

View File

@ -41,6 +41,12 @@ class ConnectionTest < Test::Unit::TestCase
end end
context "given a replica set" do context "given a replica set" do
should "enforce a minimum refresh_interval" do
@conn = ReplSetConnection.new(['localhost:27017'],
:connect => false, :refresh_mode => :sync, :refresh_interval => 10)
assert_equal 60, @conn.refresh_interval
end
should "warn if invalid options are specified" do should "warn if invalid options are specified" do
conn = ReplSetConnection.allocate conn = ReplSetConnection.allocate
opts = {:connect => false} opts = {:connect => false}