EventMachine 和 EventMachine 是如何工作的?导轨集成?
我发现很多文章向我展示了 EventMachine 是什么以及如何设置无尽的“Hello World!”示例,但我仍然不知道它如何与我的 Rails 应用程序集成。
例如,我有一个现有的 Rails 应用程序,其中有许多并发用户,他们可能同时编辑数据库中的同一行。我想我会允许两个(或更多)不同的人加载记录,但如果记录已更新,则通知这些用户,并强制后面的用户在将其保存回数据库之前协调任何冲突的更改。我想我可以在客户端使用 Javascript 处理通知和协调,并使用 websockets(或 flashsockets)与浏览器通信(如果另一个用户更新记录,例如推送通知等)。
最后一部分引导我使用 EventMachine,但是——正如我的引导问题所示——我不知道如何将其集成到我的 Rails 应用程序中。
谁能给我一些对此的见解(例如,一个好的宏观观点)或为我指出一些好的资源? (除了 EventMachine 的 wiki,因为我已经去过那里了)。
I've found plenty of articles showing me what EventMachine is and how to set up endless "Hello World!" examples, but I'm still at a loss as to how this integrates with my Rails application.
As a example, I have an existing Rails app that has many concurrent users who may be editing the same row in my database simultaneously. I was thinking that I would allow the record to be loaded by two (or more) different people, but notify those users if the record was updated and force the latter users to reconcile any conflicting changes before saving it back to the database. I was thinking I could handle the notifications and reconciliations using Javascript on the client side and websockets (or flashsockets) to communicate with the browser (on the event that another user updates the record--like a push notification, or something).
The last part led me to EventMachine, but--as my lead-off question indicates--I'm at a loss about how to integrate this into my Rails app.
Can anyone give me some insight to this (like, a good macro-level viewpoint) or point me towards some good resources? (Apart from EventMachine's wiki, as I've already been there).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我花了相当多的时间来研究这个问题。 EventMachine 需要在 Rails 安装中作为线程运行(除非您使用 Thin),并且对于 Passenger 有一些特殊的注意事项。我在这里编写了我们的实现:http://www.hiringthing。 com/2011/11/04/eventmachine-with-rails.html
I spent a considerable amount of time looking into this. EventMachine needs to run as a thread in your rails install (unless you are using Thin,) and there are some special considerations for Passenger. I wrote our implementation up here: http://www.hiringthing.com/2011/11/04/eventmachine-with-rails.html
我认为一些异步 Rails 设置的这个示例也可以帮助您调查类似 EventMachine 的功能使用情况在应用程序中。但它与 EventMachine 本身并不完全相关。
I think this example of some async Rails setup could also help you in your investigation of EventMachine like features usage in the applications. It is not fully related to EventMachine itself, though.