package indexes

import "go.cryptoscope.co/margaret/indexes"

Index

Functions

func NewObservable

func NewObservable(v interface{}, f func()) luigi.Observable

NewObservable returns a regular observable that calls f when the last registration is cancelled. This is used to garbage-collect observables from the maps in the indexes.

Types

type Addr

type Addr string

Addr is an address (or key) in the index. TODO maybe not use a string but a Stringer or

func (Addr) String

func (a Addr) String() string

type Index

type Index interface {
	// Get returns the an observable of the value stored at the address.
	// Getting an unset value retuns a valid Observable with a value
	// of type Unset and a nil error.
	Get(context.Context, Addr) (luigi.Observable, error)
}

Index provides an index table keyed by Addr. Often also implements Setter.

type SeqSetterIndex

type SeqSetterIndex interface {
	SetterIndex

	SetSeq(int64) error
	GetSeq() (int64, error)

	io.Closer
}

type Setter

type Setter interface {
	// Set sets a value in the index
	Set(context.Context, Addr, interface{}) error

	// Delete deletes a value from the index
	Delete(context.Context, Addr) error
}

type SetterIndex

type SetterIndex interface {
	Index
	Setter

	Flush() error
}

SetterIndex is an index that can be updated using calls to Set and Delete.

type SinkIndex

type SinkIndex interface {
	luigi.Sink

	QuerySpec() margaret.QuerySpec
}

SinkIndex is an index that is updated by processing a stream.

func NewSinkIndex

func NewSinkIndex(f StreamProcFunc, idx SeqSetterIndex) SinkIndex

type StreamProcFunc

type StreamProcFunc func(context.Context, int64, interface{}, SetterIndex) error

type UnsetValue

type UnsetValue struct {
	Addr Addr
}

UnsetValue is the value of observable returned by idx.Get() when the requested address has not been set yet.

Source Files

index.go obv.go sinkindex.go

Directories

PathSynopsis
indexes/badger
indexes/badger/test
indexes/mapidx
indexes/mapidx/test
indexes/mkv
indexes/mkv/test
indexes/test
indexes/test/all
Version
v0.4.3 (latest)
Published
Feb 17, 2022
Platform
linux/amd64
Imports
6 packages
Last checked
7 hours ago

Tools for package owners.