我使用AWS雲鋒AWS紅寶石SDK V2,的Cloudfront list_distributions,遍歷結果
我想列出所有我的分佈,使用list_distributions
方法
即得到的迴應是PageableResponse,
當我嘗試遍歷看來,我只能得到一個頁面的結果,
page = cloudfront.list_distributions
page.each do |page|
# only one page ....
end
但在「distribution_list」散列中,「next_marker」屬性包含請求的值,並且「is_truncated」屬性設置爲true,如果我將再次使用next_marker調用list_distributions
方法,我會得到下一組結果...
這是爲什麼?
似乎很奇怪,我不得不通過迭代方式來響應?
感謝
是的,你就像是在官方SDK中描述確切的行爲:http://docs.aws.amazon.com/AmazonCloudFront/latest/APIReference/ListDistributions.html。我認爲這是用於減少後端服務器負載的常見模式,因爲在許多情況下只需要部分列表。 – 2014-12-05 21:44:09
同意,但奇怪的是,在ruby sdk中,對列表分佈請求的響應是一個'PageableResponse',它假設爲你做了迭代請求(如果我已經正確理解了它)? – 2014-12-06 09:18:28