orlandos-nl / MongoKitten

Native MongoDB driver for Swift, written in Swift

Home Page:https://orlandos.nl/docs/mongokitten/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Vapor 3 uses monkitten4.0, and new connections appear to the mongodb database every time a request is made

wenxini234 opened this issue · comments

How to close the connection or reuse the database connection

eg:
2019-03-13T09:35:50.429377200Z 2019-03-13T09:35:50.429+0000 I NETWORK [conn25] received client metadata from 172.17.0.1:44242 conn25: { driver: { name: "MongoKitten", version: "4.0.0" }, os: { type: "Darwin", version: "10.13.6" } }
2019-03-13T09:35:51.259446400Z 2019-03-13T09:35:51.258+0000 I NETWORK [listener] connection accepted from 172.17.0.1:44244 #26 (26 connections now open)
2019-03-13T09:35:51.259485100Z 2019-03-13T09:35:51.259+0000 I NETWORK [conn26] received client metadata from 172.17.0.1:44244 conn26: { driver: { name: "MongoKitten", version: "4.0.0" }, os: { type: "Darwin", version: "10.13.6" } }

thinks

MongoKitten 4 was using a synchronous API design. It's unable to reuse connections sometimes because the other connection's thread is being blocked. There's been no request for this yet, but we didn't implement support for connection pool customization in MongoKitten 4.

If you're able to, I'd highly recommend using MongoKitten 5. The main downside I expect you to encounter is the requirement to .wait() on futures in synchronous environments.
Otherwise we can work out a nonbreaking way with a low impact on the codebase to implement this customization in MongoKitten 4.

By the way, I think you're using Vapor 3. In which case I'd strongly recommend using MongoKitten 5.

I'm closing this issue due to it being stale. If you've got any more questions, feel free to discuss further or open a new issue.