ALIDNS: Update pagination functions to accept customizable page sizes

This commit is contained in:
artin 2025-12-04 01:56:31 +08:00
parent ed8b7a773d
commit 90650e4d8b
2 changed files with 3 additions and 4 deletions

View file

@ -139,7 +139,7 @@ func (a *aliDnsDsp) describeDomainRecordsAll(domain string) ([]*alidns.Record, e
return resp.DomainRecords.Record, total, nil
}
vals, err := paginateAll(fetch)
vals, err := paginateAll(fetch, 500)
if err != nil {
return nil, err
}
@ -171,5 +171,5 @@ func (a *aliDnsDsp) describeDomainsAll() ([]string, error) {
return domains, total, nil
}
return paginateAll(fetch)
return paginateAll(fetch, 100)
}

View file

@ -5,8 +5,7 @@ package alidns
// returns the items for that page, the total number of items available,
// and an error if any. paginateAll will iterate pages until it has
// collected all items or an error occurs.
func paginateAll[T any](fetch func(pageNumber, pageSize int) ([]T, int, error)) ([]T, error) {
const maxPageSize = 500 // Alibaba API max for many endpoints
func paginateAll[T any](fetch func(pageNumber, pageSize int) ([]T, int, error), maxPageSize int) ([]T, error) {
page := 1
pageSize := maxPageSize
var out []T