Module: AgentJail::Pipe
- Defined in:
- lib/agent_jail/pipe.rb
Overview
Handles the result pipe protocol between parent and child processes. The child writes exactly one Marshal payload (success or error). The parent reads until EOF and parses it.
Class Method Summary collapse
Class Method Details
.read_result(raw) ⇒ Object
21 22 23 24 25 |
# File 'lib/agent_jail/pipe.rb', line 21 def self.read_result(raw) return nil if raw.nil? || raw.empty? Marshal.load(raw) end |
.write_error(io, exception) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/agent_jail/pipe.rb', line 12 def self.write_error(io, exception) io.write(Marshal.dump({ status: :error, class: exception.class.name, message: exception., backtrace: exception.backtrace })) end |
.write_result(io, value) ⇒ Object
8 9 10 |
# File 'lib/agent_jail/pipe.rb', line 8 def self.write_result(io, value) io.write(Marshal.dump({ status: :ok, value: value })) end |