Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongoid and mongomapper with eventmachine

I'm very new to eventmachine and I haven't been able to find an answer to this question online.

Right now I've been using em-mongo with eventmachine, and I've written essentially a poor man's mapper between documents and their respective objects. I just wanted to confirm that mongoid and mongomapper can not be used in an eventmachine environment because they are blocking and thus defeat the point of using eventmachine in the first place, and that I'm not wasting my time writing these mappers. :P

like image 951
nan Avatar asked Apr 08 '11 01:04

nan


2 Answers

EventMachine Synchrony might be what you want:

https://github.com/igrigorik/em-synchrony

It supports Mongoid and I guess makes it thread safe. Haven't personally tried it but it looks promising with active development.

like image 118
Brian Armstrong Avatar answered Nov 13 '22 13:11

Brian Armstrong


From a quick peek at the mongoid and mongo_mapper source code, you would be correct. My approach would be to just clone mongoid (or mongomapper) and swap out the blocking http connections with async connections. The majority of the framework details are not tied to the async http connection and should be re-usable. Good luck!

like image 43
Shakakai Avatar answered Nov 13 '22 12:11

Shakakai