state

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InMemory = iota
	BoltDB
)

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyValueStore

type KeyValueStore[K, V any] interface {
	ReadOnlyKeyValueStore[K, V]

	Put(key K, value V)
	Delete(key K)
}

func NewKeyValueStore

func NewKeyValueStore[K, V any](opts Options[K, V]) KeyValueStore[K, V]

type Option

type Option[K, V any] func(*options[K, V])

func WithBoltDB

func WithBoltDB[K, V any](name string) Option[K, V]

WithBoltDB use boltDB persistent store.

func WithDirPath

func WithDirPath[K, V any](dirPath string) Option[K, V]

func WithInMemory

func WithInMemory[K, V any]() Option[K, V]

WithInMemory use in-memory store. default store type.

func WithKeySerde

func WithKeySerde[K, V any](keySerde Serde[K]) Option[K, V]

WithKeySerde set custom key serializer/deserializer. default is json serde.

func WithValueSerde

func WithValueSerde[K, V any](valueSerde Serde[V]) Option[K, V]

WithValueSerde set custom value serializer/deserializer. default is json serde.

type Options

type Options[K, V any] interface {
	KeySerde() Serde[K]
	ValueSerde() Serde[V]
	StoreType() StoreType
	Name() string
	DirPath() string
}

func NewOptions

func NewOptions[K, V any](opts ...Option[K, V]) Options[K, V]

type ReadOnlyKeyValueStore

type ReadOnlyKeyValueStore[K, V any] interface {
	Get(key K) (V, error)
}

type Serde

type Serde[T any] interface {
	Serialize(T) []byte
	Deserialize([]byte) T
}

type StoreType

type StoreType int

Jump to

Keyboard shortcuts

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