Class: Mongo::ShardingPoolManager
- Inherits:
-
PoolManager
- Object
- PoolManager
- Mongo::ShardingPoolManager
- Defined in:
- lib/mongo/util/sharding_pool_manager.rb
Instance Attribute Summary
Attributes inherited from PoolManager
#arbiters, #client, #hosts, #members, #nodes, #pools, #primary, #primary_pool, #secondaries, #secondary_pools, #seeds
Instance Method Summary collapse
-
#best(members) ⇒ Object
“Best” should be the member with the fastest ping time but connect/connect_to_members reinitializes @members.
-
#check_connection_health ⇒ Object
We want to refresh to the member with the fastest ping time but also want to minimize refreshes We’re healthy if the primary is pingable.
- #connect ⇒ Object
- #inspect ⇒ Object
Methods inherited from PoolManager
#close, #closed?, #initialize, #max_bson_size, #max_message_size, #read, #refresh!, #refresh_required?
Methods included from ThreadLocalVariableManager
Constructor Details
This class inherits a constructor from Mongo::PoolManager
Instance Method Details
#best(members) ⇒ Object
“Best” should be the member with the fastest ping time but connect/connect_to_members reinitializes @members
10 11 12 |
# File 'lib/mongo/util/sharding_pool_manager.rb', line 10 def best(members) Array(members.first) end |
#check_connection_health ⇒ Object
We want to refresh to the member with the fastest ping time but also want to minimize refreshes We’re healthy if the primary is pingable. If this isn’t the case, or the members have changed, set @refresh_required to true, and return. The config.mongos find can’t be part of the connect call chain due to infinite recursion
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/mongo/util/sharding_pool_manager.rb', line 26 def check_connection_health begin seeds = @client['config']['mongos'].find.to_a.map{|doc| doc['_id']} if @seeds != seeds @seeds = seeds @refresh_required = true end rescue Mongo::OperationFailure @refresh_required = true end end |
#connect ⇒ Object
14 15 16 17 18 19 |
# File 'lib/mongo/util/sharding_pool_manager.rb', line 14 def connect @refresh_required = false disconnect_old_members connect_to_members initialize_pools best(@members) end |
#inspect ⇒ Object
4 5 6 |
# File 'lib/mongo/util/sharding_pool_manager.rb', line 4 def inspect "<Mongo::ShardingPoolManager:0x#{self.object_id.to_s(16)} @seeds=#{@seeds}>" end |