Is it possible to add tasks to EM.run within Goliath? For example, I'm
trying to create a proxy that connects outbound to a pool of sockets
without having to open a new connection for every response. The goal is
to take our existing server-queue-client model and compress it into a
single Goliath/EM application. You're probably asking "why?", and I
don't have a good answer for that one. ;)
The equivalent code in our existing worker looks something like this:
EM.run do
parser = Yajl::Parser.new
queue = EM::Hiredis.connect(redis)
ENV['SOCKET_HOSTS'].split(",").each do |socket_host|
(host,port) = socket_host.split(":")
EM::connect(host, port, SocketClient, queue, parser)
end
end
The end goal would be to have Goliath response push the payload to
EM::Queue, which would then get popped by the SocketClient and sent over
one of the long-running socket connections.
Thanks,
--
Jason Dixon
http://obfuscurity.com/
https://twitter.com/obfuscurity