mirror of
https://github.com/lightninglabs/faraday.git
synced 2026-08-13 12:33:35 +02:00
paginater: export paginated query type
We use the pagination package in other projects, exporting the query type makes this usage cleaner.
This commit is contained in:
parent
466af241c9
commit
befb4b704e
1 changed files with 3 additions and 3 deletions
|
|
@ -2,17 +2,17 @@ package paginater
|
|||
|
||||
import "context"
|
||||
|
||||
// paginatedQuery is a function which makes a call to a paginated api and adds
|
||||
// PaginatedQuery is a function which makes a call to a paginated api and adds
|
||||
// returns the index offset of the last entry and the number of events that were
|
||||
// returned.
|
||||
type paginatedQuery func(offset, maxEvents uint64) (uint64, uint64, error)
|
||||
type PaginatedQuery func(offset, maxEvents uint64) (uint64, uint64, error)
|
||||
|
||||
// QueryPaginated gets calls the paginated query function until it it has
|
||||
// retrieved all the items from the query endpoint, or the calling context is
|
||||
// cancelled. Note that the query function is responsible for collecting the
|
||||
// items returned by the API (if required) so that the pagination logic can
|
||||
// remain generic.
|
||||
func QueryPaginated(ctx context.Context, query paginatedQuery, offset,
|
||||
func QueryPaginated(ctx context.Context, query PaginatedQuery, offset,
|
||||
maxEvents uint64) error {
|
||||
|
||||
for {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue