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 ¶
- Variables
- func GetULID() string
- type ConsistencyLevel
- func (z *ConsistencyLevel) DecodeMsg(dc *msgp.Reader) (err error)
- func (z ConsistencyLevel) EncodeMsg(en *msgp.Writer) (err error)
- func (z ConsistencyLevel) MarshalMsg(b []byte) (o []byte, err error)
- func (z ConsistencyLevel) Msgsize() (s int)
- func (z *ConsistencyLevel) UnmarshalMsg(bts []byte) (o []byte, err error)
- type FileMeta
- func (z *FileMeta) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *FileMeta) EncodeMsg(en *msgp.Writer) (err error)
- func (f *FileMeta) Map() map[string]string
- func (z *FileMeta) MarshalMsg(b []byte) (o []byte, err error)
- func (z *FileMeta) Msgsize() (s int)
- func (m FileMeta) String() string
- func (f *FileMeta) Unmap(m map[string]string)
- func (z *FileMeta) UnmarshalMsg(bts []byte) (o []byte, err error)
- type FileMetaList
- type ID
- type Journal
- type JournalIter
- type JournalManager
- type JournalMeta
- func (z *JournalMeta) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *JournalMeta) EncodeMsg(en *msgp.Writer) (err error)
- func (z *JournalMeta) MarshalMsg(b []byte) (o []byte, err error)
- func (z *JournalMeta) Msgsize() (s int)
- func (j JournalMeta) String() string
- func (z *JournalMeta) UnmarshalMsg(bts []byte) (o []byte, err error)
- type Mapping
Constants ¶
This section is empty.
Variables ¶
var ( RangeStop = errors.New("stop") ForEachStop = RangeStop )
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) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
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) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
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.
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
}