luci: go.chromium.org/luci/common/proto/paged Index | Files

package paged

import "go.chromium.org/luci/common/proto/paged"

Package paged implements a helper for making paginated Datastore queries.

Index

Package Files

queries.go

func Query Uses

func Query(c context.Context, lim int32, tok string, rsp Response, q *datastore.Query, cb interface{}) error

Query executes a query to fetch the given page of results, invoking a callback function for each key or entity returned by the query. If the page isn't the last of the query, the given response will have its next page token set appropriately.

A non-positive limit means to fetch all results starting at the given page token in a single page. An empty page token means to start at the first page.

The callback must be a function of one argument, the type of which is either *datastore.Key (implies keys-only query) or a pointer to a struct to decode the returned entity into. The callback should return an error, which if not nil halts the query, and if the error is not datastore.Stop, causes this function to return an error as well. See datastore.Run for more information. No maximum page size is imposed, use datastore.Stop to enforce one.

type Response Uses

type Response interface {
    proto.Message
    // GetNextPageToken returns a token to use to fetch the next page of results.
    GetNextPageToken() string
}

Response is an interface implemented by ListResponses which support page tokens.

Package paged imports 7 packages (graph) and is imported by 2 packages. Updated 2020-09-22. Refresh now. Tools for package owners.