Navigation Menu

Skip to content

Commit

Permalink
RUBY-420 enforce lower bound on refresh interval
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerBrock committed Mar 21, 2012
1 parent 6944794 commit 0e8eef6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/mongo/repl_set_connection.rb
Expand Up @@ -476,7 +476,10 @@ def setup(opts)

# Refresh
@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
warn ":async refresh mode has been deprecated. Refresh
Expand Down
6 changes: 6 additions & 0 deletions test/unit/connection_test.rb
Expand Up @@ -41,6 +41,12 @@ class ConnectionTest < Test::Unit::TestCase
end

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
conn = ReplSetConnection.allocate
opts = {:connect => false}
Expand Down

0 comments on commit 0e8eef6

Please sign in to comment.