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

Docstore/awsdynamodb: Supporting the AWS V2 SDK #3519

Open
wants to merge 27 commits into
base: master
Choose a base branch
from

Conversation

Maldris
Copy link

@Maldris Maldris commented Jan 31, 2025

Resolved #3458

A somewhat quick and dirty conversion to using the AWS V2 SDK rather than the deprecated V1.

Due to the delays in my finding time to work on this I prioritised getting the functionality migrated to mitigate any risk from API drift form the deprecated V1 SDK.

The main sections that warrant further discussion:

  • codec behaviour could be handled better with type switches now, but may be a follow up task
  • url opener doesn't use a configuration override any more, most of this is handled by V2ConfigFromURLParams, but is worth review
  • error handling using an As pattern and I've declared all the as targets in a block which is likely less memory efficient, but simple to read, should another approach be used?

…es, returning that concrete type to avoid unnecessary type assertion
Copy link

google-cla bot commented Jan 31, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link
Contributor

@jba jba left a comment

Choose a reason for hiding this comment

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

We appreciate the effort you put into this. However, there is a lot of changed code here, including at least two breaking changes. How does the docstore user benefit from the switch to the new API?

Note that the breaking changes are unlikely to be approved, because they would require a v2 of the main module.

@@ -36,6 +37,7 @@ aws dynamodb create-table \
# The docstore-test-2 table has both a partition and a sort key, and two indexes.

aws dynamodb create-table \
--region us-east-2 \
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this line different?

Copy link
Author

Choose a reason for hiding this comment

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

The unit tests hard code the region as us-east-2, but the creation script used to set up the test db's don' t specify a region, falling back to the user default, this was to improve consistency in testing

@@ -75,8 +69,6 @@ const Scheme = "dynamodb"
// See https://godoc.org/gocloud.dev/aws#ConfigFromURLParams for supported query
// parameters for overriding the aws.Session from the URL.
type URLOpener struct {
// ConfigProvider must be set to a non-nil value.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a breaking change.

Copy link
Author

Choose a reason for hiding this comment

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

This was flagged in the original message soliciting feedback on the best way to address, as omitting it is in keeping with several other V2 implementations, but regardless the type will change to support V2

if err != nil {
return nil, "", "", "", nil, fmt.Errorf("open collection %s: %v", u, err)
}
return db, tableName, partitionKey, sortKey, opts, nil
}

// Dial gets an AWS DynamoDB service client.
func Dial(p client.ConfigProvider) (*dyn.DynamoDB, error) {
if p == nil {
func Dial(p aws.Config) (*dyn.Client, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a breaking change.

Copy link
Author

Choose a reason for hiding this comment

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

This has changed to the equivalent type used for AWS SDK V2, again, please see the comment below on why that change has already been discussed and is necessary.

@Maldris
Copy link
Author

Maldris commented Feb 3, 2025

Hi Johnathan,

Last year the AWS SDK V1 was deprecated (see announcement about maintenance and end of support in project readme) with its maintenance grace period set to end on 7/31/2025, this PR was created to address that and move the package to using the new SDK as all the other modules already have.

This was discussed in the flagged issue #3458
Forms part of the larger body of work supporting #3489
And follows all the other modules being moved to use V2 as the default (#3465 and #3466)

docstore/awsdynamodb was the only module without a V2 implementation, and as seen in #3458 was discussed as being better served as a breaking replacement ahead of removing V1 from other modules, rather than the more complicated task of building a complete abstraction of the behaviour to support both, or having duplicated code for both.

I'll be adding comments on the three sections you've specifically flagged as well.

@Maldris Maldris requested a review from jba February 4, 2025 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docstore/awsdynamodb: Support AWS SDK V2
2 participants