commitlog

package
v0.0.0-...-c0a90d8 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2017 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogFileSuffix   = ".log"
	IndexFileSuffix = ".index"
)

Variables

View Source
var (
	ErrSegmentNotFound = errors.New("segment not found")
	Encoding           = binary.BigEndian
)
View Source
var (
	ErrIndexCorrupt = errors.New("corrupt index file")
)

Functions

This section is empty.

Types

type Cleaner

type Cleaner interface {
	Clean([]*Segment) ([]*Segment, error)
}

type CommitLog

type CommitLog struct {
	Options
	// contains filtered or unexported fields
}

func New

func New(opts Options) (*CommitLog, error)

func (*CommitLog) Append

func (l *CommitLog) Append(b []byte) (offset int64, err error)

func (*CommitLog) Close

func (l *CommitLog) Close() error

func (*CommitLog) Delete

func (l *CommitLog) Delete() error

func (*CommitLog) DeleteRange

func (l *CommitLog) DeleteRange(min uint64, max uint64) error

func (*CommitLog) FirstIndex

func (l *CommitLog) FirstIndex() (uint64, error)

func (*CommitLog) Get

func (c *CommitLog) Get(key []byte) ([]byte, error)

func (*CommitLog) GetLog

func (l *CommitLog) GetLog(index uint64, log *raft.Log) error

func (*CommitLog) GetUint64

func (c *CommitLog) GetUint64(key []byte) (uint64, error)

func (*CommitLog) LastIndex

func (l *CommitLog) LastIndex() (uint64, error)

func (*CommitLog) NewReader

func (l *CommitLog) NewReader(offset int64, maxBytes int32) (io.Reader, error)

func (*CommitLog) NewestOffset

func (l *CommitLog) NewestOffset() int64

func (*CommitLog) OldestOffset

func (l *CommitLog) OldestOffset() int64

func (*CommitLog) Read

func (l *CommitLog) Read(p []byte) (n int, err error)

func (*CommitLog) Segments

func (l *CommitLog) Segments() []*Segment

func (*CommitLog) Set

func (c *CommitLog) Set(key []byte, val []byte) error

func (*CommitLog) SetUint64

func (c *CommitLog) SetUint64(key []byte, val uint64) error

func (*CommitLog) StoreLog

func (l *CommitLog) StoreLog(log *raft.Log) error

func (*CommitLog) StoreLogs

func (l *CommitLog) StoreLogs(logs []*raft.Log) error

func (*CommitLog) Truncate

func (l *CommitLog) Truncate(offset int64) error

type DeleteCleaner

type DeleteCleaner struct {
	Retention struct {
		Bytes int64
	}
}

func NewDeleteCleaner

func NewDeleteCleaner(bytes int64) *DeleteCleaner

func (*DeleteCleaner) Clean

func (c *DeleteCleaner) Clean(segments []*Segment) ([]*Segment, error)

type Entry

type Entry struct {
	Offset   int64
	Position int64
}

type Message

type Message []byte

func NewMessage

func NewMessage(p []byte) Message

type MessageSet

type MessageSet []byte

func NewMessageSet

func NewMessageSet(offset uint64, msgs ...Message) MessageSet

func (MessageSet) Offset

func (ms MessageSet) Offset() int64

func (MessageSet) Payload

func (ms MessageSet) Payload() []byte

func (MessageSet) PutOffset

func (ms MessageSet) PutOffset(offset int64)

func (MessageSet) Size

func (ms MessageSet) Size() int32

type Options

type Options struct {
	Path            string
	MaxSegmentBytes int64
	MaxLogBytes     int64
}

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

func (*Reader) Read

func (r *Reader) Read(p []byte) (n int, err error)

type Segment

type Segment struct {
	Index      *index
	BaseOffset int64
	NextOffset int64
	Position   int64

	sync.Mutex
	// contains filtered or unexported fields
}

func NewSegment

func NewSegment(path string, baseOffset int64, maxBytes int64) (*Segment, error)

func (*Segment) Close

func (s *Segment) Close() error

func (*Segment) Delete

func (s *Segment) Delete() error

func (*Segment) IsFull

func (s *Segment) IsFull() bool

func (*Segment) Read

func (s *Segment) Read(p []byte) (n int, err error)

func (*Segment) ReadAt

func (s *Segment) ReadAt(p []byte, off int64) (n int, err error)

func (*Segment) SetupIndex

func (s *Segment) SetupIndex(path string) (err error)

SetupIndex creates and initializes an index. Initialization is: - Sanity check of the loaded index - Truncates the index (clears it) - Reads the log file from the beginning and re-initializes the index

func (*Segment) Write

func (s *Segment) Write(p []byte) (n int, err error)

Write writes a byte slice to the log at the current position. It increments the offset as well as sets the position to the new tail.

Jump to

Keyboard shortcuts

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