lib/mongo/cluster.rb
# Add a server to the cluster with the provided address. Useful in
# auto-discovery of new servers when an existing server executes a hello
# and potentially non-configured servers were included.
#
# @example Add the server for the address to the cluster.
#   cluster.add('127.0.0.1:27018')
#
# @param [ String ] host The address of the server to add.
#
# @option options [ Boolean ] :monitor For internal driver use only:
#   whether to monitor the newly added server.
#
# @return [ Server ] The newly added server, if not present already.
#
# @since 2.0.0
Add a server to the cluster with the provided address. Useful in
auto-discovery of new servers when an existing server executes a hello
and potentially non-configured servers were included.
Add a server to the cluster with the provided address . Useful in auto - discovery of new servers when an existing server executes a hello and potentially non - configured servers were included .
def add(host, add_options=nil)
      address = Address.new(host, options)
      if !addresses.include?(address)
        opts = options.merge(monitor: false)
        server = Server.new(address, self, @monitoring, event_listeners, opts)
        @update_lock.synchronize do
          return if @servers.map(&:address).include?(address)
          @servers.push(server)
        end
        if add_options.nil? || add_options[:monitor] != false
          server.start_monitoring
        end
        server
      end
    end
def add ( host , add_options = nil ) address = Address . new ( host , options ) if ! addresses . include? ( address ) opts = options . merge ( monitor : false ) server = Server . new ( address , self , @monitoring , event_listeners , opts ) @update_lock . synchronize do return if @servers . map ( & :address ) . include? ( address ) @servers . push ( server ) end if add_options . nil? || add_options [ :monitor ] != false server . start_monitoring end server end end
Add a server to the cluster with the provided address.
Add a server to the cluster with the provided address .
# Note that in a load-balanced topology, every server must be a # load balancer (load_balancer: true is specified in the options) # but this option isn't set here because we are required by the # specifications to pretent the server started out as an unknown one # and publish server description change event into the load balancer # one. The actual correct description for this server will be set # by the fabricate_lb_sdam_events_and_set_server_type method. # Need to recheck whether server is present in @servers, because # the previous check was not under a lock. # Since we are under the update lock here, we cannot call servers_list.
The newly added server, if not present already.
The newly added server if not present already .
 Server 
host
add_options
host The address of the server to add.
host The address of the server to add .
options
:monitor For internal driver use only: whether to monitor the newly added server.
: monitor For internal driver use only : whether to monitor the newly added server .
example
Add the server for the address to the cluster.
Add the server for the address to the cluster .
since
None