GODRIVER-3891 Remove the operation.Command type.#2482
Conversation
API Change Report./v2/x/mongo/driver/operationincompatible changesCommand: removed |
🧪 Performance ResultsCommit SHA: e2235f4The following benchmark tests for version 6a55a8c98243090007aba576 had statistically significant changes (i.e., |z-score| > 1.96):
For a comprehensive view of all microbenchmark results for this PR's commit, please check out the Evergreen perf task for this patch. |
2325809 to
a942ef7
Compare
a942ef7 to
e2235f4
Compare
There was a problem hiding this comment.
Pull request overview
This PR removes the operation.Command wrapper type from x/mongo/driver/operation and replaces its usage with direct driver.Operation construction. The goal is to reduce indirection in the ongoing effort to remove the x/mongo/driver/operation package where it provides minimal value.
Changes:
- Deleted
x/mongo/driver/operation/command.goand replaced call sites with directdriver.Operationusage. - Refactored
mongo.Database’s RunCommand paths to build/return a*driver.Operationand attach response processing inRunCommand/RunCommandCursor. - Added package-local command helpers for auth (
runCommand) and integration tests (executeCommand,dropDatabase) to replace the removed wrapper.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| x/mongo/driver/operation/command.go | Removes the operation.Command type entirely. |
| x/mongo/driver/integration/main_test.go | Adds executeCommand helper and updates integration test helpers to use driver.Operation directly. |
| x/mongo/driver/integration/compressor_test.go | Switches serverStatus execution to executeCommand (removes operation.Command usage). |
| x/mongo/driver/auth/x509.go | Routes X509 auth command execution through the new auth-local runCommand helper. |
| x/mongo/driver/auth/sasl.go | Introduces auth-local runCommand helper and replaces operation.Command usage in SASL flows. |
| mongo/database.go | Refactors RunCommand/RunCommandCursor to construct and execute driver.Operation directly and handle cursor parsing via ProcessResponseFn. |
| internal/integtest/integtest.go | Adds dropDatabase helper implemented with driver.Operation and updates topology setup to use it. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
GODRIVER-3891
Summary
operation.Commandtype.driver.Operationtype directly inprocessRunCommandin themongopackage.runCommandfunction specific to thex/mongo/driver/authpackage.executeCommandfunction specific to thex/mongo/driver/integrationpackage.Background & Motivation
Part of a larger effort to reduce unnecessary code by removing the
x/mongo/driver/operationpackage.Unlike other types in the
x/mongo/driver/operationpackage, theoperation.Commandtype does not provide any command logic, but is a thin wrapper arounddriver.Operation, only adding cursor response parsing for a single caller (mongo.RunCommandCursor). This PR completely removes theoperation.Commandtype, replacing it with direct use ofdriver.Operation.