Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GODRIVER-2685 Simplify the writeconcern API. #1232

Merged
merged 4 commits into from
Jun 14, 2023

Conversation

matthewdale
Copy link
Collaborator

@matthewdale matthewdale commented Apr 14, 2023

GODRIVER-2685

Summary

Remove the functional options pattern, export all fields in the WriteConcern struct so users can set them directly, and add package functions for quickly specifying common write concerns w: "majority", w: 0, and w: 1. Since users can now set any value to the exported W field, add type validation logic in the MarshalBSONValue function that returns an error if W is not a supported type, and add tests for the new error logic.

Background & Motivation

The writeconcern package and types use a lot of unnecessary APIs that can confuse users. Additionally, there are no helper functions for specifying common write concerns like there are for the readconcern and readpref packages. Remove the functional options pattern, export all fields in the WriteConcern struct so users can set them directly, and add package functions for quickly building common write concerns w: "majority", w: 0, and w: 1.

@matthewdale matthewdale force-pushed the godriver2685-simplify-wc branch 2 times, most recently from 18bdc1c to 867a496 Compare April 17, 2023 18:30
@matthewdale matthewdale marked this pull request as ready for review April 18, 2023 01:07
mongo/writeconcern/writeconcern.go Outdated Show resolved Hide resolved
mongo/writeconcern/writeconcern.go Outdated Show resolved Hide resolved
mongo/writeconcern/writeconcern.go Outdated Show resolved Hide resolved
mongo/writeconcern/writeconcern.go Outdated Show resolved Hide resolved
mongo/writeconcern/writeconcern.go Outdated Show resolved Hide resolved
mongo/writeconcern/writeconcern.go Outdated Show resolved Hide resolved
mongo/writeconcern/writeconcern.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@prestonvasquez prestonvasquez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

mongo/writeconcern/writeconcern.go Outdated Show resolved Hide resolved
mongo/writeconcern/writeconcern.go Show resolved Hide resolved
@matthewdale matthewdale force-pushed the godriver2685-simplify-wc branch 2 times, most recently from 4e664bb to 8d16e8f Compare June 14, 2023 05:06
@matthewdale matthewdale merged commit a10150b into mongodb:master Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants