Method: M2R::Connection#deliver

Defined in:
lib/m2r/connection.rb

#deliver(uuid, connection_ids, data, trial = 1) ⇒ String

Delivers data to multiple mongrel2 connections. Useful for streaming.

Parameters:

  • uuid (String)

    Mongrel2 instance uuid

  • connection_ids (Array<String>, String)

    Mongrel2 connections ids

  • data (String)

    Data that should be delivered to the connections

Returns:

  • (String)

    M2 response message



64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/m2r/connection.rb', line 64

def deliver(uuid, connection_ids, data, trial = 1)
  msg = "#{uuid} #{TNetstring.dump([*connection_ids].join(' '))} #{data}"
  ret = @response_socket.send_string(msg, ZMQ::NonBlocking)
  if ret < 0
    e = Error.new "Unable to deliver message: #{ZMQ::Util.error_string}"
    e.errno = ZMQ::Util.errno
    raise e
  end
  return msg
rescue Connection::Error => er
  raise if trial >= 3
  raise unless er.signal?
  deliver(uuid, connection_ids, data, trial + 1)
end