[GODRIVER-348] Refactor Client Creation Created: 05/Apr/18 Updated: 28/Oct/23 Resolved: 27/Nov/18 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | Options & Configuration |
| Affects Version/s: | None |
| Fix Version/s: | 0.1.0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Kristofer Brandow (Inactive) | Assignee: | Isabella Siu (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | beta, neweng | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Epic Link: | Finalize mongo API | ||||||||
| Description |
|
Remove the NewClientFromConnString function from the mongo package. This will remove the confusion around creating connection strings for users and the inability to remake a string version of that connection string form a connstring.ConnString instance.
Currently there are 3 functions that can be used to create a new mongo.Client: NewClient, NewClientWithOptions, and NewClientFromConnString. While useful to be able to create a client with either a URI or a ConnString it complicates the API. For instance, if we wanted to allow users to also use ClientOptions and a ConnString we would need to add another function. The current way of using ClientOptions is to start with mongo.ClientOpt and build the options off of that. To help clean up the API, we should change how Clients are created. Have a single function, NewClient, that takes a ClientOptions struct. Add two new functions, WithURI and WithConnString, each returning a ClientOptions struct. The new API would work like this:
We could change the methods on ClientOptions to be With* to make it read better as well. Alternatively, we can just have two functions, NewClient and NewClientWithConnString, with the following signatures:
But this means adding a custom dialer to the client would look like this:
|
| Comments |
| Comment by Githook User [ 27/Nov/18 ] |
|
Author: {'name': 'Isabella Siu', 'email': 'isabella.siu@10gen.com'}Message: Change-Id: I6493a4be9d54e5f8f57d05527d2b150ba408c532 |
| Comment by Sam Kleinman (Inactive) [ 21/May/18 ] |
|
After talking with Kris, I think this makes sense to wait until |
| Comment by Kristofer Brandow (Inactive) [ 05/Apr/18 ] |