mongo.cr icon indicating copy to clipboard operation
mongo.cr copied to clipboard

Mongo.cr and the event loop

Open ursuscamp opened this issue 7 years ago • 3 comments

Does mongo.cr use the asynchronous event loop provided by Crystal, or will it block?

ursuscamp avatar Aug 14 '17 15:08 ursuscamp

mongo.cr is using mongoc driver which by default is using libc IO. So it will block the process. As an experiment I implemented src/mongo/stream.cr to delegate all IO operations to crystal event loop. Please try it and let me know if it helps.

datanoise avatar Aug 14 '17 16:08 datanoise

Looking through the code, it seems all it needs to set it up is to call setup_stream on the Mongo::Client instance. Is that correct?

ursuscamp avatar Aug 14 '17 17:08 ursuscamp

That's correct.

datanoise avatar Aug 15 '17 19:08 datanoise