-
Notifications
You must be signed in to change notification settings - Fork 21
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
Fix Barbeque::SnsSubscriptionsController#fetch_sns_topic_arns #70
Conversation
efac99d
to
141faf3
Compare
next_token = nil | ||
|
||
loop do | ||
list_topics = Barbeque::SNSSubscriptionService.sns_client.list_topics(next_token: next_token) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI https://github.com/aws/aws-sdk-ruby#paging-responses
To make it easy to get the next page of results, every AWS response object is enumerable:
141faf3
to
780fcc0
Compare
cc @cookpad/dev-infra |
end | ||
|
||
def each_sns_topic_arns | ||
unless block_given? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any reason you want to support passing block?
780fcc0
to
83d93e1
Compare
@@ -44,6 +44,6 @@ def destroy | |||
private | |||
|
|||
def fetch_sns_topic_arns | |||
Barbeque::SNSSubscriptionService.sns_client.list_topics.topics.map(&:topic_arn) | |||
Barbeque::SNSSubscriptionService.sns_client.list_topics.flat_map{ |resp| resp.topics.map(&:topic_arn) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is enough, isn't it.
Barbeque::SNSSubscriptionService.sns_client.list_topics.flat_map(&:topics).map(&:topic_arn)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. b28f812
83d93e1
to
b28f812
Compare
LGTM |
Aws::SNS::Client#list_topics returns up to 100 topics. This
change allows to fetch all topics when there are more than 100
topics.