-
Notifications
You must be signed in to change notification settings - Fork 905
GODRIVER-3043 Use default write/read concerns in the index search commands. #1563
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,27 +15,25 @@ import ( | |
"go.mongodb.org/mongo-driver/bson" | ||
"go.mongodb.org/mongo-driver/event" | ||
"go.mongodb.org/mongo-driver/mongo/description" | ||
"go.mongodb.org/mongo-driver/mongo/writeconcern" | ||
"go.mongodb.org/mongo-driver/x/bsonx/bsoncore" | ||
"go.mongodb.org/mongo-driver/x/mongo/driver" | ||
"go.mongodb.org/mongo-driver/x/mongo/driver/session" | ||
) | ||
|
||
// CreateSearchIndexes performs a createSearchIndexes operation. | ||
type CreateSearchIndexes struct { | ||
indexes bsoncore.Document | ||
session *session.Client | ||
clock *session.ClusterClock | ||
collection string | ||
monitor *event.CommandMonitor | ||
crypt driver.Crypt | ||
database string | ||
deployment driver.Deployment | ||
selector description.ServerSelector | ||
writeConcern *writeconcern.WriteConcern | ||
result CreateSearchIndexesResult | ||
serverAPI *driver.ServerAPIOptions | ||
timeout *time.Duration | ||
indexes bsoncore.Document | ||
session *session.Client | ||
clock *session.ClusterClock | ||
collection string | ||
monitor *event.CommandMonitor | ||
crypt driver.Crypt | ||
database string | ||
deployment driver.Deployment | ||
selector description.ServerSelector | ||
result CreateSearchIndexesResult | ||
serverAPI *driver.ServerAPIOptions | ||
timeout *time.Duration | ||
} | ||
|
||
// CreateSearchIndexResult represents a single search index result in CreateSearchIndexesResult. | ||
|
@@ -109,9 +107,15 @@ func (csi *CreateSearchIndexes) Execute(ctx context.Context) error { | |
return driver.Operation{ | ||
CommandFn: csi.command, | ||
ProcessResponseFn: csi.processResponse, | ||
Client: csi.session, | ||
Clock: csi.clock, | ||
CommandMonitor: csi.monitor, | ||
Crypt: csi.crypt, | ||
Database: csi.database, | ||
Deployment: csi.deployment, | ||
Selector: csi.selector, | ||
ServerAPI: csi.serverAPI, | ||
Timeout: csi.timeout, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's peculiar all this data was missing from the operation. Was it just missed in the original implementation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it will be better to align with the implementation in "create_indexes.go". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIUC, the search index management server commands actually manage resources on an Apache Lucene cluster (and maybe some database configuration), so it's possible some of the previously omitted info was unnecessary. However, it's not clear what the impact of adding or removing those fields is. I generally agree that passing the same info as Edit: To clarify, we shouldn't block merging the PR, but we should try to figure out whether we're missing test coverage for this type of behavior change that could be hiding other omissions. |
||
}.Execute(ctx) | ||
|
||
} | ||
|
@@ -214,16 +218,6 @@ func (csi *CreateSearchIndexes) ServerSelector(selector description.ServerSelect | |
return csi | ||
} | ||
|
||
// WriteConcern sets the write concern for this operation. | ||
func (csi *CreateSearchIndexes) WriteConcern(writeConcern *writeconcern.WriteConcern) *CreateSearchIndexes { | ||
if csi == nil { | ||
csi = new(CreateSearchIndexes) | ||
} | ||
|
||
csi.writeConcern = writeConcern | ||
return csi | ||
} | ||
|
||
// ServerAPI sets the server API version for this operation. | ||
func (csi *CreateSearchIndexes) ServerAPI(serverAPI *driver.ServerAPIOptions) *CreateSearchIndexes { | ||
if csi == nil { | ||
|
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.
Why not exhaust the cursor?
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.
I break on negative
cursor.Next
to reduce the deep nesting block and simplify the exiting of the recurringList
calls.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.
I mention doing this because this is what CXX does: https://github.com/kevinAlbs/mongo-cxx-driver/blob/fff7c2c71438f9f62c6b1a6ca5dee20f1c1749ac/src/mongocxx/test/search_index_view.cpp#L19
I think the current implementation is fine, though. IIUC in case 6 there would only ever be one doc on the cursor for
view.List
. Is that correct?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.
Correct.