def select_pool(mode, tags, latency)
if mode == :primary && !tags.empty?
raise MongoArgumentError, "Read preferecy :primary cannot be combined with tags"
end
case mode
when :primary
primary_pool
when :primary_preferred
primary_pool || select_secondary_pool(secondary_pools, tags, latency)
when :secondary
select_secondary_pool(secondary_pools, tags, latency)
when :secondary_preferred
select_secondary_pool(secondary_pools, tags, latency) || primary_pool
when :nearest
select_secondary_pool(pools, tags, latency)
end
end