Project

horobi

0.01
No commit activity in last 3 years
No release in over 3 years
mesh network builder with ZeroMQ
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.0.0
~> 1.5.2
>= 0
~> 2.3.0
 Project Readme

horobi

Horobi is very flexible mesh network builder with ZeroMQ.

zmq model

Virtual realtime web.

sample1

Scalable logging architecture.

sample2

Or, you can do all on one machine.

sample3

Node Type

Pub

Pub-node push some interesting data to Hub-node.

#!/usr/bin/env ruby
require "rubygems"
require "horobi"

loop do
  Horobi::Pub.send(Time.now.to_s)
  sleep 1
end

Real world sample as below:

#!/usr/bin/env ruby
require "rubygems"
require "twitter/json_stream" # https://github.com/voloko/twitter-stream
require "horobi"

EM.run do
  stream = Twitter::JSONStream.connect(
    :path    => '/1/statuses/filter.json?track=ruby',
    :auth    => 'LOGIN:PASSWORD'
  )

  stream.each_item do |json|
    Horobi::Pub.send("twitter " + json)
  end
end

Hub

Hub-node get data from Pub-node, and push to Sub-node.

#!/usr/bin/env ruby
require "rubygems"
require "horobi"

Horobi::Hub.start

Sub

Sub-node get data from Hub-node and do some stuff.

#!/usr/bin/env ruby
require "rubygems"
require "notify" # https://github.com/jugyo/notify
require "json"
require "horobi"

Horobi::Sub.listen("twitter") do |data|
  tweet = JSON.parse(data)
  Notify.notify(tweet["user"]["screen_name"], tweet["text"])
end

Example

Please see example/ directory.

# launch pub node with background job, stream push to tcp://127.0.0.1:5551. if you don't want to log messages, use -l /dev/null option
$ SCREEN_NAME=uu59 PASSWORD=xxxx ruby example/twitter/pub1.rb -o tcp://127.0.0.1:5551 ruby & # tracking twitter stream with "ruby"
$ ruby example/twitter/pub2.rb -o tcp://127.0.0.1:5551 & # fake stream

# launch hub node as daemon(-d), ZeroMQ PULL socket listen to tcp://127.0.0.1:5551 (-i 5551) and PUB socket is tcp://127.0.0.1:5552 (-o 5552)
$ ruby example/twitter/hub.rb -d -i 5551 -o 5552

# get data from tcp://127.0.0.1:5552. you'll get mixed stream of twitter and fake.
$ ruby example/twitter/sub1.rb -i tcp://127.0.0.1:5552

You can ignore launch sequence to Pub/Sub/Hub nodes.

Install

Install ZeroMQ first.

http://www.zeromq.org/intro:get-the-software

And install gem

$ sudo gem install zmq horobi

Contributing to horobi

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
  • Fork the project
  • Start a feature/bugfix branch
  • Commit and push until you are happy with your contribution
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright

Copyright (c) 2011 uu59. See LICENSE.txt for further details.