client options lost when creating with URI

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • 2.0.0
    • Affects Version/s: 2.0.0
    • Component/s: Public API
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The current implementation ignores the options arg when creating a client, for example:

      client = Mongo::Client.new("mongodb://localhost:27017", :heartbeat_frequency => 15)
      

      Possible fix:

      module Mongo
        class Client
      
          def initialize(addresses_or_uri, options = {})
            if addresses_or_uri.is_a?(::String)
              create_from_uri(addresses_or_uri, options)
            else
              create_from_addresses(addresses_or_uri, options)
            end
          end
      
          def create_from_addresses(addresses, options = {})
            @options = options.freeze
            @cluster = Cluster.new(self, addresses, @options)
            @database = Database.new(self, @options[:database])
          end
      
          def create_from_uri(connection_string, options = {})
            uri = URI.new(connection_string)
            @options = options.merge(uri.client_options).freeze
            @cluster = Cluster.new(self, uri.servers, @options)
            @database = Database.new(self, @options[:database])
          end
      
        end
      end
      

      This issue overlaps with RUBY-815. Note that modification to `create_from_addresses` shown here is only for consistency, there no difference in functionality.

              Assignee:
              Durran Jordan
              Reporter:
              Gary Murakami (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: