cursor

package
v0.0.0-...-7bf56e6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package cursor contains logic for marshalling pagination cursors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode[T any](ctx context.Context, kind cursorpb.RequestKind, cursor string) (*T, error)

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

func Encode(ctx context.Context, kind cursorpb.RequestKind, payload proto.Message) (string, error)

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.

func IsValidCursor

func IsValidCursor(ctx context.Context, cursor string) (bool, error)

IsValidCursor returns true if `cursor` looks like a Swarming cursor string.

Returns an error if the check can't be performed (e.g. there's no decryption key in the context).

Types

This section is empty.

Directories

Path Synopsis
Package cursorpb contains proto messages with pagination cursors.
Package cursorpb contains proto messages with pagination cursors.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL