storage

package
v0.0.0-...-984c388 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodePageToken

func DecodePageToken(token PageToken) string

DecodePageToken retrieves raw token from a PageToken.

Types

type Criteria

type Criteria struct {
	Limit     int       `json:"limit"`
	PageToken PageToken `json:"page_token"`
}

Criteria set of parameters used to indicate conditions (e.g. filters, offset, cursor, limit) to a Reader -or Repository- when fetching data.

type PageToken

type PageToken []byte

PageToken custom-type representing the page to fetch by a storage system.

This type obfuscates raw tokens through a codec to be later served to system users securely.

Depending on the underlying storage engine, the token might represent an offset, cursor (identifier of an item) or similar.

func NewPageToken

func NewPageToken(src string) PageToken

NewPageToken allocates a new instance of PageToken based on src.

func (PageToken) String

func (p PageToken) String() string

type Reader

type Reader[T any] interface {
	Get(ctx context.Context, id string) (*T, error)
	Find(ctx context.Context, cr Criteria) (items []T, nextPage PageToken, err error)
}

Reader reads data from an underlying storage engine.

type Repository

type Repository[T any] interface {
	Writer[T]
	Reader[T]
}

Repository writes and reads data using an underlying storage engine.

type Writer

type Writer[T any] interface {
	Save(ctx context.Context, v T) error
	Remove(ctx context.Context, id string) error
}

Writer writes data into an underlying storage engine.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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