kvif

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

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

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

README

go-kvif

Key/Value interface with official implementations

Go Reference Go Report Card codecov

Overview

Archive Type
Zip
  • bucket: path/to/sample1/a.zip
    • path/inside/archive/file1.dat
    • path/inside/archive/deep/file2.gz
    • ...
  • bucket: path/to/sample2/date/2022-09-24/device/cafef00d-dead-beaf-face-864299792458/time/06-04.zip
    • 06-04-00.txt
    • 06-04-01.txt
    • 06-04-02.txt
    • ...
    • 06-04-59.txt
    • 06-04-60.txt
Sql Type
PostgreSQL
  • bucket: postgres.public.sample1
    • key1
    • key2
    • ...
  • bucket: postgres.public.date_2022_09_24_device_cafef00ddeadbeafface864299792458
    • 06_04_00
    • 06_04_01
    • 06_04_02
    • ...
    • 06_04_60
    • ...
    • 23_59_60
  • prefix: postgres.public.date_2022_09_23_device_cafef00ddeadbeafface864299792458
    • bucket: 06_04.zip
      • 06-04-00.txt
      • 06-04-01.gz
      • 06-04-02.gz
      • ...
      • 06-04-60.gz
    • bucket: 06_05
    • bucket: 06_06
    • ...

Documentation

Index

Constants

View Source
const OptEmpty = false
View Source
const OptHasValue = true

Variables

View Source
var ErrNotFound error = errors.New("key does not exist")

Functions

func And

func And(a, b bool) bool

func Compose

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

func ComposeErr

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

func Curry

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

func CurryCtx

func CurryCtx[T, U any](f func(context.Context, T) (U, error)) func(context.Context) func(T) (U, error)

func Error1st

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

func ErrorFlatMap

func ErrorFlatMap[T, U any](t T, te error, f func(T) (U, error)) (u U, e error)

func ErrorFromBool

func ErrorFromBool[T any](ok bool, okf func() (T, error), ngf func() error) (t T, err error)

func ErrorFuncCreate

func ErrorFuncCreate[T, U any](f func(T) U) func(T) (U, error)

func ErrorMap

func ErrorMap[T, U any](t T, te error, f func(T) U) (u U, e error)

func ErrorOrElse

func ErrorOrElse(e error, ef func() error) error

func ErrorTryForEach

func ErrorTryForEach[T any](t T, e error, f func(T) error) error

func Identity

func Identity[T any](t T) T

func IterCompose

func IterCompose[T, U any](f func(T) U) func(Iter[T]) Iter[U]

func IterComposeErr

func IterComposeErr[T, U any](f func(T) (U, error)) func(Iter[T]) (Iter[U], error)

func IterReduce

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

func IterReduceErr

func IterReduceErr[T, U any](i Iter[T], u1st U, f func(st U, t T) (U, error)) (u U, e error)

func Opt2Err

func Opt2Err[T any](o T, hasValue bool, ng func() error) (t T, e error)

func OptMap

func OptMap[T, U any](o T, hasValue bool, f func(T) U) (u U, nonEmpty bool)

Types

type Getter

type Getter interface {
	Get(ctx context.Context, key Key) (Val, error)
}

Getter gets Val by Key. Error for non-existent key must be ErrNotFound.

type Iter

type Iter[T any] func() (o T, hasValue bool)

func IterFromArr

func IterFromArr[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]) All

func (i Iter[T]) All(f func(T) bool) bool

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

type Key

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

func KeyNew

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

func (Key) Bucket

func (k Key) Bucket() string

func (Key) Raw

func (k Key) Raw() []byte

type Kv

type Kv interface {
	Getter
	Lister
	io.Closer
}

type Lister

type Lister interface {
	Lst(ctx context.Context, bucket string) (keys Iter[Key], err error)
}

Lister gets keys by bucket.

type Reader2Bytes

type Reader2Bytes func(r io.Reader) ([]byte, error)
var UnlimitedRead2Bytes Reader2Bytes = io.ReadAll

type Val

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

func ValNew

func ValNew(raw []byte) Val

func (Val) Raw

func (v Val) Raw() []byte

Directories

Path Synopsis
pkg
fs
sql

Jump to

Keyboard shortcuts

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