mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-12-09 13:46:07 +08:00
ALIDNS: Update pagination functions to accept customizable page sizes
This commit is contained in:
parent
ed8b7a773d
commit
90650e4d8b
2 changed files with 3 additions and 4 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue