Sha256: e32ce58f4e53394a2c1b35b75cbd86b5a0f3d4656e14521116688b11b8124042
Contents?: true
Size: 1.01 KB
Versions: 9
Compression:
Stored size: 1.01 KB
Contents
# PipeRpc PipeRpc was designed so parent und child processes can call each other's methods. It uses a protocol similar to JSON-RPC but serializes the payloads with [msgpack](http://msgpack.org/). ## Installation Add this line to your application's Gemfile: ```ruby gem 'pipe_rpc' ``` And then execute: $ bundle Or install it yourself as: $ gem install pipe_rpc ## Usage ```ruby require 'pipe_rpc' request_read, request_write = IO.pipe response_read, response_write = IO.pipe pid = fork do request_write.close response_read.close class Server def add(a, b) a + b end end hub = PipeRpc::Hub.new(input: request_read, output: response_write) hub.add_server(default: Server.new) loop do hub.handle_message # blocks until message available end end begin request_read.close response_write.close hub = PipeRpc::Hub.new(output: request_write, input: response_read) client = hub.client_for(:default) puts client.add(3, 5) ensure Process.kill 9, pid Process.wait pid end ```
Version data entries
9 entries across 9 versions & 1 rubygems