globalsign / mgo

The MongoDB driver for Go
Other
1.97k stars 230 forks source link

mgo.ParseURL function and retry requests #168

Closed theoks closed 6 years ago

theoks commented 6 years ago

I created a Atlas MongoDB cluster for testing purposes. The option that appears on the site is this:

screen shot 2018-05-18 at 08 32 29

The format of the given string is:

mongodb://<USERNAME>:<PASSWORD>@<SERVER_NAME>:27017,<SERVER_NAME>:27017,<SERVER_NAME>:27017/test?ssl=true&replicaSet=Main-shard-0&authSource=admin&retryWrites=true

which is according to the specs:

mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]

The string in this form however cannot be parsed by the mgo.ParseURL function. I checked the issue with the ssl option (https://stackoverflow.com/a/42522753/4772647), but I still had an issue. It only worked when I removed the database name and every option (ssl, retry writes etc)

I have a couple of questions if someone could answer:

  1. If the driver in its current version supports retryable writes (https://docs.mongodb.com/manual/core/retryable-writes/)
  2. If it is planned to support both the new option in the Connection Options (retryWrites) and the new URI format (mongodb+srv://server.example.com/) (https://docs.mongodb.com/manual/reference/connection-string/#dns-seedlist-connection-format)

Thank you in advance!

weiishann commented 6 years ago

Hi @tkallioras,

We do not have support for both features yet. PRs are welcomed! :)

domodwyer commented 6 years ago

Hi @tkallioras

I think that's actually an issue with Atlas? Retryable writes did not exist before 3.6 so it's not a valid option for a v3.4 driver, as it relies on the OP_MSG wire protocol added in 3.6 (we have an implementation, however it is not currently used due to a performance regression we need to chase down).

As for the DNS seed list, we have https://github.com/globalsign/mgo/issues/112 open to track adding it as a feature - like @weiishann says, we'd love a PR if you have the time!

Sorry!

Dom

theoks commented 6 years ago

@domodwyer @weiishann Thank you both for your answers. It's a great library. Thank you for your work :)