Documentation ¶
Index ¶
- Constants
- Variables
- type Cursor
- func (*Cursor) Descriptor() ([]byte, []int)deprecated
- func (x *Cursor) GetEndIndex() string
- func (x *Cursor) GetExpires() *timestamppb.Timestamp
- func (x *Cursor) GetPageSize() int32
- func (x *Cursor) GetStartIndex() string
- func (c *Cursor) HasExpired() (bool, error)
- func (c *Cursor) IsZero() bool
- func (c *Cursor) NextPageToken() (token string, err error)
- func (*Cursor) ProtoMessage()
- func (x *Cursor) ProtoReflect() protoreflect.Message
- func (x *Cursor) Reset()
- func (x *Cursor) String() string
Constants ¶
View Source
const ( DefaultPageSize int32 = 100 MaximumPageSize int32 = 5000 CursorDuration = 24 * time.Hour )
Variables ¶
View Source
var ( ErrMissingExpiration = errors.New("cursor does not have an expires timestamp") ErrCursorExpired = errors.New("cursor has expired and is no longer useable") ErrUnparsableToken = errors.New("could not parse the next page token") ErrTokenQueryMismatch = errors.New("cannot change query parameters during pagination") )
View Source
var File_pagination_pagination_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type Cursor ¶
type Cursor struct { // The start index is the ID at the beginning of the page and is used for previous // page queries, whereas the end index is the last ID on the page and is used to // compute the next page for the query. Ensure that IDs are montonically increasing // such as autoincrement IDs or ULIDs (do not use UUIDs). StartIndex string `protobuf:"bytes,1,opt,name=start_index,json=startIndex,proto3" json:"start_index,omitempty"` EndIndex string `protobuf:"bytes,2,opt,name=end_index,json=endIndex,proto3" json:"end_index,omitempty"` // The maximum number of results per page. PageSize int32 `protobuf:"varint,3,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` // The timestamp when the cursor is no longer valid. Expires *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=expires,proto3" json:"expires,omitempty"` // contains filtered or unexported fields }
Key-Index Cursors are useful for high-performance pagination that do not require Postgres Cursors managed by an open transaction. The cursor specifies the current page of results so that the next/previous pages can be calculated from the query. Cursors also specify an expiration so that a page token cannot be replayed forever. Note that Key-Index cursors require the original query to correctly order the index, this cursor type assumes that no ordering or filtering has been applied.
The cursor object is serialized and base64 encoded to be sent as a next_page_token in a paginated request. Protocol buffers ensures the most compact representation.
func (*Cursor) Descriptor
deprecated
func (*Cursor) GetEndIndex ¶
func (*Cursor) GetExpires ¶
func (x *Cursor) GetExpires() *timestamppb.Timestamp
func (*Cursor) GetPageSize ¶
func (*Cursor) GetStartIndex ¶
func (*Cursor) HasExpired ¶
func (*Cursor) NextPageToken ¶
func (*Cursor) ProtoMessage ¶
func (*Cursor) ProtoMessage()
func (*Cursor) ProtoReflect ¶
func (x *Cursor) ProtoReflect() protoreflect.Message
Click to show internal directories.
Click to hide internal directories.