Documentation ¶
Overview ¶
Package paginator contains helpers to convert between AIP-158 page_size/page_token/next_page_token fields and simple offset/limit values.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InvalidTokenError ¶
InvalidTokenError annotates the error with InvalidArgument appstatus.
Types ¶
type Paginator ¶
type Paginator struct { // The default page size to use if the user does not specify a page size. DefaultPageSize int32 // The max page size to allow the user to request. MaxPageSize int32 }
Paginator converts between AIP-158 page_size/page_token/next_page_token fields and a simple offset/limit. Note that offset/limit is susceptible to page tearing during pagination if new items are added to the list during iteration. This paginator makes no attempt to solve this at present, but can be extended to take additional state in the future to address this if necessary.
func (Paginator) Limit ¶
Limit gets the limit given the page_size field and the configuration stored in the paginator.
func (Paginator) NextPageToken ¶
NextPageToken gets the value to use for the next_page_token field in a response to remember the given offset for the next request. The request message is required to ensure that the user does not change request parameters in the next request (hence making the offset invalid).