mongo.cr
mongo.cr copied to clipboard
Mongo.cr and the event loop
Does mongo.cr use the asynchronous event loop provided by Crystal, or will it block?
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.
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?
That's correct.