Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-816

client options lost when creating with URI

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.0.0
    • Affects Version/s: 2.0.0
    • Component/s: Public API
    • 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@mongodb.com Durran Jordan
            Reporter:
            gjmurakami Gary Murakami
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: