noptions

package
v0.0.30 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScanLimitNone    = 0
	ScanLimitDefault = 1

	ScanTimeoutNone    = 0
	ScanTimeoutDefault = 10 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyValue

type KeyValue struct {
	Index string
	Value any
}

type Option

type Option func(o *Options) error

Option is a closure that updates Options.

func WithAnyVersion

func WithAnyVersion() Option

Use WithAnyVersion to update documents without caring what their version is.

func WithDestination

func WithDestination(dst any) Option

WithDestination provides an interface for receiving data when getting a nosql.

func WithDestinationList

func WithDestinationList(dst []any) Option

WithDestinationList provides a interface list for receiving data when getting a nosql.

func WithMultipleSource

func WithMultipleSource(src map[string]any) Option

func WithSource

func WithSource(src any) Option

WithSource provides an interface to source data when updating a nosql.

func WithTTL

func WithTTL(ttl time.Duration) Option

Use WithTTL to set the expiration time of a nosql during an operation.

func WithVersion

func WithVersion(v Version) Option

WithVersion provides a Version value option. This is optionally used when updating documents to ensure the user has the correct version before updating.

type Options

type Options struct {
	Version         Version
	AnyVersion      bool
	TTL             time.Duration
	Source          any
	Sources         map[string]any
	Destination     any
	DestinationList []any
}

Options contains all the various options that the provided WithXyz functions construct.

func NewOptions

func NewOptions(opts ...Option) (options Options, err error)

NewOptions constructs an Options struct from the provided Option closures and returns it.

type ScanOption

type ScanOption func(o *ScanOptions) error

func MatchAny

func MatchAny() ScanOption

MatchAny does not perform any filter on the query

func MatchKeyLike

func MatchKeyLike(idx string, val string) ScanOption

MatchKeyLike packs up a keys/value search pair when scanning for a nosql - for a sql style "like" match.

func MatchKeyValue

func MatchKeyValue(idx string, val string) ScanOption

MatchKeyValue packs up a keys/value search pair when scanning for a nosql.

func MatchNumber

func MatchNumber(idx string, op ScanQueryOp, val float64) ScanOption

func MatchRegex

func MatchRegex(regex string) ScanOption

func WithLimit

func WithLimit(limit int) ScanOption

func WithNoLimit

func WithNoLimit() ScanOption

func WithNoTimeout

func WithNoTimeout() ScanOption

func WithOffset

func WithOffset(offset int) ScanOption

For paginating query results, use in combination with an appropriate limit. NB: Offsets are not reliable in mock implementation because mock ordering is nondeterministic

func WithTimeout

func WithTimeout(timeout time.Duration) ScanOption

Use WithTimeout to set the expiration time of a supported operation.

type ScanOptions

type ScanOptions struct {
	Query []ScanQuery

	Offset  int
	Limit   int
	Timeout time.Duration
}

func NewScanOptions

func NewScanOptions(opts ...ScanOption) (options ScanOptions, err error)

NB: consider making a way to request that defaults to unlimited?

type ScanQuery

type ScanQuery struct {
	ScanType      ScanQueryType
	ScanOperation ScanQueryOp

	KeyValue KeyValue
	Regex    string
}

type ScanQueryOp

type ScanQueryOp int
const (
	// lower level, what operator is being used in the query?
	ScanOpEquals ScanQueryOp = iota
	ScanOpLessThan
	ScanOpGreaterThan
)

type ScanQueryType

type ScanQueryType int
const (
	// high level, what kind of a scan is this query?
	ScanTypeUnset ScanQueryType = iota
	ScanTypeKeyValue
	ScanTypeKeyLike
	ScanTypeNOOP
	ScanTypeRegex
	ScanTypeNum
)

type Version

type Version = int64
const (
	NoVersion Version = 0
)

Jump to

Keyboard shortcuts

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