kvstore

package module
v0.0.0-...-b33c24c Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

README

go-kvstore

kvstore interface and official interfaces

Go Reference Go Report Card codecov

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool2ef

func Bool2ef(ok bool, ng func() error) func() error

func Bool2error

func Bool2error(ok bool, ng func() error) error

func CoalesceError

func CoalesceError(e1 error, e2 error) error

func Compose

func Compose[T, U, V any](f func(T) U, g func(U) V) func(T) V

func ComposeEither

func ComposeEither[T, U, V, E any](f func(T) Either[U, E], g func(U) Either[V, E]) func(T) Either[V, E]

func Curry

func Curry[T, U, V any](f func(T, U) V) func(T) func(U) V

func Error1st

func Error1st(ef []func() error) error

func Identity

func Identity[T any](t T) T

func IterAll

func IterAll[T any](i Iter[T], f func(T) bool) bool

func IterReduce

func IterReduce[T, U any](i Iter[T], init U, reducer func(U, T) U) U

func IterReduceFilter

func IterReduceFilter[T, U any](i Iter[T], init U, filter func(T) bool, reducer func(U, T) U) U

func NonAtomicUpsertBuilder

func NonAtomicUpsertBuilder(sel Select) func(Delete) func(Insert) Upsert

func OptionEq

func OptionEq[T comparable](o Option[T], other T) bool

func OptionEqOpt

func OptionEqOpt[T comparable](o Option[T], other Option[T]) bool

Types

type Bucket

type Bucket func() string

type BucketItem

type BucketItem struct {
	// contains filtered or unexported fields
}

func BucketItemNew

func BucketItemNew(key Key, val Val) BucketItem

func (BucketItem) Key

func (b BucketItem) Key() Key

func (BucketItem) Val

func (b BucketItem) Val() Val

type BulkUpsert

type BulkUpsert func(ctx context.Context, bucket Bucket, items Iter[BucketItem]) error

BulkUpsert upserts items into single bucket.

type Create

type Create func(ctx context.Context, bucket Bucket) error

type Delete

type Delete func(ctx context.Context, key Key) error

type Either

type Either[T, E any] interface {
	IsOk() bool
	IsNg() bool
	TryForEach(f func(T) E) E
	Ok() Option[T]
	UnwrapOrElse(func(E) T) T
	Left() Option[E]
	Right() Option[T]
	FlatMap(func(T) Either[T, E]) Either[T, E]
	Map(func(T) T) Either[T, E]
}

func EitherFlatMap

func EitherFlatMap[T, U, E any](r Either[T, E], f func(T) Either[U, E]) Either[U, E]

func EitherLeft

func EitherLeft[T, E any](e E) Either[T, E]

func EitherMap

func EitherMap[T, U, E any](r Either[T, E], f func(T) U) Either[U, E]

func EitherNew

func EitherNew[T any](t T, e error) Either[T, error]

func EitherNg

func EitherNg[T any](e error) Either[T, error]

func EitherOk

func EitherOk[T any](t T) Either[T, error]

func EitherOkWhen

func EitherOkWhen[T, E any](e Either[T, E], okf func(E) (ok bool)) Either[Option[T], E]

func EitherRight

func EitherRight[T, E any](t T) Either[T, E]

func IterTryCollect

func IterTryCollect[T any](i Iter[Either[Option[T], error]]) Either[[]T, error]

type Insert

type Insert func(ctx context.Context, item BucketItem) error

type Iter

type Iter[T any] func() Option[T]

func IterEmpty

func IterEmpty[T any]() Iter[T]

func IterFromArray

func IterFromArray[T any](a []T) Iter[T]

func IterMap

func IterMap[T, U any](i Iter[T], f func(T) U) Iter[U]

func (Iter[T]) Count

func (i Iter[T]) Count() uint64

func (Iter[T]) Map

func (i Iter[T]) Map(f func(T) T) Iter[T]

func (Iter[T]) Reduce

func (i Iter[T]) Reduce(init T, reducer func(state T, item T) T) T

func (Iter[T]) ToArray

func (i Iter[T]) ToArray() []T

func (Iter[T]) TryForEach

func (i Iter[T]) TryForEach(f func(T) error) error

type IterFilter

type IterFilter[T any] func(i Iter[T], f func(T) bool) Iter[T]

func IterFilterDefaultNew

func IterFilterDefaultNew[T any]() IterFilter[T]

type Key

type Key struct {
	// contains filtered or unexported fields
}

func KeyNew

func KeyNew(bucket Bucket, id []byte) Key

func (Key) Bucket

func (k Key) Bucket() Bucket

func (Key) BucketString

func (k Key) BucketString() string

func (Key) Id

func (k Key) Id() []byte

type Option

type Option[T any] struct {
	// contains filtered or unexported fields
}

func MapGet

func MapGet[T comparable, U any](m map[T]U, t T) Option[U]

func OptionEmpty

func OptionEmpty[T any]() Option[T]

func OptionFlatMap

func OptionFlatMap[T, U any](o Option[T], f func(T) Option[U]) Option[U]

func OptionFromArray

func OptionFromArray[T any](a []T, ix int) Option[T]

func OptionFromBool

func OptionFromBool[T any](b bool, f func() T) Option[T]

func OptionMap

func OptionMap[T, U any](o Option[T], f func(T) U) Option[U]

func OptionNew

func OptionNew[T any](t T) Option[T]

func (Option[T]) Empty

func (o Option[T]) Empty() bool

func (Option[T]) Filter

func (o Option[T]) Filter(flt func(T) bool) Option[T]

func (Option[T]) ForEach

func (o Option[T]) ForEach(f func(T))

func (Option[T]) HasValue

func (o Option[T]) HasValue() bool

func (Option[T]) Map

func (o Option[T]) Map(f func(T) T) Option[T]

func (Option[T]) Must

func (o Option[T]) Must() T

func (Option[T]) OkOrElse

func (o Option[T]) OkOrElse(ng func() error) Either[T, error]

func (Option[T]) UnwrapOr

func (o Option[T]) UnwrapOr(t T) T

func (Option[T]) UnwrapOrElse

func (o Option[T]) UnwrapOrElse(f func() T) T

func (Option[T]) Value

func (o Option[T]) Value() T

type Select

type Select func(ctx context.Context, key Key) Either[Option[Val], error]

type Upsert

type Upsert func(ctx context.Context, item BucketItem) error

type Val

type Val struct {
	// contains filtered or unexported fields
}

func ValNew

func ValNew(val []byte) Val

func (Val) Raw

func (v Val) Raw() []byte

Directories

Path Synopsis
pkg
fs

Jump to

Keyboard shortcuts

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