# File lib/mongo/util/read_preference.rb, line 36
    def select_pool(mode, tags, latency)
      return primary_pool if @client.mongos?

      if mode == :primary && !tags.empty?
        raise MongoArgumentError, "Read preference :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