margaret: go.cryptoscope.co/margaret Index | Files | Directories

package margaret

import "go.cryptoscope.co/margaret"

Index

Package Files

codec.go framing.go log.go qry.go seq.go seqwrap.go

Variables

var ErrNulled errNulled
var OOB oob

OOB is an out of bounds error

func IsErrNulled Uses

func IsErrNulled(err error) bool

func IsOutOfBounds Uses

func IsOutOfBounds(err error) bool

IsOutOfBounds returns whether a particular error is an out-of-bounds error

type Alterer Uses

type Alterer interface {
    Null(Seq) error

    Replace(Seq, []byte) error
}

type BaseSeq Uses

type BaseSeq int64

BaseSeq is the sequence number of an item in the log TODO currently this BaseSeq and the one in multilog somewhat do the same but not really. Find a way to unify them.

const (
    // SeqEmpty is the current sequence number of an empty log
    SeqEmpty BaseSeq = -1
)

func (BaseSeq) Seq Uses

func (s BaseSeq) Seq() int64

Seq returns itself to adhere to the Seq interface in ./multilog.

type Codec Uses

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 Uses

type Decoder interface {
    Decode() (interface{}, error)
}

Decoder decodes values

type Encoder Uses

type Encoder interface {
    Encode(v interface{}) error
}

Encoder encodes values

type Framing Uses

type Framing interface {
    DecodeFrame([]byte) ([]byte, error)
    EncodeFrame([]byte) ([]byte, error)

    FrameSize() int64
}

Framing encodes and decodes byte slices into a framing so the frames can be stored sequentially

type Log Uses

type Log interface {
    // Seq returns an observable that holds the current sequence number
    Seq() luigi.Observable

    // Get returns the entry with sequence number seq
    Get(seq Seq) (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{}) (Seq, error)
}

Log stores entries sequentially, which can be queried individually using Get or as streams using Query.

type Query Uses

type Query interface {
    // Gt makes the source return only items with sequence numbers > seq.
    Gt(seq Seq) error
    // Gte makes the source return only items with sequence numbers >= seq.
    Gte(seq Seq) error
    // Lt makes the source return only items with sequence numbers < seq.
    Lt(seq Seq) error
    // Lte makes the source return only items with sequence numbers <= seq.
    Lte(seq Seq) 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 Uses

type QuerySpec func(Query) error

QuerySpec is a constraint on the query.

func ErrorQuerySpec Uses

func ErrorQuerySpec(err error) QuerySpec

ErrorQuerySpec makes the log.Query call return the passed error.

func Gt Uses

func Gt(s Seq) QuerySpec

Gt makes the source return only items with sequence numbers > seq.

func Gte Uses

func Gte(s Seq) QuerySpec

Gte makes the source return only items with sequence numbers >= seq.

func Limit Uses

func Limit(n int) QuerySpec

Limit makes the source return only up to n items.

func Live Uses

func Live(live bool) QuerySpec

Live makes the source block at the end of the log and wait for new values that are being appended.

func Lt Uses

func Lt(s Seq) QuerySpec

Lt makes the source return only items with sequence numbers < seq.

func Lte Uses

func Lte(s Seq) QuerySpec

Lte makes the source return only items with sequence numbers <= seq.

func MergeQuerySpec Uses

func MergeQuerySpec(spec ...QuerySpec) QuerySpec

MergeQuerySpec collects several contraints and merges them into one.

func Reverse Uses

func Reverse(yes bool) QuerySpec

func SeqWrap Uses

func SeqWrap(wrap bool) QuerySpec

SeqWrap makes the source return values that contain both the item and its sequence number, instead of the item alone.

type Seq Uses

type Seq interface {
    Seq() int64
}

type SeqWrapper Uses

type SeqWrapper interface {
    // Seq returns the sequence number of the item.
    Seq() Seq

    // Value returns the item itself.
    Value() interface{}
}

SeqWrapper wraps a value to attach a sequence number to it.

func WrapWithSeq Uses

func WrapWithSeq(v interface{}, seq Seq) SeqWrapper

WrapWithSeq wraps the value v to attach a sequence number to it.

Directories

PathSynopsis
codec/cbor
codec/json
codec/msgpack
framing/basic
framing/lengthprefixed
internal/persist
internal/persist/fs
internal/persist/mkv
internal/persist/sqlite
internal/seqobsvPackage seqobsv wants to supply an observable value sepcialized for sequence numbers in append-only logs.
mem
mem/test
mockCode generated by counterfeiter.
multilog
multilog/badger
multilog/badger/test
multilog/roaring
multilog/roaring/mkv
multilog/roaring/sqlite
multilog/roaring/test
multilog/test
multilog/test/all
offset
offset2Package offset2 implements a margaret log as persisted sequence of data across multiple files.
offset2/test
offset/test
test
test/all

Package margaret imports 3 packages (graph) and is imported by 88 packages. Updated 2020-04-24. Refresh now. Tools for package owners.