Documentation ¶
Index ¶
- Constants
- Variables
- func Retrieve(ctx context.Context, tx *sql.Tx, key Key, value Value) error
- func Store(ctx context.Context, tx *sql.Tx, items []Item) error
- type AsyncWriteResult
- type AsyncWriter
- type DefaultValues
- type Handler
- type Item
- type Key
- type Reader
- type SerialWriteRunner
- type Value
- type Writer
Constants ¶
const UuidMetaKey = "uuid"
Variables ¶
var (
ErrNoSuchKey = errors.New("No Such Key")
)
Functions ¶
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 ¶
func NewDefaultedHandler ¶
func NewDefaultedHandler(conn *dbconn.PooledPair, defaultValues DefaultValues) (*Handler, error)
func NewHandler ¶
func NewHandler(conn *dbconn.PooledPair) (*Handler, error)
type 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