Skip to content

GODRIVER-3891 Remove the operation.Command type.#2482

Open
matthewdale wants to merge 1 commit into
mongodb:masterfrom
matthewdale:godriver3891-move-command
Open

GODRIVER-3891 Remove the operation.Command type.#2482
matthewdale wants to merge 1 commit into
mongodb:masterfrom
matthewdale:godriver3891-move-command

Conversation

@matthewdale

@matthewdale matthewdale commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

GODRIVER-3891

Summary

  • Completely remove the operation.Command type.
  • Use the driver.Operation type directly in processRunCommand in the mongo package.
  • Create a runCommand function specific to the x/mongo/driver/auth package.
  • Create an executeCommand function specific to the x/mongo/driver/integration package.

Background & Motivation

Part of a larger effort to reduce unnecessary code by removing the x/mongo/driver/operation package.

Unlike other types in the x/mongo/driver/operation package, the operation.Command type does not provide any command logic, but is a thin wrapper around driver.Operation, only adding cursor response parsing for a single caller (mongo.RunCommandCursor). This PR completely removes the operation.Command type, replacing it with direct use of driver.Operation.

@mongodb-drivers-pr-bot

Copy link
Copy Markdown
Contributor

API Change Report

./v2/x/mongo/driver/operation

incompatible changes

Command: removed
NewCommand: removed
NewCursorCommand: removed

@mongodb-drivers-pr-bot

mongodb-drivers-pr-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

🧪 Performance Results

Commit SHA: e2235f4

The following benchmark tests for version 6a55a8c98243090007aba576 had statistically significant changes (i.e., |z-score| > 1.96):

Benchmark Measurement % Change Patch Value Stable Region H-Score Z-Score
BenchmarkSingleRunCommand allocated_bytes_per_op -0.2017 12208.0000 Avg: 12232.6744
Med: 12234.0000
Stdev: 6.6835
0.8650 -3.6918

For a comprehensive view of all microbenchmark results for this PR's commit, please check out the Evergreen perf task for this patch.

@matthewdale matthewdale force-pushed the godriver3891-move-command branch from 2325809 to a942ef7 Compare July 10, 2026 22:05
@matthewdale matthewdale changed the title GODRIVER-3891 Move command to the mongo package. GODRIVER-3891 Remove the operation.Command type. Jul 10, 2026
@matthewdale matthewdale added review-priority-low Low Priority PR for Review: within 3 business days ignore-for-release labels Jul 10, 2026
@matthewdale matthewdale force-pushed the godriver3891-move-command branch from a942ef7 to e2235f4 Compare July 14, 2026 03:11
@matthewdale matthewdale marked this pull request as ready for review July 14, 2026 04:39
@matthewdale matthewdale requested a review from a team as a code owner July 14, 2026 04:39
@matthewdale matthewdale added review-priority-normal Medium Priority PR for Review: within 1 business day and removed review-priority-low Low Priority PR for Review: within 3 business days labels Jul 14, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.go and replaced call sites with direct driver.Operation usage.
  • Refactored mongo.Database’s RunCommand paths to build/return a *driver.Operation and attach response processing in RunCommand / 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ignore-for-release review-priority-normal Medium Priority PR for Review: within 1 business day

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants