From 5a170c89508c81056fa0f1da996fb289e054da90 Mon Sep 17 00:00:00 2001 From: Josh Mills Date: Fri, 7 May 2021 11:34:57 +0100 Subject: [PATCH] Add pagination to ListNodes call --- main.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index dd1b09c..64da58d 100644 --- a/main.go +++ b/main.go @@ -90,16 +90,20 @@ func getClusters(svc kafkaClient) (*kafka.ListClustersOutput, error) { // getBrokers returns a slice of broker hosts without ports func getBrokers(svc kafkaClient, arn string) ([]string, error) { input := kafka.ListNodesInput{ClusterArn: &arn} - r, err := svc.ListNodes(context.Background(), &input) + var brokers []string - if err != nil { - return nil, err - } + p := kafka.NewListNodesPaginator(svc, &input) + for p.HasMorePages() { + page, err := p.NextPage(context.Background()) + if err != nil { + return nil, err + } - var brokers []string - for _, b := range r.NodeInfoList { - brokers = append(brokers, b.BrokerNodeInfo.Endpoints...) + for _, b := range page.NodeInfoList { + brokers = append(brokers, b.BrokerNodeInfo.Endpoints...) + } } + return brokers, nil }