package margaret
import "go.cryptoscope.co/margaret"
Index ¶
- Constants
- Variables
- func IsErrNulled(err error) bool
- func IsOutOfBounds(err error) bool
- type Alterer
- type Codec
- type Decoder
- type Encoder
- type Log
- type Query
- type QuerySpec
- func ErrorQuerySpec(err error) QuerySpec
- func Gt(s int64) QuerySpec
- func Gte(s int64) QuerySpec
- func Limit(n int) QuerySpec
- func Live(live bool) QuerySpec
- func Lt(s int64) QuerySpec
- func Lte(s int64) QuerySpec
- func MergeQuerySpec(spec ...QuerySpec) QuerySpec
- func Reverse(yes bool) QuerySpec
- func SeqWrap(wrap bool) QuerySpec
- type SeqWrapper
- type Seqer
Constants ¶
const ( // SeqEmpty is the current sequence number of an empty log SeqEmpty int64 = -1 // SeqErrored is returned if an operation (like Append) fails SeqErrored int64 = -2 SeqSublogDeleted int64 = -255 )
Variables ¶
var OOB oob
OOB is an out of bounds error
Functions ¶
func IsErrNulled ¶
func IsOutOfBounds ¶
IsOutOfBounds returns whether a particular error is an out-of-bounds error
Types ¶
type Alterer ¶
type Codec ¶
type Codec interface { // Marshal encodes a single value and returns the serialized byte slice. Marshal(value interface{}) ([]byte, error) // Unmarshal decodes and returns the value stored in data. Unmarshal(data []byte) (interface{}, error) NewDecoder(io.Reader) Decoder NewEncoder(io.Writer) Encoder }
Codec marshals and unmarshals values and creates encoders and decoders
type Decoder ¶
type Decoder interface { Decode() (interface{}, error) }
Decoder decodes values
type Encoder ¶
type Encoder interface { Encode(v interface{}) error }
Encoder encodes values
type Log ¶
type Log interface { // Seq returns the current sequence number, which is also the number of entries in the log Seqer // Changes returns an observable that holds the current sequence number Changes() luigi.Observable // Get returns the entry with sequence number seq Get(seq int64) (interface{}, error) // Query returns a stream that is constrained by the passed query specification Query(...QuerySpec) (luigi.Source, error) // Append appends a new entry to the log Append(interface{}) (int64, error) }
Log stores entries sequentially, which can be queried individually using Get or as streams using Query.
type Query ¶
type Query interface { // Gt makes the source return only items with sequence numbers > seq. Gt(seq int64) error // Gte makes the source return only items with sequence numbers >= seq. Gte(seq int64) error // Lt makes the source return only items with sequence numbers < seq. Lt(seq int64) error // Lte makes the source return only items with sequence numbers <= seq. Lte(seq int64) error // Limit makes the source return only up to n items. Limit(n int) error // Reverse makes the source return the lastest values first Reverse(yes bool) error // Live makes the source block at the end of the log and wait for new values // that are being appended. Live(bool) error // SeqWrap makes the source return values that contain both the item and its // sequence number, instead of the item alone. SeqWrap(bool) error }
Query is the interface implemented by the concrete log implementations that collects the constraints of the query.
type QuerySpec ¶
QuerySpec is a constraint on the query.
func ErrorQuerySpec ¶
ErrorQuerySpec makes the log.Query call return the passed error.
func Gt ¶
Gt makes the source return only items with sequence numbers > seq.
func Gte ¶
Gte makes the source return only items with sequence numbers >= seq.
func Limit ¶
Limit makes the source return only up to n items.
func Live ¶
Live makes the source block at the end of the log and wait for new values that are being appended.
func Lt ¶
Lt makes the source return only items with sequence numbers < seq.
func Lte ¶
Lte makes the source return only items with sequence numbers <= seq.
func MergeQuerySpec ¶
MergeQuerySpec collects several contraints and merges them into one.
func Reverse ¶
func SeqWrap ¶
SeqWrap makes the source return values that contain both the item and its sequence number, instead of the item alone.
type SeqWrapper ¶
type SeqWrapper interface { Seqer // Value returns the item itself. Value() interface{} }
SeqWrapper wraps a value to attach a sequence number to it.
func WrapWithSeq ¶
func WrapWithSeq(v interface{}, seq int64) SeqWrapper
WrapWithSeq wraps the value v to attach a sequence number to it.
type Seqer ¶
type Seqer interface { Seq() int64 }
Seqer returns the current sequence of a log
Source Files ¶
codec.go log.go qry.go seq.go seqwrap.go
Directories ¶
Path | Synopsis |
---|---|
codec | |
codec/cbor | |
codec/json | |
codec/msgpack | |
indexes | |
indexes/badger | |
indexes/badger/test | |
indexes/mapidx | |
indexes/mapidx/test | |
indexes/mkv | |
indexes/mkv/test | |
indexes/test | |
indexes/test/all | |
internal | |
legacyflumeoffset | Package legacyflumeoffset implements the first iteration of an offset file. |
legacyflumeoffset/test | |
mem | |
mem/test | |
multilog | |
multilog/roaring | |
multilog/roaring/badger | |
multilog/roaring/badger/cmd | |
multilog/roaring/badger/cmd/mbdump | |
multilog/roaring/fs | |
multilog/roaring/mkv | |
multilog/roaring/sqlite | |
multilog/roaring/test | |
multilog/test | |
multilog/test/all | |
offset2 | Package offset2 implements a margaret log as persisted sequence of data across multiple files. |
offset2/test | |
test | |
test/all |
- Version
- v0.4.3 (latest)
- Published
- Feb 17, 2022
- Platform
- linux/amd64
- Imports
- 3 packages
- Last checked
- 3 hours ago –
Tools for package owners.