Documentation
¶
Overview ¶
Package wal implements write-ahead logging.
Index ¶
- Constants
- Variables
- type Options
- type WAL
- func (w *WAL) Clean(index uint64) (err error)
- func (w *WAL) Close() (err error)
- func (w *WAL) FirstIndex() (index uint64, err error)
- func (w *WAL) Flush() error
- func (w *WAL) IsExist(index uint64) (bool, error)
- func (w *WAL) LastIndex() (index uint64, err error)
- func (w *WAL) Read(index uint64) (data []byte, err error)
- func (w *WAL) Reset() (err error)
- func (w *WAL) Sync() error
- func (w *WAL) Truncate(index uint64) (err error)
- func (w *WAL) Write(index uint64, data []byte) (err error)
Constants ¶
View Source
const ( // DefaultSegmentSize is the default segment size. DefaultSegmentSize = 1024 * 1024 * 512 // DefaultSegmentEntries is the default segment entries. DefaultSegmentEntries = 1024 * 1024 * 8 // DefaultWriteBufferSize is the default write buffer size. DefaultWriteBufferSize = 1024 * 1024 // DefaultEncodeBufferSize is the default encode buffer size. DefaultEncodeBufferSize = 1024 * 64 // DefaultBase is the default base. DefaultBase = 10 )
View Source
const ( // DefaultLogSuffix is the default log suffix. DefaultLogSuffix = ".log" // DefaultIndexSuffix is the default index suffix. DefaultIndexSuffix = ".idx" )
Variables ¶
View Source
var ( // ErrClosed is returned when the log is closed. ErrClosed = errors.New("closed") // ErrUnexpectedSize is returned when the number of bytes is unexpected. ErrUnexpectedSize = errors.New("unexpected size") // ErrOutOfRange is returned when the index is out of range. ErrOutOfRange = errors.New("out of range") // ErrZeroIndex is returned because the index must be greater than zero. ErrZeroIndex = errors.New("index can not be zero") // ErrOutOfOrder is returned when the index is out of order. The index must be equal to LastIndex + 1 ErrOutOfOrder = errors.New("out of order") // ErrBase is returned when base < 2 or base > 36 ErrBase = errors.New("2 <= base <= 36") )
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// SegmentSize is the segment size.
SegmentSize int
// SegmentEntries is the number of segment entries.
SegmentEntries int
// EncodeBufferSize is the encode buffer size.
EncodeBufferSize int
// WriteBufferSize is the write buffer size.
WriteBufferSize int
// LogSuffix is the log suffix.
LogSuffix string
// IndexSuffix is the index suffix.
IndexSuffix string
// Base is the base.
Base int
// NoSplitSegment is used by the Clean method. When this option is set,
// do not split the segment. Default is false .
NoSplitSegment bool
}
Options represents options
type WAL ¶
type WAL struct {
// contains filtered or unexported fields
}
WAL represents a write-ahead log.
func (*WAL) FirstIndex ¶
FirstIndex returns the write-ahead log first index.
func (*WAL) Sync ¶
Sync commits the current contents of the file to stable storage. Typically, this means flushing the file system's in-memory copy of recently written data to disk.
Click to show internal directories.
Click to hide internal directories.