[GODRIVER-2954] Make defining a "majority" write concern literal easier Created: 22/Aug/23  Updated: 10/Nov/23  Resolved: 10/Nov/23

Status: Closed
Project: Go Driver
Component/s: Read and Write Concern
Affects Version/s: 1.12.0
Fix Version/s: 2.0.0

Type: Improvement Priority: Unknown
Reporter: Matt Dale Assignee: Preston Vasquez
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to GODRIVER-2953 Make setting journaled=true on a writ... Backlog
Epic Link: Go Driver 2.0: Driver
Quarter: FY24Q3
Backwards Compatibility: Major Change
Documentation Changes: Not Needed
Documentation Changes Summary:

1. What would you like to communicate to the user about this feature?
2. Would you like the user to see examples of the syntax and/or executable code and its output?
3. Which versions of the driver/connector does this apply to?


 Description   

The new API for creating write concerns (added in v1.12.0) only includes a single way to create a write concern with w:majority: the writeconcern.Majority convenience function. If users want to define a write concern literal for w:majority, ..., they have to define their own string:

j := true
writeConcern := writeconcern.WriteConcern{
	W:       "majority",
	Journal: &j,
}

or use the Majority function to get the "w" field:

writeConcern := &writeconcern.WriteConcern{
	W:       writeconcern.Majority().W,
	Journal: writeconcern.Journaled().Journal,
}

Definition of done:

  • Create a way to define a write concern literal for w:majority, ... without using a literal string or the Majority function.


 Comments   
Comment by Githook User [ 10/Nov/23 ]

Author:

{'name': 'Preston Vasquez', 'email': 'prestonvasquez@icloud.com', 'username': 'prestonvasquez'}

Message: GODRIVER-2954 Add WCMajority const to wc package (#1463)
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/28a05e84246c80de4583620af4fcdccd43670dcb

Comment by Matt Dale [ 22/Aug/23 ]

One option is to define a constant for write concern majority, like

const WMajority = "majority"

However, there is already a function with that name, so we'd have to call it something else or wait until Go Driver 2.0.

Generated at Thu Feb 08 08:39:43 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.