rlog

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLastIndex

func GetLastIndex(dir string) (index uint64, err error)

GetLastIndex returns the last written index of the replay log

Types

type Config

type Config struct {
	DisableFsync    bool
	ZeroCopy        bool
	WriteBufferSize int
}

type LogEntry

type LogEntry struct {
	Index uint64
	Data  proto.ReplayLogEntry
}

type Manager

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

Manager manages the replay log operations for reads and writes. Replay Log is an append-only log which persists all changesets.

func NewManager

func NewManager(logger logger.Logger, dir string, config Config) (*Manager, error)

func (*Manager) Close

func (m *Manager) Close() error

func (*Manager) LastIndex

func (m *Manager) LastIndex() (index uint64, err error)

LastIndex returns the last written index of the replay log

func (*Manager) Reader

func (m *Manager) Reader() Reader

func (*Manager) Writer

func (m *Manager) Writer() Writer

type RLReader

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

func NewReader

func NewReader(logger logger.Logger, rlog *wal.Log, config Config) (*RLReader, error)

func (*RLReader) CheckSubscriber

func (reader *RLReader) CheckSubscriber() error

CheckSubscriber check the error signal of the subscriber

func (*RLReader) ReadAt

func (reader *RLReader) ReadAt(index uint64) (*proto.ReplayLogEntry, error)

ReadAt will read the log entry at the provided index

func (*RLReader) Replay

func (reader *RLReader) Replay(start uint64, end uint64, processFn func(index uint64, entry proto.ReplayLogEntry) error) error

Replay will read the replay log and process each log entry with the provided function

func (*RLReader) StartSubscriber

func (reader *RLReader) StartSubscriber(fromIndex uint64, processFn func(index uint64, entry proto.ReplayLogEntry) error)

func (*RLReader) StopSubscriber

func (reader *RLReader) StopSubscriber() error

type RLWriter

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

func NewWriter

func NewWriter(logger logger.Logger, rlog *wal.Log, config Config) (*RLWriter, error)

func (*RLWriter) CheckAsyncCommit

func (writer *RLWriter) CheckAsyncCommit() error

CheckAsyncCommit check the quit signal of async rlog writing

func (*RLWriter) TruncateAfter

func (writer *RLWriter) TruncateAfter(index uint64) error

TruncateAfter will remove all entries that are after the provided `index`. In other words the entry at `index` becomes the last entry in the log.

func (*RLWriter) TruncateBefore

func (writer *RLWriter) TruncateBefore(index uint64) error

TruncateBefore will remove all entries that are before the provided `index`. In other words the entry at `index` becomes the first entry in the log.

func (*RLWriter) WaitAsyncCommit

func (writer *RLWriter) WaitAsyncCommit() error

WaitAsyncCommit will block and wait for async writes to complete

func (*RLWriter) Write

func (writer *RLWriter) Write(entry LogEntry) error

Write will write a new entry to the log at specific index. Whether the writes is in blocking or async manner depends on the buffer size.

type Reader

type Reader interface {
	// ReadAt will read the replay log at the given index
	ReadAt(index uint64) (*proto.ReplayLogEntry, error)
	// Replay will read the replay log and process each log entry with the provided function
	Replay(start uint64, end uint64, processFn func(index uint64, entry proto.ReplayLogEntry) error) error

	// StartSubscriber starts the underline subscriber goroutine to keep read the replay log from a given index
	StartSubscriber(fromIndex uint64, processFn func(index uint64, entry proto.ReplayLogEntry) error)

	// StopSubscriber stops the underline subscriber goroutine
	StopSubscriber() error

	// CheckSubscriber check the error signal of the subscriber
	CheckSubscriber() error
}

type Writer

type Writer interface {
	// Write will write a new entry to the log at the given index.
	Write(entry LogEntry) error

	// CheckAsyncCommit check the error signal of async writes
	CheckAsyncCommit() error

	// WaitAsyncCommit will block and wait for async writes to complete
	WaitAsyncCommit() error

	// TruncateBefore will remove all entries that are before the provided `index`
	TruncateBefore(index uint64) error

	// TruncateAfter will remove all entries that are after the provided `index`
	TruncateAfter(index uint64) error
}

Jump to

Keyboard shortcuts

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