In the example below, two bud instances communicate via a zookeeper collection. The program times out. However, if I uncomment the print() inside the bloom block of ReadOff, it works as expected (begins delivering tuples, and exits without error).
module Zook
state{ store :zk, :zookeeper, :path => '/', :addr => 'localhost:2181' }
end
class StuffOn
include Bud
include Zook
state{ interface input, :iput }
bloom do
zk <~ iput{|p| [p.key, p.val, {:ephemeral => true, :sequence => true}]}
end
end
class ReadOff
include Bud
include Zook
state{ interface output, :outs }
bloom do
outs <= zk do |z|
#print ""
z
end
stdio <~ outs.inspected
end
end
r = ReadOff.new
r.run_bg
q = Queue.new
r.register_callback(:outs) do |cb|
q.push true
end
s = StuffOn.new
s.run_bg
(0..100).each do |i|
s.async_do { s.iput <+ [["foo#{i}-", "bar#{i}"]] }
end
Timeout.timeout(5) do
q.pop
end
r.stop_bg
s.stop_bg
In the example below, two bud instances communicate via a zookeeper collection. The program times out. However, if I uncomment the print() inside the bloom block of ReadOff, it works as expected (begins delivering tuples, and exits without error).