lib/mongo/server/connection_pool.rb
def next_available_connection(service_id: nil)
        if service_id
          conn = @available_connections.detect do |conn|
            conn.service_id == service_id
          end
          if conn
            @available_connections.delete(conn)
          end
          conn
        else
          @available_connections.pop
        end
      end
# Returns the next available connection, optionally scoped to the
# specified service. If no suitable connections are available,
# returns nil.
Returns the next available connection, optionally scoped to the
specified service. If no suitable connections are available,
returns nil.
Returns the next available connection optionally scoped to the specified service . If no suitable connections are available returns nil .
def next_available_connection(service_id: nil)
        if service_id
          conn = @available_connections.detect do |conn|
            conn.service_id == service_id
          end
          if conn
            @available_connections.delete(conn)
          end
          conn
        else
          @available_connections.pop
        end
      end
def next_available_connection ( service_id : nil ) if service_id conn = @available_connections . detect do | conn | conn . service_id == service_id end if conn @available_connections . delete ( conn ) end conn else @available_connections . pop end end
Returns the next available connection, optionally scoped to the
specified service.
Returns the next available connection optionally scoped to the specified service .
service_id