Provides an easy to use abstraction for sharing Ruby objects between Ruby processes.
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.gitignore
.travis.yml
.yardopts
CHANGELOG.md
Gemfile
LICENSE.txt
README.md
Rakefile
zchannel.gemspec

README.md

Mirrors:

zchannel

Provides an easy to use abstraction for sharing Ruby objects between Ruby processes who share a parent-child relationship. The implementation uses an unbound UNIXSocket, and a serializer of your choice, for sending Ruby objects between processes.

Examples

1.

Marshal is the serializer that can serialize the most Ruby objects, although Proc and other objects cannot be serialized. It is apart of Ruby's core library, so no require is needed:

ch = ZChannel.unix Marshal
Process.wait fork { ch.send "Hello, world!" }
ch.recv # => "Hello, world!"

2.

JSON can be used as a serializer but what it can serialize is less than what Marshal can serialize. Which could be a good or bad thing, depending on what you want to do:

require 'json'
ch = ZChannel.unix JSON
Process.wait fork { ch.send [1,2,3] }
ch.recv # => [1,2,3]

3.

Any serializer that implements "dump", & "load" is supported though, so YAML also works out of the box:

require 'yaml'
ch = ZChannel.unix YAML
Process.wait fork { ch.send [1,2,3] }
ch.recv # => [1,2,3]

Requirements

Ruby 2.1 or later.

Install

Rubygems:

$ gem install zchannel.rb

Bundler:

gem "zchannel.rb", git: "https://github.com/r-obert/zchannel.rb"

License

MIT