dop82210 2019-01-09 21:24
浏览 119

DynamoDB使用AWS GoLang SDK列出所有备份

Based on the example given in the link blow on API Operation Pagination without Callbacks https://aws.amazon.com/blogs/developer/context-pattern-added-to-the-aws-sdk-for-go/ I am trying to list all the Backups in dynamodb. But it seems like pagination is not working and it is just retrieving first page and not going to next page

package main

    import (
        "context"
        "fmt"

        "github.com/aws/aws-sdk-go/aws"
        "github.com/aws/aws-sdk-go/aws/request"

        "github.com/aws/aws-sdk-go/aws/session"
        "github.com/aws/aws-sdk-go/service/dynamodb"
    )

    func main() {

        sess, sessErr := session.NewSession()

        if sessErr != nil {
            fmt.Println(sessErr)
            fmt.Println("Cound not initilize session..returning..")
            return
        }
        // Create DynamoDB client
        dynamodbSvc := dynamodb.New(sess)

        params := dynamodb.ListBackupsInput{}
        ctx := context.Background()

        p := request.Pagination{
            NewRequest: func() (*request.Request, error) {
                req, _ := dynamodbSvc.ListBackupsRequest(&params)
                req.SetContext(ctx)
                return req, nil
            },
        }

        for p.Next() {
            page := p.Page().(*dynamodb.ListBackupsOutput)
            fmt.Println("Received", len(page.BackupSummaries), "objects in page")
            for _, obj := range page.BackupSummaries {
                fmt.Println(aws.StringValue(obj.BackupName))
            }
        }
        //return p.Err()
    } //end of main
  • 写回答

1条回答 默认 最新

  • 普通网友 2019-01-10 06:24
    关注

    It could be that you're smashing into the API a bit with your usage

    You can call ListBackups a maximum of 5 times per second.

    What is the value of p.HasNextPage() in your p.Next() loop?

    评论

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 虚心请教几个问题,小生先有礼了
  • ¥30 截图中的mathematics程序转换成matlab