Module: Dynflow::Listeners::Serialization
- Included in:
- Executors::RemoteViaSocket, Executors::RemoteViaSocket::Core, Socket
- Defined in:
- lib/dynflow/listeners/serialization.rb
Defined Under Namespace
Modules: Protocol
Instance Method Summary collapse
- #dump(obj) ⇒ Object
- #load(str) ⇒ Object
- #receive_message(io) ⇒ Object
- #send_message(io, message, barrier = nil) ⇒ Object
Instance Method Details
#dump(obj) ⇒ Object
47 48 49 |
# File 'lib/dynflow/listeners/serialization.rb', line 47 def dump(obj) MultiJson.dump(obj.to_hash) end |
#load(str) ⇒ Object
51 52 53 |
# File 'lib/dynflow/listeners/serialization.rb', line 51 def load(str) Protocol::Message.from_hash MultiJson.load(str) end |
#receive_message(io) ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/dynflow/listeners/serialization.rb', line 66 def (io) if ( = io.gets) load() else nil end rescue IOError nil end |
#send_message(io, message, barrier = nil) ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/dynflow/listeners/serialization.rb', line 55 def (io, , = nil) .lock if io.puts dump() true rescue SystemCallError => error @logger.warn "message could not be sent #{} because #{error}" false ensure .unlock if end |