data

package
v0.1.1-0...-03eb687 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// PageTokenDefaultEncryptionKey the default secret key for PageToken encryption.
	PageTokenDefaultEncryptionKey = "Some_Page_Token_Key_1927_!@#$*~<" // 32 bytes, therefore, AES 256-bit
)

Variables

View Source
var (
	// ErrInvalidPageToken the token cannot be built.
	ErrInvalidPageToken = errors.New("invalid page token")
)

Functions

This section is empty.

Types

type ComparisonOperator

type ComparisonOperator uint16

ComparisonOperator an operator for comparisons.

const (
	OperatorEquals ComparisonOperator = iota + 1
	OperatorGreaterThan
	OperatorGreaterThanEquals
	OperatorLessThan
	OperatorLessThanEquals
	OperatorBetween
	OperatorNotBetween
	OperatorNotEquals
	OperatorIn
	OperatorNotIn
	OperatorLike
	OperatorNotLike
	OperatorExists
	OperatorNotExists
	OperatorIsNull
	OperatorIsNotNull
)

type LogicalOperator

type LogicalOperator uint8

LogicalOperator an operator for logical operations (concatenations, e.g. AND, OR).

const (
	LogicalOperatorAnd LogicalOperator = iota + 1
	LogicalOperatorOr
)

type OrderType

type OrderType uint8

OrderType the ordering type for a persistence operation (DESC, ASC).

const (
	// OrderTypeAscending Ascending ordering type.
	OrderTypeAscending OrderType = iota + 1
	// OrderTypeDescending Descending ordering type.
	OrderTypeDescending
)

type Page

type Page[T any] struct {
	PreviousPageToken PageToken `json:"previous_page_token"`
	NextPageToken     PageToken `json:"next_page_token"`
	TotalItems        int       `json:"total_items"`
	Items             []T       `json:"items"`
}

Page a chunk of items from a dataset with metadata used to fetch more data.

type PageToken

type PageToken []byte

PageToken Tokens are first encrypted so anybody is able to see internal system implementation details. Then, the token is encoded in hex format, so it can be transferred through network protocols, and thus, systems.

The token is able to use different pagination mechanism.

The nomenclature proposal would be this: QUERY_TYPE#NEXT_QUERY Nomenclature examples:

  • OFFSET#100
  • KEY_SET#name>'Foo'
  • CURSOR#abc-foo

func NewPageToken

func NewPageToken(encryptor encryption.Encryptor, queryType PaginationType, value string) (PageToken, error)

NewPageToken allocates a new PageToken instance.

func (PageToken) MarshalText

func (p PageToken) MarshalText() (text []byte, err error)

MarshalText encodes the receiver into UTF-8-encoded text and returns the result.

func (PageToken) Read

func (p PageToken) Read(encryptor encryption.Encryptor) (string, string, error)

Read decomposes encrypted token to a set of PaginationType and its value.

func (PageToken) String

func (p PageToken) String() string

String retrieves encoded token.

type PaginationType

type PaginationType string

PaginationType the type of pagination for a

const (
	PaginationTypeOffset PaginationType = "OFFSET"
	PaginationTypeKeySet PaginationType = "KEY_SET"
	PaginationTypeCursor PaginationType = "CURSOR"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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