Comments (13)
As a workaround the Service API issue you can use aws.StringValue in both files and check against empty string to determine that the end of pagination has been reached.
This will also ensure your code is forward compatible if the MediaPackage service determine they are able to convert the empty string to a null value in the service response. You can also use ListChannelsPages methods to perform the pagination automatically for you.
The V2 SDK also has outstanding #36 to refactor how the v2 SDK will perform pagination.
from aws-sdk-go-v2.
Thanks for pointing this issue out @kaihendry. This looks to be an inconsistency with the Elemental MediaLive and MediaPackage service. I don't think the MediaLive service should not be sending the NextToken
field or sending it as JSON null
. I can forward this issue internally to the MediaLive service, but it would be helpful if you submit feedback to the service directly via their API reference documentation. There is a Feedback button in the bottom right corner of the page you can submit feedback directly to the service teams on an API.
from aws-sdk-go-v2.
Thanks, I struggled to find a regular "List*Pages" example. I ended up with something like:
err = svc.ListInputsPages(&medialive.ListInputsInput{},
func(page *medialive.ListInputsOutput, lastPage bool) bool {
log.Println("Received", len(page.Inputs), "inputs in page")
Inputs = append(Inputs, page.Inputs...)
return lastPage
})
Which worked. But I am not sure if return lastPage
is right.
from aws-sdk-go-v2.
That code should work, except you should changed return lastPage
to return true
. The bool
return value of the pagination callback is to tell the SDK whether to continue paging or not. This is apart of the reason we want to refactor pagination in #36.
A design ideas we're considering for refactoring pagination to would be something similar to the following, using a similar pattern to the bufio's scanner.
This isn't available yet in the SDK but I think something like the following is how we'd like V2 pagination to work.
req := svc.ListInputsRequest(&medialive.ListInputsInput{})
pager := req.Paginate()
for pager.Next() {
page := pager.Page()
log.Println("Received", len(page.Inputs), "inputs in page")
Inputs = append(Inputs, page.Inputs...)
}
if err := pager.Err(); err != nil {
panic("paging failed, " + err.Error())
}
from aws-sdk-go-v2.
Thank you Jason. Sorry, little confused when you say I should write return true
instead. I want it to stop paging when I have everything, and that should be when lastPage is true, no?
from aws-sdk-go-v2.
@kaihendry returning "false" from the callback function will instruct the SDK's paginator to stop paginating. The callback function can return this on any page stating that your application no longer wants to continue to paginate the API. With that said, the SDK will also automatically stop paginating if it reaches the last page. The lastPage
input parameter is there to let your application know that this will be the last page of the API's data. Does that help clarify?
from aws-sdk-go-v2.
Hm... I'm still confused. Can you give me an example of code which gets all the data from every page? Trouble is, unless I am going crazy, I can't get a true from lastPage.
err = svc.ListInputsPages(&medialive.ListInputsInput{},
func(page *medialive.ListInputsOutput, lastPage bool) bool {
log.Println("Received", len(page.Inputs), "inputs in page")
Inputs = append(Inputs, page.Inputs...)
log.Println(lastPage)
return true
})
from aws-sdk-go-v2.
@kaihendry Here is an example using S3 list objects.
Is your callback function only being called once? I'm curious if this issue is related to the testing failure found in #89.
Are you using Go's dep
tool? If not could you try checking out 0b12d6b5
of github.com/jmespath/go-jmespath and see if that corrects the pagination issue.
cd $(go env GOPATH)/src/github.com/jmespath/go-jmespath
git checkout 0b12d6b5
from aws-sdk-go-v2.
@kaihendry Also how many inputs do you expect to have? Any how many are being returned in the ListPages calls? Is it possible that all Inputs have been returned in a single callback?
from aws-sdk-go-v2.
Happy to use dep
, perhaps you can show the Gopkg.toml
and I'll use it by running dep ensure
after?
Tbh I don't think I am hitting multiple pages with this API strangely. When using the aws cli, it definitely needs paging.
from aws-sdk-go-v2.
Thanks for helping us with this issue @kaihendry. I've identified this issue as directly related to MediaLive's API sending a NextToken as an empty string. I created PR #94 as a workaround with this issue. I've reached out to the service team also to address this issue, as it may be preventing other SDKs from paginating the API response correctly.
from aws-sdk-go-v2.
Hope you go to the https://godoc.org/bufio#Scanner approach, since I am still struggling to comprehend return true
, aka (continuePaging bool). I also would like a straightforward way of dropping in aws cli style --query
, preferably in the Input object.
from aws-sdk-go-v2.
Thanks for the feedback. The idea of the return true
is a bit awkward and one reason we are looking at replacing the pagination pattern. If you don't mind please create a new feature request for the query
concept. We can discuss more how this concept could be incorporated.
from aws-sdk-go-v2.
Related Issues (20)
- Use `encoding.TextMarshaler` and `encoding.TextUnmarshaler` in DynamoDB `attributevalue` marshalers/unmarshalers, if available HOT 1
- Improve formatting of package doc for secretsmanager HOT 3
- iam.NewListRolesPaginator.NextPage suddenly doesn't return "Tags" HOT 5
- Missing json => dynamodbav v2 migration HOT 1
- DynamoDB:UpdateItem ReturnValuesOnConditionCheckFailure flag does not work HOT 5
- Get Filtered Repositories from ECR(short issue description) HOT 2
- S3: False Request and 'Object Not Found' Error When Bucket Name Matches Object Key Prefix and usePathStyle is False HOT 2
- S3: `DeleteObjects` Creates File Versions and Delete Markers Regardless of File Existence with `ObjectLockEnabledForBucket` Set to True HOT 4
- Include imitation of 10 message attributes field for sns.PublishInput in godoc HOT 2
- SSO Cache filename should be based on `sso_session` in addition to `sso_start_url` HOT 4
- PresignedPutObject ignores ChecksumAlgorithm HOT 2
- No paginator for DescribeLockedSnapshots? HOT 2
- [inspector2] GetConfiguration is missing the `ec2Configuration` object HOT 3
- Provide io.Reader wrapper around S3 SelectObjectContentEventStream
- Expand Codebuild to accept the new WebhookFilterType of `WORKFLOW_JOB_QUEUED` HOT 3
- How to set a field to NULL using the Redshift Data API? HOT 2
- Bad request when describe key pairs with empty filters slice HOT 13
- EC2Query empty list serialization behavior is incorrect HOT 1
- MIGRATION ISSUE: No programatic access to region descriptions used in pricing API HOT 2
- imagebuilder fails to serialize `types.LaunchTemplateConfiguration.SetDefaultVersion` when set to `false`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-sdk-go-v2.