Documentation ¶
Overview ¶
Package cursor contains logic for marshalling pagination cursors.
Index ¶
- func Decode[T any](ctx context.Context, kind cursorpb.RequestKind, cursor string) (*T, error)
- func DecodeOpaqueCursor(ctx context.Context, kind cursorpb.RequestKind, cursor string) (datastore.Cursor, error)
- func Encode(ctx context.Context, kind cursorpb.RequestKind, payload proto.Message) (string, error)
- func EncodeOpaqueCursor(ctx context.Context, kind cursorpb.RequestKind, cursor datastore.Cursor) (string, error)
- func IsValidCursor(ctx context.Context, cursor string) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
Decode base64-decodes, decrypts and deserializes a cursor.
`T` is expected to have a type matching `kind` (see RequestKind enum in cursor.proto), e.g. if `kind` is LIST_BOTS, `T` must be BotsCursor. Panics on violations.
Returns gRPC errors with an appropriate code. Such errors can be returned to the user as are. Extra details are logged.
func DecodeOpaqueCursor ¶
func DecodeOpaqueCursor(ctx context.Context, kind cursorpb.RequestKind, cursor string) (datastore.Cursor, error)
DecodeOpaqueCursor decodes an opaque datastore cursor.
Returns gRPC errors with an appropriate code. Such errors can be returned to the user as are. Extra details are logged.
func Encode ¶
Encode serializes, encrypts and base64-encode the cursor.
`payload` is expected to have a type matching `kind` (see RequestKind enum in cursor.proto), e.g. if `kind` is LIST_BOTS, `payload` must be *BotsCursor. Panics on violations.
Returns gRPC errors. All errors have INTERNAL code (since there's no other way for this function to fail) and can be returned to the user as are. Extra details are logged.
func EncodeOpaqueCursor ¶
func EncodeOpaqueCursor(ctx context.Context, kind cursorpb.RequestKind, cursor datastore.Cursor) (string, error)
EncodeOpaqueCursor encodes an opaque datastore cursor.
Returns gRPC errors. All errors have INTERNAL code (since there's no other way for this function to fail) and can be returned to the user as are. Extra details are logged.
Types ¶
This section is empty.