Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Using PanZMQ as socket handler gem

  • Loading branch information...
commit 106b2124a7822e8f78e31e87bf928e310370df4f 1 parent baff375
@krakatoa krakatoa authored
Showing with 27 additions and 25 deletions.
  1. +1 −1  Gemfile
  2. +6 −8 Gemfile.lock
  3. +13 −11 lib/channel.rb
  4. +7 −5 lib/dispatcher.rb
View
2  Gemfile
@@ -8,7 +8,7 @@ group :cli do
gem "servolux"
end
-gem "ma-zmq", :path => "/home/krakatoa/workspace/al-nattahnam/ma-zmq"
+gem "pan-zmq", :path => "/home/krakatoa/workspace/al-nattahnam/pan-zmq"
gem "cucub-protocol", :path => "/home/krakatoa/workspace/al-nattahnam/cucub/protocol", :require => "cucub-protocol"
# Add dependencies to develop your gem here.
View
14 Gemfile.lock
@@ -6,19 +6,17 @@ PATH
msgpack
PATH
- remote: /home/krakatoa/workspace/al-nattahnam/ma-zmq
+ remote: /home/krakatoa/workspace/al-nattahnam/pan-zmq
specs:
- ma-zmq (0.0.2)
- eventmachine (= 1.0.0.beta.4)
- ffi-rzmq (= 0.9.3)
+ pan-zmq (0.0.1)
+ ffi-rzmq (~> 0.9.6)
GEM
remote: http://rubygems.org/
specs:
diff-lcs (1.1.3)
- eventmachine (1.0.0.beta.4)
- ffi (1.1.5)
- ffi-rzmq (0.9.3)
+ ffi (1.2.0)
+ ffi-rzmq (0.9.6)
ffi
git (1.2.5)
inifile (2.0.2)
@@ -55,7 +53,7 @@ DEPENDENCIES
bundler (~> 1.2.1)
cucub-protocol!
jeweler (~> 1.8.4)
- ma-zmq!
+ pan-zmq!
rspec
servolux
simplecov
View
24 lib/channel.rb
@@ -8,12 +8,13 @@ def self.initialize
def self.reply
# Es usado dentro del Reactor
- return @reply if @reply.is_a? MaZMQ::Reply
+ return @reply if @reply.is_a? PanZMQ::Reply
$stdout.puts "Initializing Outer Inbound (REPLY) socket"
- @reply = MaZMQ::Reply.new
- @reply.bind(:tcp, Cucub::Server.instance.address, 6441)
+ @reply = PanZMQ::Reply.new
+ @reply.bind("tcp://#{Cucub::Server.instance.address}:6441")
+ @reply.register
- @reply.on_read { |msg|
+ @reply.on_receive { |msg|
# Chequear por llamada async / sync
# Async - returns job id
@@ -55,10 +56,10 @@ def self.inner_inbound
# It works by setting up an IPC socket. In a future, it might be considered to
# enable tcp communication, so workers can be outside the local server.
- return @inner_inbound if @inner_inbound.is_a? MaZMQ::Push
+ return @inner_inbound if @inner_inbound.is_a? PanZMQ::Push
$stdout.puts "Initializing Inner Inbound (PUSH) socket"
- @inner_inbound = MaZMQ::Push.new
- @inner_inbound.bind :ipc, "/tmp/cucub-inner-inbound.sock"
+ @inner_inbound = PanZMQ::Push.new
+ @inner_inbound.bind "ipc:///tmp/cucub-inner-inbound.sock"
end
def self.inner_outbound
@@ -68,10 +69,11 @@ def self.inner_outbound
# It works by setting up an IPC socket. In a future, it might be considered to
# enable tcp communication, so workers can be outside the local server.
- return @inner_outbound if @inner_outbound.is_a? MaZMQ::Pull
+ return @inner_outbound if @inner_outbound.is_a? PanZMQ::Pull
$stdout.puts "Initializing Inner Outbound (PULL) socket"
- @inner_outbound = MaZMQ::Pull.new
- @inner_outbound.bind :ipc, "/tmp/cucub-inner-outbound.sock"
+ @inner_outbound = PanZMQ::Pull.new
+ @inner_outbound.bind "ipc:///tmp/cucub-inner-outbound.sock"
+ @inner_outbound.register
end
####
@@ -154,7 +156,7 @@ def self.shutdown!
end
=end
- MaZMQ.terminate
+ PanZMQ.terminate
end
end
end
View
12 lib/dispatcher.rb
@@ -1,5 +1,5 @@
require 'singleton'
-require 'ma-zmq'
+require 'pan-zmq'
module Cucub
class Dispatcher
@@ -11,8 +11,9 @@ def initialize
def start(block=nil)
block ||= Proc.new {}
- EM.epoll
- EM.run do
+ #EM.epoll
+ #EM.run do
+
self.init_inner_channels
#### @proxy_worker = Cucub::ProxyWorker::connection
@@ -68,7 +69,8 @@ def start(block=nil)
=end
block.call
- end
+ #end
+ PanZMQ::Poller.instance.poll
end
def init_inner_channels
@@ -79,7 +81,7 @@ def init_inner_channels
def stop
#### Cucub::LiveProxy.shutdown!
Cucub::Channel.shutdown!
- EM.stop
+ #EM.stop
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.