journal

package
v0.0.0-...-2ca1813 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2017 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package journal is responsible for maintaining the inner state of the OBJSTORE, journals represent managed event logs that can be diffed, joined and stored as in-memory B-tree or in a BoltDB bucket. All operations on BoltDB are performed in the context of a transaction, so journals are ACID-compatible.

Index

Constants

This section is empty.

Variables

View Source
var (
	RangeStop   = errors.New("stop")
	ForEachStop = RangeStop
)
View Source
var ErrRangeStop = errors.New("range stop")

Functions

func GetULID

func GetULID() string

GetULID constucts an Universally Unique Lexicographically Sortable Identifier. See https://github.com/oklog/ulid

Types

type ConsistencyLevel

type ConsistencyLevel int
const (
	// ConsistencyLocal flags file for local persistence only, implying
	// that the file body will be stored on a single node. Default.
	ConsistencyLocal ConsistencyLevel = 0
	// ConsistencyS3 flags file for local+S3 persistence, implying that the file
	// body will be stored on a single node and Amazon S3.
	ConsistencyS3 ConsistencyLevel = 1
	// ConsistencyFull flags file to be replicated across all existing nodes in cluster and S3.
	ConsistencyFull ConsistencyLevel = 2
)

func (*ConsistencyLevel) DecodeMsg

func (z *ConsistencyLevel) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (ConsistencyLevel) EncodeMsg

func (z ConsistencyLevel) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (ConsistencyLevel) MarshalMsg

func (z ConsistencyLevel) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (ConsistencyLevel) Msgsize

func (z ConsistencyLevel) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*ConsistencyLevel) UnmarshalMsg

func (z *ConsistencyLevel) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type FileMeta

type FileMeta struct {
	ID          string            `msgp:"0" json:"id"`
	Name        string            `msgp:"1" json:"name"`
	Size        int64             `msgp:"2" json:"size"`
	Timestamp   int64             `msgp:"3" json:"timestamp"`
	UserMeta    map[string]string `msgp:"4" json:"user_meta"`
	IsSymlink   bool              `msgp:"5" json:"is_symlink"`
	Consistency ConsistencyLevel  `msgp:"6" json:"consistency"`
	IsDeleted   bool              `msgp:"7" json:"is_deleted"`
	IsFetched   bool              `msgp:"8" json:"is_fetched"`
}

func (*FileMeta) DecodeMsg

func (z *FileMeta) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*FileMeta) EncodeMsg

func (z *FileMeta) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*FileMeta) Map

func (f *FileMeta) Map() map[string]string

func (*FileMeta) MarshalMsg

func (z *FileMeta) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*FileMeta) Msgsize

func (z *FileMeta) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (FileMeta) String

func (m FileMeta) String() string

func (*FileMeta) Unmap

func (f *FileMeta) Unmap(m map[string]string)

func (*FileMeta) UnmarshalMsg

func (z *FileMeta) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type FileMetaList

type FileMetaList []*FileMeta

func (*FileMetaList) DecodeMsg

func (z *FileMetaList) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (FileMetaList) EncodeMsg

func (z FileMetaList) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (FileMetaList) MarshalMsg

func (z FileMetaList) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (FileMetaList) Msgsize

func (z FileMetaList) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*FileMetaList) UnmarshalMsg

func (z *FileMetaList) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type ID

type ID string

func (*ID) DecodeMsg

func (z *ID) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (ID) EncodeMsg

func (z ID) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (ID) MarshalMsg

func (z ID) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (ID) Msgsize

func (z ID) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*ID) UnmarshalMsg

func (z *ID) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Journal

type Journal interface {
	ID() ID
	Get(k string) *FileMeta
	Exists(k string) bool
	Set(k string, m *FileMeta) error
	Delete(k string) error
	Diff(j Journal) (added FileMetaList, deleted FileMetaList)
	Range(start string, limit int, fn func(k string, v *FileMeta) error) (string, error)
	Join(target Journal, mapping Mapping) error
	List() FileMetaList
	Close() error
	Meta() *JournalMeta
}

func MakeJournal

func MakeJournal(id ID, events FileMetaList) Journal

MakeJournal allows to represent a serialized list of events as an in-memory journal compatible with journals backed by a real KV store.

func NewJournal

func NewJournal(id ID, tx *bolt.Tx, bucket *bolt.Bucket) Journal

NewJournal creates a new journal backed by a BoltDB bucket, in the context of a transaction.

type JournalIter

type JournalIter func(journal Journal, meta *JournalMeta) error

type JournalManager

type JournalManager interface {
	Create(id ID) error
	View(id ID, fn JournalIter) error
	Update(id ID, fn JournalIter) error

	ForEach(fn JournalIter) error
	ForEachUpdate(fn JournalIter) error

	JoinAll(target ID) (*JournalMeta, error)
	ListAll() ([]*JournalMeta, error)
	ExportAll() (FileMetaList, error)

	Close() error
}

func NewJournalManager

func NewJournalManager(db *bolt.DB) JournalManager

type JournalMeta

type JournalMeta struct {
	ID         ID     `msgp:"0" json:"journal_id"`
	CreatedAt  int64  `msgp:"1" json:"created_at"`
	JoinedAt   int64  `msgp:"2" json:"joined_at"`
	FirstKey   string `msgp:"3" json:"first_key"`
	LastKey    string `msgp:"4" json:"last_key"`
	CountTotal int    `msgp:"5" json:"count_total"`
}

func (*JournalMeta) DecodeMsg

func (z *JournalMeta) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*JournalMeta) EncodeMsg

func (z *JournalMeta) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*JournalMeta) MarshalMsg

func (z *JournalMeta) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*JournalMeta) Msgsize

func (z *JournalMeta) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (JournalMeta) String

func (j JournalMeta) String() string

func (*JournalMeta) UnmarshalMsg

func (z *JournalMeta) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Mapping

type Mapping interface {
	Get(id ID) *JournalMeta
	Set(id ID, meta *JournalMeta) error
	SetBytes(k, v []byte) error
}

func NewMapping

func NewMapping(tx *bolt.Tx) (Mapping, error)

Jump to

Keyboard shortcuts

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