https://github.com/cotag/celluloid-presence
Node presence using ZooKeeper for celluloid services
https://github.com/cotag/celluloid-presence
Last synced: 9 months ago
JSON representation
Node presence using ZooKeeper for celluloid services
- Host: GitHub
- URL: https://github.com/cotag/celluloid-presence
- Owner: cotag
- License: mit
- Created: 2013-03-26T01:24:06.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2013-03-27T09:16:58.000Z (about 13 years ago)
- Last Synced: 2025-10-07T14:21:44.470Z (9 months ago)
- Language: Ruby
- Size: 129 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.textile
- License: MIT-LICENSE
Awesome Lists containing this project
README
h1. Celluloid Presence
Start an instance of "ZooKeeper":http://zookeeper.apache.org/ on your dev machine then run:
require 'rubygems'
require 'celluloid-presence'
Celluloid::Presence::ZkService.init :server => 'localhost'
Celluloid::Presence::ZkPresence.supervise_as :presence, :service_name => :presence
class Messaging
include Celluloid
include Celluloid::Notifications
def self.finalizer
:finalize
end
def initialize(service_name)
@service_name = service_name
subscribe("#{@service_name}_nodes", :node_update)
end
def node_update(event, nodes)
p "\nNode list updated!"
nodes.each do |node|
p " -> #{Actor[@service_name].get(node)}"
end
end
private
def finalize
Actor[@service_name].terminate
end
end
Messaging.run(:presence)
h2. Start using it now
# Read the "Documentation":http://rubydoc.info/gems/celluloid-presence/Celluloid/Presence
# Then @gem install celluloid-presence@