Method: Computation#next_message

Defined in:
lib/signalfx/signalflow/computation.rb

#next_message(timeout_seconds = nil) ⇒ Object

Get the next message in this computation.

Parameters:

  • timeout_seconds (Float) (defaults to: nil)

    If a new message does not come within this interval, raises a ChannelTimeout exception. Note that this does not mean that this function will return within this interval since there may be messages received that are part of a larger batch. If nil, will block indefinitely.



60
61
62
63
64
65
66
67
68
69
# File 'lib/signalfx/signalflow/computation.rb', line 60

def next_message(timeout_seconds=nil)
  raise "Computation #{@handle} is not attached to a channel" unless @channel

  msg = nil
  while msg.nil? && !@channel.nil?
    # process_message might return no messages if it is building up a batch
    msg = process_message(@channel.pop(timeout_seconds))
  end
  return msg
end