Skip to content
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

chore(mongodb): upgrade driver to version 2.0.0 #3108

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ooesili
Copy link
Contributor

@ooesili ooesili commented Jan 10, 2025

  • SetSocketTimeout was removed, and its usage has been replaced with SetTimeout
  • mongo.Connect` no longer accepts a context because it was never used
  • The WriteConcern struct no longer contains a timeout field, context is used instead, so I added a wrapper struct with this field to minimize code changes
  • The options packages has been overhauled so there are a bunch of code changes around setting options

For more information, see this doc https://github.com/mongodb/mongo-go-driver/blob/v2.0.0/docs/migration-2.0.md

@ooesili ooesili added dependencies Pull requests that update a dependency file go Pull requests that update Go code mongodb labels Jan 10, 2025
@ooesili ooesili self-assigned this Jan 10, 2025
internal/impl/mongodb/common.go Show resolved Hide resolved
@@ -188,10 +188,13 @@ func (m *Processor) ProcessBatch(ctx context.Context, batch service.MessageBatch
Hint: hintJSON,
}
case OperationFindOne:
collection := m.database.Collection(collectionStr, m.writeConcernCollectionOption)
ctx, cancel := context.WithTimeout(context.Background(), m.writeConcernSpec.wTimeout)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Read timeout? Seems wrong to use a write timeout here...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Or maybe we should deprecate writeConcernSpec.wTimeout the and just use the ProcessBatch ctx instead. Not sure why it wasn't used before...

Same for the output since https://github.com/mongodb/mongo-go-driver/blob/v2.0.0/docs/migration-2.0.md#wtimeout

The WTimeout field has been removed from the WriteConcern struct. Instead, users should define a timeout at the operation-level using a context object.

To deprecate a field, we typically remove it from everywhere except the docs (see example here and here) and mention it in the Changelog.

@rockwotj
Copy link
Collaborator

Looks good thanks! Looks like the linter is :blobmad:

Copy link
Collaborator

@mihaitodor mihaitodor left a comment

Choose a reason for hiding this comment

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

Nice job @ooesili! I just left one small comment, but feel free to ignore it if it would cause trouble for users. Otherwise feel free to :shipit:

@@ -188,10 +188,13 @@ func (m *Processor) ProcessBatch(ctx context.Context, batch service.MessageBatch
Hint: hintJSON,
}
case OperationFindOne:
collection := m.database.Collection(collectionStr, m.writeConcernCollectionOption)
ctx, cancel := context.WithTimeout(context.Background(), m.writeConcernSpec.wTimeout)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Or maybe we should deprecate writeConcernSpec.wTimeout the and just use the ProcessBatch ctx instead. Not sure why it wasn't used before...

Same for the output since https://github.com/mongodb/mongo-go-driver/blob/v2.0.0/docs/migration-2.0.md#wtimeout

The WTimeout field has been removed from the WriteConcern struct. Instead, users should define a timeout at the operation-level using a context object.

To deprecate a field, we typically remove it from everywhere except the docs (see example here and here) and mention it in the Changelog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file go Pull requests that update Go code mongodb
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants