Class: Pantry::Communication::SerializeMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/pantry/communication/serialize_message.rb

Overview

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

Defined Under Namespace

Classes: FromZeromq, ToZeromq

Constant Summary collapse

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).

''

Class Method Summary collapse

Class Method Details

.from_zeromq(parts) ⇒ Object

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



24
25
26
# File 'lib/pantry/communication/serialize_message.rb', line 24

def self.from_zeromq(parts)
  FromZeromq.new(parts).perform
end

.to_zeromq(message) ⇒ Object

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



18
19
20
# File 'lib/pantry/communication/serialize_message.rb', line 18

def self.to_zeromq(message)
  ToZeromq.new(message).perform
end