On Wed, 02 Nov 2016 00:55:55 GMT, Uiy Uiy wrote:
If I try to connect to a mongoDB in a static this, it fails.
I suppose that vibe.d has not initialized the mongoDB driver.
It simplifies my code to initialize module level global database variables in static this but this is non-compliant with vibe.d. While I could spawn a thread and spin for a bit until vibe.d has run, this is not the optimal solution.
MongoClient client; MongoDatabase db; MongoCollection collection; static this() { client = connectMongoDB("127.0.0.1"); db = client.getDatabase("Test"); collection = client.getCollection("Test.test"); }
Any ideas?
The event loop is not running yet in static this.