Skip to content

Conversation

@xibz
Copy link
Contributor

@xibz xibz commented Feb 7, 2018

Pagination will be typed now and users will be able to grab a aws.Pager from the API requests.

svc := s3.New(cfg)
req := svc.ListObjectsRequest(input)
p := req.Paginate()

for p.Next() {
    page := p.CurrentPage()
    fmt.Println("List Objects' contents", len(page.Contents))
}

if err := p.Err(); err != nil {
    fmt.Println("unexpected error occurred", err.Error())
}

@xibz xibz requested a review from jasdel February 7, 2018 19:10
Copy link
Contributor

@jasdel jasdel left a comment

Choose a reason for hiding this comment

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

Looks like a few merge issues in the codebase, the protocol benchmark files have merge issues, or not updated like they should of been with the gen marshaler change.

//
// Will always return true if Next has not been called yet.
func (p *Pagination) HasNextPage() bool {
func (p *Pager) hasNextPage() bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

out of curiosity why not export this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With the new design, I couldn't think of a good reason to export it.


"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/internal/awstesting"
"github.com/aws/aws-sdk-go-v2/aws/defaults"
Copy link
Contributor

Choose a reason for hiding this comment

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

so much red! :)


// Use DynamoDB methods for simplicity
func TestPaginationEachPage(t *testing.T) {
/*// Use DynamoDB methods for simplicity
Copy link
Contributor

Choose a reason for hiding this comment

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

large block of commented code here.

})
}
}
}*/
Copy link
Contributor

Choose a reason for hiding this comment

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

can this block be uncommented, or tested directly?

"GetCrosslinkURL": GetCrosslinkURL,
}).Parse(`
{{ $reqType := printf "%sRequest" .ExportedName -}}
{{ $pagerType := printf "%sPager" .ExportedName -}}
Copy link
Contributor

Choose a reason for hiding this comment

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

We want to make sure this __Pager type won't collide with modeled shapes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah! Good point. Will fix.

}
var output {{ .OutputRef.GoTypeElem }}
req := aws.New(p.Request.Config, p.Request.Metadata, p.Request.Handlers.Copy(), p.Request.Retryer, p.Request.Operation, inCpy, &output)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not directly related to this PR, but we should rename the aws.New method to aws.NewRequest

}
var output {{ .OutputRef.GoTypeElem }}
req := aws.New(p.Request.Config, p.Request.Metadata, p.Request.Handlers.Copy(), p.Request.Retryer, p.Request.Operation, inCpy, &output)
Copy link
Contributor

Choose a reason for hiding this comment

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

If there are in custom code generated into the API's __Request method this will bypass that code. e.g. Signing logic, ect.

For example its possible for the __Request logic to have a closure referencing some instance value such as a output shape. This code probably should just use the base __Request instead of bypasing it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, that makes sense.

@@ -1,85 +0,0 @@
// +build bench
Copy link
Contributor

Choose a reason for hiding this comment

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

Think this is a merge issue, these benchmark files have been removed.

"net/http"
"net/http/httptest"
"os"
"testing"
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't these files of been updated in the generated marshaler change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, this is a rebase issue.

@xibz xibz force-pushed the paginator branch 2 times, most recently from 9e4ae2d to 6babf84 Compare February 8, 2018 17:47
Copy link
Contributor

@jasdel jasdel left a comment

Choose a reason for hiding this comment

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

Looks good few minor things. specifically with the s3manager batch utility using the Paginate() value provided instead of duplicating the logic, and a test that would be good to update.

@@ -162,7 +161,7 @@ func (iter *DeleteListIterator) Next() bool {
}

if len(iter.objects) == 0 && iter.Paginator.Next() {
iter.objects = iter.Paginator.Page().(s3.ListObjectsOutput).Contents
iter.objects = iter.Paginator.CurrentPage().(s3.ListObjectsOutput).Contents
Copy link
Contributor

Choose a reason for hiding this comment

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

The s3/s3manager/DeleteBatch can be updated to use the Pager created by S3.ListObjectsRequest.Paginate() method.

This would also get rid of the closure here. If there are other places that have the aws.Pager{NewRequest:...} like this they probably can be updated as well.

func NewDeleteListIterator(...
    pager := svc.ListObjectsRequest(input).Paginate()
    iter := &DeleteListIterator{
        Bucket: input.Bucket,
        Paginator: pager.Pager,
    }

//...
}


for _, obj := range p.Contents {
fmt.Println("Object:", *obj.Key)
req := svc.ListObjectsRequest(&s3.ListObjectsInput{Bucket: &os.Args[1]})
Copy link
Contributor

Choose a reason for hiding this comment

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

Noticed the listObjectsConcurrently example isn't using the paginator like it should be. Only the first page is used in that example. If you don't mind would be good to update that one as well.

Paginator: request.Pagination{
NewRequest: func() (*request.Request, error) {
Paginator: aws.Pager{
NewRequest: func() (*aws.Request, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

These tests can be updated to use the ListObjectsRequest(input).Paginate() returned pager value.

@xibz xibz merged commit 5e8e36f into aws:master Feb 13, 2018
jasdel added a commit to jasdel/aws-sdk-go-v2 that referenced this pull request Mar 8, 2018
Services
---
* Synced the V2 SDK with latests AWS service API definitions.

Breaking Changes
---
* `private/mode/api`: Refactor service paginator helpers to iterator pattern ([aws#119](aws#119))
	* Refactors the generated service client paginators to be an iterator pattern. This pattern improves usability while removing the need for callbacks.
	* See the linked PR for an example.
* `private/model/api`: Removes setter helpers from service API types ([aws#101](aws#101))
	* Removes the setter helper methods from service API types. Removing clutter and noise from the API type's signature.
	* Based on feedback [aws#81][aws#81]
* `aws`: Rename CanceledErrorCode to ErrCodeRequestCanceled ([aws#131](aws#131))
	* Renames CanceledErrorCode to correct naming scheme.

SDK Bugs
---
* `internal/awsutil`: Fix DeepEqual to consider string alias type equal to string ([aws#102](aws#102))
	* Fixes SDK waiters not detecting the correct condition is met. [aws#92](aws#92)
* `aws/external`: Fix EnvConfig misspelled container endpoint path getter ([aws#106](aws#106))
	* This caused the type to not satisfy the ContainerCredentialsEndpointPathProvider interface.
	* Fixes [aws#105](aws#105)
* `service/s3/s3crypto`: Fix S3Crypto's handling of TagLen ([aws#107](aws#107))
	* Fixes the S3Crypto's handling of TagLen to only be set if present.
	* V2 Fix for [aws/aws-sdk-go#1742](aws/aws-sdk-go#1742)
* `private/model/api`: Update SDK service client initialization documentation ([aws#141](aws#141))
	* Updates the SDK's service initialization doc template to reflect the v2 SDK's configuration update change from v1.
	* Related to [aws#136](aws#136)

SDK Enhancements
---
* `aws`: Improve pagination unit tests ([aws#97](aws#97))
	* V2 port of [aws/aws-sdk-go#1733](aws/aws-sdk-go#1733)
* `aws/external`: Add example for shared config and static credential helper ([aws#109](aws#109))
	* Adds examples for the  config helpers; WithSharedConfigProfile, WithCredentialsValue, WithMFATokenFunc.
* `private/model/api`: Add validation to prevent collision of api defintions ([aws#112](aws#112))
	* V2 port of [aws/aws-sdk-go#1758](aws/aws-sdk-go#1758)
* `aws/ec2metadata`: Add support for AWS_EC2_METADATA_DISABLED env var ([aws#128](aws#128))
	* When this environment variable is set. The SDK's EC2 Metadata Client will not attempt to make requests. All requests made with the EC2 Metadata Client will fail.
	* V2 port of [aws/aws-sdk-go#1799](aws/aws-sdk-go#1799)
* Add code of conduct ([aws#138](aws#138))
* Update SDK README dep usage ([aws#140](aws#140))
jasdel added a commit to jasdel/aws-sdk-go-v2 that referenced this pull request Mar 8, 2018
Services
---
* Synced the V2 SDK with latests AWS service API definitions.

Breaking Changes
---
* `private/mode/api`: Refactor service paginator helpers to iterator pattern (aws#119)
	* Refactors the generated service client paginators to be an iterator pattern. This pattern improves usability while removing the need for callbacks.
	* See the linked PR for an example.
* `private/model/api`: Removes setter helpers from service API types (aws#101)
	* Removes the setter helper methods from service API types. Removing clutter and noise from the API type's signature.
	* Based on feedback aws#81
* `aws`: Rename CanceledErrorCode to ErrCodeRequestCanceled (aws#131)
	* Renames CanceledErrorCode to correct naming scheme.

SDK Bugs
---
* `internal/awsutil`: Fix DeepEqual to consider string alias type equal to string (aws#102)
	* Fixes SDK waiters not detecting the correct condition is met. aws#92
* `aws/external`: Fix EnvConfig misspelled container endpoint path getter (aws#106)
	* This caused the type to not satisfy the ContainerCredentialsEndpointPathProvider interface.
	* Fixes aws#105
* `service/s3/s3crypto`: Fix S3Crypto's handling of TagLen (aws#107)
	* Fixes the S3Crypto's handling of TagLen to only be set if present.
	* V2 Fix for aws/aws-sdk-go#1742
* `private/model/api`: Update SDK service client initialization documentation (aws#141)
	* Updates the SDK's service initialization doc template to reflect the v2 SDK's configuration update change from v1.
	* Related to aws#136

SDK Enhancements
---
* `aws`: Improve pagination unit tests (aws#97)
	* V2 port of aws/aws-sdk-go#1733
* `aws/external`: Add example for shared config and static credential helper (aws#109)
	* Adds examples for the  config helpers; WithSharedConfigProfile, WithCredentialsValue, WithMFATokenFunc.
* `private/model/api`: Add validation to prevent collision of api defintions (aws#112)
	* V2 port of aws/aws-sdk-go#1758
* `aws/ec2metadata`: Add support for AWS_EC2_METADATA_DISABLED env var (aws#128)
	* When this environment variable is set. The SDK's EC2 Metadata Client will not attempt to make requests. All requests made with the EC2 Metadata Client will fail.
	* V2 port of aws/aws-sdk-go#1799
* Add code of conduct (aws#138)
* Update SDK README dep usage (aws#140)
jasdel added a commit to jasdel/aws-sdk-go-v2 that referenced this pull request Mar 8, 2018
Services
---
* Synced the V2 SDK with latests AWS service API definitions.

Breaking Changes
---
* `private/mode/api`: Refactor service paginator helpers to iterator pattern (aws#119)
	* Refactors the generated service client paginators to be an iterator pattern. This pattern improves usability while removing the need for callbacks.
	* See the linked PR for an example.
* `private/model/api`: Removes setter helpers from service API types (aws#101)
	* Removes the setter helper methods from service API types. Removing clutter and noise from the API type's signature.
	* Based on feedback aws#81
* `aws`: Rename CanceledErrorCode to ErrCodeRequestCanceled (aws#131)
	* Renames CanceledErrorCode to correct naming scheme.

SDK Bugs
---
* `internal/awsutil`: Fix DeepEqual to consider string alias type equal to string (aws#102)
	* Fixes SDK waiters not detecting the correct condition is met. aws#92
* `aws/external`: Fix EnvConfig misspelled container endpoint path getter (aws#106)
	* This caused the type to not satisfy the ContainerCredentialsEndpointPathProvider interface.
	* Fixes aws#105
* `service/s3/s3crypto`: Fix S3Crypto's handling of TagLen (aws#107)
	* Fixes the S3Crypto's handling of TagLen to only be set if present.
	* V2 Fix for aws/aws-sdk-go#1742
* `private/model/api`: Update SDK service client initialization documentation (aws#141)
	* Updates the SDK's service initialization doc template to reflect the v2 SDK's configuration update change from v1.
	* Related to aws#136

SDK Enhancements
---
* `aws`: Improve pagination unit tests (aws#97)
	* V2 port of aws/aws-sdk-go#1733
* `aws/external`: Add example for shared config and static credential helper (aws#109)
	* Adds examples for the  config helpers; WithSharedConfigProfile, WithCredentialsValue, WithMFATokenFunc.
* `private/model/api`: Add validation to prevent collision of api defintions (aws#112)
	* V2 port of aws/aws-sdk-go#1758
* `aws/ec2metadata`: Add support for AWS_EC2_METADATA_DISABLED env var (aws#128)
	* When this environment variable is set. The SDK's EC2 Metadata Client will not attempt to make requests. All requests made with the EC2 Metadata Client will fail.
	* V2 port of aws/aws-sdk-go#1799
* Add code of conduct (aws#138)
* Update SDK README dep usage (aws#140)
jasdel added a commit that referenced this pull request Mar 8, 2018
Services
---
* Synced the V2 SDK with latests AWS service API definitions.

Breaking Changes
---
* `private/mode/api`: Refactor service paginator helpers to iterator pattern (#119)
	* Refactors the generated service client paginators to be an iterator pattern. This pattern improves usability while removing the need for callbacks.
	* See the linked PR for an example.
* `private/model/api`: Removes setter helpers from service API types (#101)
	* Removes the setter helper methods from service API types. Removing clutter and noise from the API type's signature.
	* Based on feedback #81
* `aws`: Rename CanceledErrorCode to ErrCodeRequestCanceled (#131)
	* Renames CanceledErrorCode to correct naming scheme.

SDK Bugs
---
* `internal/awsutil`: Fix DeepEqual to consider string alias type equal to string (#102)
	* Fixes SDK waiters not detecting the correct condition is met. #92
* `aws/external`: Fix EnvConfig misspelled container endpoint path getter (#106)
	* This caused the type to not satisfy the ContainerCredentialsEndpointPathProvider interface.
	* Fixes #105
* `service/s3/s3crypto`: Fix S3Crypto's handling of TagLen (#107)
	* Fixes the S3Crypto's handling of TagLen to only be set if present.
	* V2 Fix for aws/aws-sdk-go#1742
* `private/model/api`: Update SDK service client initialization documentation (#141)
	* Updates the SDK's service initialization doc template to reflect the v2 SDK's configuration update change from v1.
	* Related to #136

SDK Enhancements
---
* `aws`: Improve pagination unit tests (#97)
	* V2 port of aws/aws-sdk-go#1733
* `aws/external`: Add example for shared config and static credential helper (#109)
	* Adds examples for the  config helpers; WithSharedConfigProfile, WithCredentialsValue, WithMFATokenFunc.
* `private/model/api`: Add validation to prevent collision of api defintions (#112)
	* V2 port of aws/aws-sdk-go#1758
* `aws/ec2metadata`: Add support for AWS_EC2_METADATA_DISABLED env var (#128)
	* When this environment variable is set. The SDK's EC2 Metadata Client will not attempt to make requests. All requests made with the EC2 Metadata Client will fail.
	* V2 port of aws/aws-sdk-go#1799
* Add code of conduct (#138)
* Update SDK README dep usage (#140)
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.

2 participants