Open ghost opened 9 years ago
Can you implement the first point? I don't fully understand how to do it with EventMachine.
Yes, sorry for the delay... I will have enough time to contribute on the weekend.
I'm not 100% sure how to do, but I believe will be something based on faye channel subscription: http://faye.jcoglan.com/ruby/clients.html, with the exception that for every "subscribed channel", instead of creating a loop or callback, will spawn/delegate using EM.defer to an EventLoop like the one present on RTMConnection: https://github.com/kenjij/lita-slack/blob/master/lib/lita/adapters/slack/rtm_connection.rb#L39
Does it make sense?
Eventmachine is an hybrid reactor-pattern implementation. While the main thread runs evented loop, you can spawn additional "worker threads" to perform different computations using EM.defer.
It would be really cool if @jimmycuadra could give a feedback here :)
I have tried to subscribe for multiple channels with Faye, but with no result.
Is multithreading really necessary for this? I prefer to avoid it.
Lita already uses it (threads).
I have to read documentation again to fully understand whether defer is the right thing or how to use eventmachine own eventloop code correctly (I believe we will have to use something like Fibers).
The whole idea is that we need something to subscribe in an "evented way" to different endpoints and when it receives valid data, it should delegate tho the handlers in a non blocking way (this will use defer).
This last step is important because handlers can do heavy operations like remote IO, etc. If we don't isolate the handler from the eventloop, lita will have huge latency in crowded channels.
I have an idea on how to implement this in some simple incremental steps:
will give a try to the first point and report back when have it working