class Pantry::Communication::SerializeMessage

Handles all serialization of Pantry::Messages to and from the ZeroMQ communication stack

Constants

IS_JSON

To prevent accidents like trying to send the raw contents of a JSON file and end up with a Ruby hash on the other side, we designate messages as being JSON using a simple one character prefix. This way we don’t have to guess if it’s JSON or not and will leave non encoded strings alone. Don’t want to dive into anything more complicated unless it’s really necessary (like msgpack).

Public Class Methods

from_zeromq(parts) click to toggle source

Given an array of message parts from ZeroMQ, built up a Pantry::Message containing the included information.

# File lib/pantry/communication/serialize_message.rb, line 24
def self.from_zeromq(parts)
  FromZeromq.new(parts).perform
end
to_zeromq(message) click to toggle source

Convert a message into an array of message parts that will be sent through ZeroMQ.

# File lib/pantry/communication/serialize_message.rb, line 18
def self.to_zeromq(message)
  ToZeromq.new(message).perform
end