lib/serfx/commands.rb
# subscribe to a stream of all events matching a given type filter.
# Events will continue to be sent until the stream is stopped
#
# @param types [String] comma separated list of events
# @return  [Thread, Response]
subscribe to a stream of all events matching a given type filter.
Events will continue to be sent until the stream is stopped
subscribe to a stream of all events matching a given type filter . Events will continue to be sent until the stream is stopped
def stream(types, &block)
      res = request(:stream, 'Type' => types)
      t = Thread.new do
        loop do
          header = read_data
          check_rpc_error!(header)
          if header['Seq'] == res.header.seq
            ev = read_data
            block.call(ev) if block
          else
            break
          end
        end
      end
      [res, t]
    end
def stream ( types , & block ) res = request ( :stream , 'Type' => types ) t = Thread . new do loop do header = read_data check_rpc_error! ( header ) if header [ 'Seq' ] == res . header . seq ev = read_data block . call ( ev ) if block else break end end end [ res , t ] end
subscribe to a stream of all events matching a given type filter.
subscribe to a stream of all events matching a given type filter .
None
Thread, Response
types
comma separated list of events
comma separated list of events
block