metadata

package
v0.0.0-...-4be01c1 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const UuidMetaKey = "uuid"

Variables

View Source
var (
	ErrNoSuchKey = errors.New("No Such Key")
)

Functions

func Retrieve

func Retrieve(ctx context.Context, tx *sql.Tx, key Key, value Value) error

func Store

func Store(ctx context.Context, tx *sql.Tx, items []Item) error

Types

type AsyncWriteResult

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

func (*AsyncWriteResult) Done

func (r *AsyncWriteResult) Done() <-chan error

func (*AsyncWriteResult) Wait

func (r *AsyncWriteResult) Wait() error

Wait forces the caller to wait until the underlying store call ends, either successfully or not

type AsyncWriter

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

AsyncWriter allows callers to schedule values to be stored, but in a non-blocking way TODO: at the moment AsyncWriter serializes and doesn't bufferize the store requests, making them behave as if they were blocking for all the requesters. It can be a problem in case of "high pressure" with many simultaneous requests, which can be a bit slow. In such scenarios, one possibility to be verified is to accumulate many requests in a single transaction as SQLite can be slow on storing multiple independent pieces of data, but is quite efficient when grouping them into a single transaction.

func (*AsyncWriter) Store

func (w *AsyncWriter) Store(items []Item) *AsyncWriteResult

func (*AsyncWriter) StoreJson

func (w *AsyncWriter) StoreJson(key, value interface{}) *AsyncWriteResult

func (*AsyncWriter) StoreJsonSync

func (w *AsyncWriter) StoreJsonSync(ctx context.Context, key, value interface{}) error

type DefaultValues

type DefaultValues map[string]interface{}

type Handler

type Handler struct {
	Reader Reader
	Writer *Writer
}

func NewDefaultedHandler

func NewDefaultedHandler(conn *dbconn.PooledPair, defaultValues DefaultValues) (*Handler, error)

func NewHandler

func NewHandler(conn *dbconn.PooledPair) (*Handler, error)

type Item

type Item struct {
	Key   interface{}
	Value interface{}
}

type Key

type Key interface{}

type Reader

type Reader interface {
	Retrieve(context.Context, Key) (Value, error)
	RetrieveJson(context.Context, Key, Value) error
}

func NewReader

func NewReader(pool *dbconn.RoPool) Reader

type SerialWriteRunner

type SerialWriteRunner struct {
	runner.CancellableRunner
	// contains filtered or unexported fields
}

SerialWriteRunner aims to serialize all requests to write in a single goroutine, which effectively owns writing access to the connection

func NewSerialWriteRunner

func NewSerialWriteRunner(h *Handler) *SerialWriteRunner

func (*SerialWriteRunner) Writer

func (runner *SerialWriteRunner) Writer() *AsyncWriter

type Value

type Value = interface{}

type Writer

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

func (*Writer) Store

func (writer *Writer) Store(ctx context.Context, items []Item) error

func (*Writer) StoreJson

func (writer *Writer) StoreJson(ctx context.Context, key Key, value Value) (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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