Method: Mongo::Server::Connection#connect!
- Defined in:
- lib/mongo/server/connection.rb
#connect!(context = nil) ⇒ true
Note:
This method mutates the connection object by setting a socket if one previously did not exist.
Establishes a network connection to the target address.
If the connection is already established, this method does nothing.
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/mongo/server/connection.rb', line 229 def connect!(context = nil) raise_if_closed! unless @socket @socket = create_socket(context) @description, @compressor = do_connect if server.load_balancer? if Lint.enabled? unless service_id raise Error::InternalDriverError, "The connection is to a load balancer and it must have service_id set here, but does not" end end @generation = connection_pool.generation_manager.generation(service_id: service_id) end publish_cmap_event( Monitoring::Event::Cmap::ConnectionReady.new(address, id) ) @close_event_published = false end true end |