-
Type: Improvement
-
Resolution: Won't Do
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: Read and Write Concern
-
None
When GODRIVER-2685 is complete, the W field in the writeconcern.WriteConcern struct will be exported and visible/settable by anyone. While that simplifies the writeconcern package API, the field can be either a string or an int, so it has to be type interface{}, which can be confusing to users because it doesn't specify what type is required (any value can be set, but some values will result in BSON marshal errors).
For Go Driver 2.0, we can use generics, so make WriteConcern parameterized so we can limit the types usable for W to int or string.
E.g.
type WriteConcern[T string | int] struct { W T // ...
Definition of done:
- The W field on a WriteConcern can only be a string or an int.
Note that users will have to update any WriteConcern literal declarations to include the type parameter. E.g.
&writeconcern.WriteConcern[int]{W: 2}
- is related to
-
GODRIVER-2685 Simplify "writeconcern" API
- Closed