RbZMQ
An opinionated ruby library wrapping ffi-rzmq for more rubish flair.
Library is still pre-release 0.x
. Everything may change anytime.
Installation
Add this line to your application's Gemfile:
gem 'rbzmq', '~> 0.1'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rbzmq
Usage
You can use RbZMQ's sockets just like in the zguide but without the need to handle a context. A global context will be used automagically.
require 'rbzmq'
writer = RbZMQ::Socket.new ZMQ::PUSH
writer.connect 'tcp://127.0.0.1:4237'
writer.send 'My Message!'
writer.send 'My Second Message!'
reader = RbZMQ::Socket.new ZMQ::PULL
reader.bind 'tcp://127.0.0.1:4237'
p reader.recv.to_s
p reader.recv.to_s
writer.close
reader.close
See examples/
for a growing number of translated examples from the zguide.
TODO
- RbZMQ::Reactor
- Pimp RbZMQ::Message
- Socket option accessors
- Class documentation w/ examples
- Translate zguide examples (and try to use them for auto testing)
- Integration options into EventMachine (plus Fibers) / Celluloid (if possible)
Contributing
- Fork it (http://github.com/jgraichen/rbzmq/fork)
- 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
License
Copyright (C) 2014 Jan Graichen
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see http://www.gnu.org/licenses/.