-
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-2617 Remove deprecated code #1398
Conversation
5446a0d
to
1b99cfd
Compare
d1127f2
to
3ef44aa
Compare
3ef44aa
to
f35a93a
Compare
78b17ff
to
cfd0ffc
Compare
a6d3aca
to
fe99af6
Compare
f050dc0
to
f3fea53
Compare
628a603
to
5b1da45
Compare
e261dc3
to
23df976
Compare
bwo := options.BulkWrite() | ||
for _, opt := range opts { | ||
if opt == nil { | ||
continue | ||
} | ||
if opt.Comment != nil { | ||
bwo.Comment = opt.Comment | ||
} |
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 intent of removing the Merge...Options
functions is also to remove the bug-prone logic of merging options structs together. Instead, we want to only allow a single options struct and return an error if the user passes more than one.
E.g.
if len(opts) > 1 {
return errors.New("only one BulkWriteOptions can be provided")
}
bwo := options.BulkWrite()
if len(opts) == 1 {
bwo = opts[0]
}
...
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.
That change will be handled in GODRIVER-2696, so it's fine to keep the options struct merging here. Consider this comment resolved.
mongo/description/server.go
Outdated
Passive bool | ||
Primary address.Address | ||
ReadOnly bool | ||
ServiceID *primitive.ObjectID // Only set for servers that are deployed behind a load balancer. | ||
SessionTimeoutMinutesPtr *int64 |
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.
Optional: It's a little awkward to leave a field named ...Ptr
. Consider renaming SessionTimeoutMinutesPtr
to SessionTimeoutMinutes
.
@@ -1971,7 +1971,10 @@ func WithTransactionExample(ctx context.Context) error { | |||
defer func() { _ = client.Disconnect(ctx) }() | |||
|
|||
// Prereq: Create collections. | |||
wcMajority := writeconcern.New(writeconcern.WMajority(), writeconcern.WTimeout(1*time.Second)) | |||
wcMajority := &writeconcern.WriteConcern{ |
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.
Can we use the convenience function in the example, instead of using the "majority" magic string?
wcMajority := writeconcern.Majority()
wcMajority.WTimeout = 1 * time.Second
@@ -2552,7 +2555,11 @@ func CausalConsistencyExamples(client *mongo.Client) error { | |||
|
|||
// Use a causally-consistent session to run some operations | |||
opts := options.Session().SetDefaultReadConcern(readconcern.Majority()).SetDefaultWriteConcern( | |||
writeconcern.New(writeconcern.WMajority(), writeconcern.WTimeout(1000))) | |||
&writeconcern.WriteConcern{ |
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.
Can we use the convenience function in the example, instead of using the "majority" magic string?
wcMajority := writeconcern.Majority()
wcMajority.WTimeout = 1000
readconcern.Majority()).SetDefaultWriteConcern(writeconcern.New(writeconcern.WMajority(), | ||
writeconcern.WTimeout(1000))) | ||
readconcern.Majority()).SetDefaultWriteConcern( | ||
&writeconcern.WriteConcern{ |
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.
Can we use the convenience function in the example, instead of using the "majority" magic string?
wcMajority := writeconcern.Majority()
wcMajority.WTimeout = 1000
description: "empty", | ||
input: []*options.ChangeStreamOptions{}, | ||
want: &options.ChangeStreamOptions{}, | ||
}, |
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.
Can we include a nil
case as well?
x/mongo/driver/operation_test.go
Outdated
wcAck := writeconcern.New(writeconcern.WMajority()) | ||
wcUnack := writeconcern.New(writeconcern.W(0)) | ||
wcAck := writeconcern.Majority() | ||
wcUnack := &writeconcern.WriteConcern{W: 0} |
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.
wcUnack := &writeconcern.WriteConcern{W: 0} | |
wcUnack := writeconcern.Unacknowledged() |
mongo/integration/collection_test.go
Outdated
@@ -1688,7 +1685,7 @@ func TestCollection(t *testing.T) { | |||
assert.Equal(mt, res.UpsertedIDs[3].(string), id3, "expected UpsertedIDs[3] to be %v, got %v", id3, res.UpsertedIDs[3]) | |||
}) | |||
unackClientOpts := options.Client(). | |||
SetWriteConcern(writeconcern.New(writeconcern.W(0))) | |||
SetWriteConcern(&writeconcern.WriteConcern{W: 0}) |
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.
SetWriteConcern(&writeconcern.WriteConcern{W: 0}) | |
SetWriteConcern(writeconcern.Unacknowledged()) |
mongo/integration/index_view_test.go
Outdated
@@ -264,7 +263,7 @@ func TestIndexView(t *testing.T) { | |||
} | |||
}) | |||
unackClientOpts := options.Client(). | |||
SetWriteConcern(writeconcern.New(writeconcern.W(0))) | |||
SetWriteConcern(&writeconcern.WriteConcern{W: 0}) |
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.
SetWriteConcern(&writeconcern.WriteConcern{W: 0}) | |
SetWriteConcern(writeconcern.Unacknowledged()) |
mongo/integration/index_view_test.go
Outdated
@@ -345,7 +344,7 @@ func TestIndexView(t *testing.T) { | |||
Name: indexNames[1], | |||
}) | |||
}) | |||
wc := writeconcern.New(writeconcern.W(1)) | |||
wc := &writeconcern.WriteConcern{W: 1} |
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.
wc := &writeconcern.WriteConcern{W: 1} | |
wc := writeconcern.W1() |
mongo/integration/sessions_test.go
Outdated
@@ -107,7 +107,7 @@ func TestSessions(t *testing.T) { | |||
}) | |||
}) | |||
|
|||
unackWcOpts := options.Collection().SetWriteConcern(writeconcern.New(writeconcern.W(0))) | |||
unackWcOpts := options.Collection().SetWriteConcern(&writeconcern.WriteConcern{W: 0}) |
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.
unackWcOpts := options.Collection().SetWriteConcern(&writeconcern.WriteConcern{W: 0}) | |
unackWcOpts := options.Collection().SetWriteConcern(writeconcern.Unacknowledged()) |
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.
Looks good 👍
bwo := options.BulkWrite() | ||
for _, opt := range opts { | ||
if opt == nil { | ||
continue | ||
} | ||
if opt.Comment != nil { | ||
bwo.Comment = opt.Comment | ||
} |
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.
That change will be handled in GODRIVER-2696, so it's fine to keep the options struct merging here. Consider this comment resolved.
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.
LGTM
GODRIVER-2617
GODRIVER-2885
Summary
Remove or un-export deprecated code in Go Driver 2.0.
Background & Motivation
options.MergeClientOptions
will be removed in GODRIVER-3001.GODRIVER-2862 and GODRIVER-2927 are not covered in this PR.