Chattyproc
TODO: Write a gem description
Installation
Add this line to your application's Gemfile:
gem 'chattyproc'
And then execute:
$ bundle
Or install it yourself as:
$ gem install chattyproc
Usage
Right now ChattyProc only includes a single process communication method - a pipe server. The idea behind the pipe server is that a process can communicate back and forth with processes that it forks. Here's a quick example:
require "chattyproc"
# Set up the pipe server
ps = ChattyProc::PipeServer.new
# Fork a new process
fork do
# Mark this process as the callee
ps.callee!
= ps.read
ps.write("Hello #{}")
end
# Mark this process as the caller
ps.caller!
# Send a message over to the other process
ps.write("Alan")
# Print the response
response = ps.read
# Wait for the child process to exit
Process.waitall
This style of pipe server is in use in tconsole and has worked amazingly well. It's faster than DRb for communication between forked processes, and has shown itself to be less error prone.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request