I need to have an infinite loop on top of eventmachine that constantly reads a redis queue. below is my code. is recursion the right way to do it? I tried loop do
loop, but could not make it work that way.
require 'em-hiredis'
def read
d = @redis.blpop 'queue', 0
d.callback do |_, value|
p value
read
end.errback do |e|
p e
EM.next_tick { read }
end
end
EM.run do
@redis = EM::Hiredis.connect
read
end