Top Level Namespace
- Includes:
- SysVIPC
Defined Under Namespace
Classes: IPCTransit
Instance Method Summary collapse
- #clear_test_queue ⇒ Object
- #kill_daemon(pid) ⇒ Object
- #run_daemon(prog) ⇒ Object
- #transit_deflate(args) ⇒ Object
- #transit_freeze(args) ⇒ Object
- #transit_inflate(args) ⇒ Object
- #transit_thaw(args) ⇒ Object
Instance Method Details
#clear_test_queue ⇒ Object
4 5 6 7 8 9 |
# File 'lib/ipc_transit/test.rb', line 4 def clear_test_queue begin IPCTransit.remove('qname' => $ipc_transit_test_qname) rescue Exception => msg end end |
#kill_daemon(pid) ⇒ Object
20 21 22 |
# File 'lib/ipc_transit/test.rb', line 20 def kill_daemon(pid) Process.kill(9, pid) end |
#run_daemon(prog) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/ipc_transit/test.rb', line 11 def run_daemon(prog) pid = fork if pid.nil? #child exec "ruby -Ilib bin/#{prog} -p/tmp/test_ipc_transit" exit end return pid end |
#transit_deflate(args) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/ipc_transit/compress.rb', line 3 def transit_deflate(args) if args['c'].nil? compression_type = 'none' else compression_type = args['c'] end case compression_type when 'none' return args['frozen'] when 'zlib' return Zlib::deflate(args['frozen']) end end |
#transit_freeze(args) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/ipc_transit/serialize.rb', line 6 def transit_freeze(args) if args['e'].nil? serialize_type = 'json' else serialize_type = args['e'] end case serialize_type when 'json' args['frozen'] = args['message'].to_json when 'yaml' args['frozen'] = YAML.dump(args['message']) end return transit_deflate(args) end |
#transit_inflate(args) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ipc_transit/compress.rb', line 17 def transit_inflate(args) if args['wire_headers'].nil? compression_type = 'none' else if args['wire_headers']['c'].nil? compression_type = 'none' else compression_type = args['wire_headers']['c'] end end case compression_type when 'none' return args['serialized_message'] when 'zlib' return Zlib::inflate(args['serialized_message']) end end |
#transit_thaw(args) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ipc_transit/serialize.rb', line 21 def transit_thaw(args) if args['wire_headers'].nil? serialize_type = 'json' else if args['wire_headers']['e'].nil? serialize_type = 'json' else serialize_type = args['wire_headers']['e'] end end begin inflated = transit_inflate(args) rescue Exception => msg puts "transit_thaw exception: #{e}" end case serialize_type when 'json' args['thawed'] = JSON.parse(inflated) when 'yaml' args['thawed'] = YAML.load(inflated) end return args['thawed'] end |