Permalink
Browse files

Introduced Cucub::Channel.inner_inbound and Cucub::Channel.inner_outb…

…ound
  • Loading branch information...
1 parent 28fa7ce commit 8e04992b88db8f10c516461731f820c30c17d4fe @krakatoa krakatoa committed Oct 24, 2012
Showing with 34 additions and 2 deletions.
  1. +27 −2 lib/channel.rb
  2. +7 −0 lib/dispatcher.rb
View
29 lib/channel.rb
@@ -28,21 +28,46 @@ def self.reply
@reply
end
+ ### Right now, and in earlier versions, cucub-server will support only REPLY socket for inbound.
+=begin
def self.pull
# Es usado dentro del Reactor
return @pull if @pull.is_a? MaZMQ::Pull
@pull = MaZMQ::Pull.new
@pull.bind(:tcp, Cucub.address, 6442)
####
-=begin
@pull.on_read { |msg|
Cucub::Queue.instance.push(msg)
}
-=end
@pull
end
+=end
+
+ def self.inner_inbound
+ # a ZMQ PUSH-PULL socket which binds to the local server as a 'pusher',
+ # so workers connect to it in a 1-N way to consume messages.
+
+ # 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.new
+ @inner_inbound = MaZMQ::Push.new
+ @inner_inbound.bind :ipc, "/tmp/cucub-inner-inbound.sock"
+ end
+
+ def self.inner_outbound
+ # a ZMQ PUSH-PULL socket which binds to the local server as a 'puller',
+ # so workers connect to it in a 1-N way to push their messages.
+
+ # 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.new
+ @inner_outbound = MaZMQ::Pull.new
+ @inner_outbound.bind :ipc, "/tmp/cucub-inner-outbound.sock"
+ end
####
=begin
View
7 lib/dispatcher.rb
@@ -13,6 +13,8 @@ def start(block=nil)
block ||= Proc.new {}
EM.epoll
EM.run do
+ self.init_inner_channels
+
#### @proxy_worker = Cucub::ProxyWorker::connection
## TODO if list.size == 1 => oid unico
@@ -69,6 +71,11 @@ def start(block=nil)
end
end
+ def init_inner_channels
+ @inner_inbound = Cucub::Channel.inner_inbound
+ @inner_outbound = Cucub::Channel.inner_outbound
+ end
+
def stop
#### Cucub::LiveProxy.shutdown!
Cucub::Channel.shutdown!

0 comments on commit 8e04992

Please sign in to comment.