lib/arachni/rpc/client.rb
# Connection factory, will re-use or create new connections as needed to
# accommodate the workload.
#
# @param    [Block] block
#   Block to be passed a {Handler connection}.
#
# @return   [Boolean]
#   `true` if a new connection had to be established, `false` if an existing
#   one was re-used.
Connection factory, will re-use or create new connections as needed to
accommodate the workload.
Connection factory will re - use or create new connections as needed to accommodate the workload .
def connect( &block )
        ensure_reactor_running
        if @connections.empty? && @connection_count < @pool_size
            opts = @socket ? @socket : [@host, @port]
            block.call @reactor.connect( *[opts, Handler, @opts.merge( client: self )].flatten )
            increment_connection_counter
            return true
        end
        pop_block = proc do |conn|
            if !conn.done?
                connection_failed conn
                connect( &block )
                next
            end
            block.call conn
        end
        @connections.pop( &pop_block )
        false
    end
def connect ( & block ) ensure_reactor_running if @connections . empty? && @connection_count < @pool_size opts = @socket ? @socket : [ @host , @port ] block . call @reactor . connect ( * [ opts , Handler , @opts . merge ( client : self ) ] . flatten ) increment_connection_counter return true end pop_block = proc do | conn | if ! conn . done? connection_failed conn connect ( & block ) next end block . call conn end @connections . pop ( & pop_block ) false end
Connection factory, will re-use or create new connections as needed to
accommodate the workload.
Connection factory will re - use or create new connections as needed to accommodate the workload .
# Some connections may have died while they were waiting in the # queue, get rid of them and start all over in case the queue has # been emptied.
`true` if a new connection had to be established, `false` if an existing one was re-used.
` true ` if a new connection had to be established ` false ` if an existing one was re - used .
Boolean
block
<not_specific>
<not_specific>
block Block to be passed a {Handler connection}.
block Block to be passed a { Handler connection } .