-
Type: New Feature
-
Resolution: Won't Fix
-
Priority: Major - P3
-
None
-
Affects Version/s: 1.0.1
-
Component/s: Connections
-
None
-
Environment:Linux
MongoDB 4.0
Hello
I'm migrating my code from globalsign/mgo to the official mongo driver.
In my tests, I was using the "FailFast" optionĀ https://godoc.org/github.com/globalsign/mgo#DialInfo.FailFast
It allows to connect to a MongoDB server with a "normal" timeout (e.g. 10 sec), however it will return an error after the first failed attempt.
This is very useful in tests, because I want to skip my test if my local instance of MongoDB is not available.
With mgo, all my tests were skipped very quickly, because the connection attempt returned an error immediately, and wasn't retried.
However, in the mongo official driver, there is no such option. I can only define a very low "connect timeout" (e.g. 100 ms). This solution is not ideal, because on some busy CI server it could take longer to connect to MongoDB. This will cause "flaky" tests.