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:
carla 2020-11-23 09:34:18 +02:00
parent 466af241c9
commit befb4b704e
No known key found for this signature in database
GPG key ID: 4CA7FE54A6213C91

View file

@ -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 {