# File lib/mongo/client.rb, line 315
    def initialize(addresses_or_uri, options = nil)
      if options
        options = options.dup
      else
        options = {}
      end
      Lint.validate_underscore_read_preference(options[:read])
      Lint.validate_read_concern_option(options[:read_concern])
      if addresses_or_uri.is_a?(::String)
        uri = URI.get(addresses_or_uri, options)
        addresses = uri.servers
        options = uri.client_options.merge(options)
      else
        addresses = addresses_or_uri
      end
      # Special handling for sdam_proc as it is only used during client
      # construction
      sdam_proc = options.delete(:sdam_proc)
      @options = validate_options!(Database::DEFAULT_OPTIONS.merge(options)).freeze
      @database = Database.new(self, @options[:database], @options)
      # Temporarily set monitoring so that event subscriptions can be
      # set up without there being a cluster
      @monitoring = Monitoring.new(@options)
      if sdam_proc
        sdam_proc.call(self)
      end
      @server_selection_semaphore = Semaphore.new
      @cluster = Cluster.new(addresses, @monitoring, cluster_options)
      # Unset monitoring, it will be taken out of cluster from now on
      remove_instance_variable('@monitoring')

      yield(self) if block_given?
    end