Based on the afMongo example I'm currently doing this:
mongoClient := MongoClient(ActorPool(), `mongodb://localhost:27017`)
collection := mongoClient.db("mydb").collection("mycollection")
...
// inserts or queries here
...
mongoClient.shutdown
My understanding is that MongoClient uses a pooled connection. If that's correct then I believe I can share the MongoClient across all my DAOs and only shutting it down when the afBedSheet application is shut down.
- Is this assumption correct?
- How can I hook the MongoClient shutdown to the afBedSheet shutdown, please?
MongoClient
.I would have the
ConnectionManager
as a service, and shut that down. So in yourAppModule
:MongoClient
could also be a service.You could also rewrite the above to be a little more, um, correct. I tend to use the
ActorPools
service to keep tabs on them.myPod.closeConnections
is just an arbitrary name and in the example it is not used anywhere else.`But you could use it to override or remove the contribution. Some future test scenario could add a
MyTestAppModule
with the following:Probably not useful in this particular instance, but useful to know about.