Documentation
¶
Index ¶
- func GetLastIndex(dir string) (index uint64, err error)
- type Config
- type LogEntry
- type Manager
- type RLReader
- func (reader *RLReader) CheckSubscriber() error
- func (reader *RLReader) ReadAt(index uint64) (*proto.ReplayLogEntry, error)
- func (reader *RLReader) Replay(start uint64, end uint64, ...) error
- func (reader *RLReader) StartSubscriber(fromIndex uint64, ...)
- func (reader *RLReader) StopSubscriber() error
- type RLWriter
- type Reader
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetLastIndex ¶
GetLastIndex returns the last written index of the replay log
Types ¶
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 ¶
type RLReader ¶
type RLReader struct {
// contains filtered or unexported fields
}
func (*RLReader) CheckSubscriber ¶
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 (*RLReader) StopSubscriber ¶
type RLWriter ¶
type RLWriter struct {
// contains filtered or unexported fields
}
func (*RLWriter) CheckAsyncCommit ¶
CheckAsyncCommit check the quit signal of async rlog writing
func (*RLWriter) TruncateAfter ¶
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 ¶
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 ¶
WaitAsyncCommit will block and wait for async writes to complete
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
}