-
Type: Task
-
Resolution: Duplicate
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Go Drivers
Context
Unlike operation-level options, client options are rather complex and have a wide variety of use cases. For example, mongodb-kubernetes-operator.
Definition of done
List ways to mitigate pain points in the use of client options in v2.
Maintain deprecated v1 behavior.
To avoid causing too much migration pain, suggest we add a deprecated function called ConnectWithOptions that exactly maintains the v2 behavior of Connect(). This gives users a way to defer complex refactors required to migrate to v2 options.
// Deprecated: Use Connect instead func ConnectWithOptions(opts ...*options.ClientOptions) (Client, error) { clientOpt := options.MergeClientOptions(opts...) // ... }
Export a MergeCollectionOptions function
mopts := MergeCollectionOptions(opt1, opt2, ...) client, _ := mongo.Connect(mopts)
This could also be added as an method to ClientOptionsBuilder called Merge.
Pitfalls
Maintain deprecated v1 behavior.
We will have to maintain MergeClientOptions until 3.0
Export a MergeCollectionOptions function
We will have to maintain `MergeCollectionOptions` indefinitely.
- duplicates
-
GODRIVER-3434 Revert options pattern for ClientOptions
- In Code Review