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