objstore: github.com/SphereSoftware/objstore/journal Index | Files

package journal

import "github.com/SphereSoftware/objstore/journal"

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

Package Files

helpers.go journal.go manager.go mapping.go meta.go meta_gen.go

Variables

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

func GetULID Uses

func GetULID() string

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

type ConsistencyLevel Uses

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 Uses

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

DecodeMsg implements msgp.Decodable

func (ConsistencyLevel) EncodeMsg Uses

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

EncodeMsg implements msgp.Encodable

func (ConsistencyLevel) MarshalMsg Uses

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

MarshalMsg implements msgp.Marshaler

func (ConsistencyLevel) Msgsize Uses

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 Uses

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

UnmarshalMsg implements msgp.Unmarshaler

type FileMeta Uses

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 Uses

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

DecodeMsg implements msgp.Decodable

func (*FileMeta) EncodeMsg Uses

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

EncodeMsg implements msgp.Encodable

func (*FileMeta) Map Uses

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

func (*FileMeta) MarshalMsg Uses

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

MarshalMsg implements msgp.Marshaler

func (*FileMeta) Msgsize Uses

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 Uses

func (m FileMeta) String() string

func (*FileMeta) Unmap Uses

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

func (*FileMeta) UnmarshalMsg Uses

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

UnmarshalMsg implements msgp.Unmarshaler

type FileMetaList Uses

type FileMetaList []*FileMeta

func (*FileMetaList) DecodeMsg Uses

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

DecodeMsg implements msgp.Decodable

func (FileMetaList) EncodeMsg Uses

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

EncodeMsg implements msgp.Encodable

func (FileMetaList) MarshalMsg Uses

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

MarshalMsg implements msgp.Marshaler

func (FileMetaList) Msgsize Uses

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 Uses

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

UnmarshalMsg implements msgp.Unmarshaler

type ID Uses

type ID string

func (*ID) DecodeMsg Uses

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

DecodeMsg implements msgp.Decodable

func (ID) EncodeMsg Uses

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

EncodeMsg implements msgp.Encodable

func (ID) MarshalMsg Uses

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

MarshalMsg implements msgp.Marshaler

func (ID) Msgsize Uses

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 Uses

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

UnmarshalMsg implements msgp.Unmarshaler

type Journal Uses

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 Uses

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 Uses

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 Uses

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

type JournalManager Uses

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 Uses

func NewJournalManager(db *bolt.DB) JournalManager

type JournalMeta Uses

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 Uses

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

DecodeMsg implements msgp.Decodable

func (*JournalMeta) EncodeMsg Uses

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

EncodeMsg implements msgp.Encodable

func (*JournalMeta) MarshalMsg Uses

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

MarshalMsg implements msgp.Marshaler

func (*JournalMeta) Msgsize Uses

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 Uses

func (j JournalMeta) String() string

func (*JournalMeta) UnmarshalMsg Uses

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

UnmarshalMsg implements msgp.Unmarshaler

type Mapping Uses

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

func NewMapping Uses

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

Package journal imports 13 packages (graph). Updated 2017-09-27. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).