-
Notifications
You must be signed in to change notification settings - Fork 891
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-2689 (POC) Simplify the "readpref" API #1733
base: master
Are you sure you want to change the base?
Conversation
API Change Report./v2/eventincompatible changes##ServerDescription.Tags: changed from ./v2/tag.Set to ./v2/mongo/readpref.TagSet ./v2/mongo/readprefincompatible changes(*ReadPref).MaxStaleness: changed from func() (time.Duration, bool) to func() *time.Duration compatible changesBuilder: added ./v2/tagincompatible changespackage removed ./v2/x/mongo/driver/descriptionincompatible changes##SelectedServer.Tags: changed from ./v2/tag.Set to ./v2/mongo/readpref.TagSet |
type ReadPref struct { | ||
Mode Mode | ||
|
||
maxStaleness *time.Duration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current pattern prevents users from creating invalid read preferences, for example:
ms := 1 * time.Second
rp := readpref.ReadPref{
Mode: readpref.PrimaryMode,
MaxStaleness: &ms,
}
Concerning server selection:
If the mode field is “primary”, the tags, maxStalenessSeconds, and hedge fields MUST be absent.
Concerning max staleness:
A connection string combining a positive maxStalenessSeconds with read preference mode “primary” MUST be considered invalid; this includes connection strings with no explicit read preference mode.
The only driver I've investigated that doesn't follow the pattern of validating in the read preference constructor is C (compared to Node, Python, PHP). C uses a _mongoc_read_prefs_validate function to validate this behavior.
GODRIVER-2689
Summary
Background & Motivation