Documentation ¶
Index ¶
- Constants
- type Offset
- type Opts
- type Reader
- type WAL
- func (wal *WAL) Close() (err error)
- func (wal *WAL) CompressBefore(o Offset) error
- func (wal *WAL) CompressBeforeSize(limit int64) error
- func (wal *WAL) CompressBeforeTime(ts time.Time) error
- func (wal *WAL) Latest() ([]byte, Offset, error)
- func (wal *WAL) NewReader(name string, offset Offset, bufferSource func() []byte) (*Reader, error)
- func (wal *WAL) TruncateBefore(o Offset) error
- func (wal *WAL) TruncateBeforeTime(ts time.Time) error
- func (wal *WAL) TruncateToSize(limit int64) error
- func (wal *WAL) Write(bufs ...[]byte) error
Constants ¶
const (
// OffsetSize is the size in bytes of a WAL offset
OffsetSize = 16
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Offset ¶
type Offset []byte
Offset records an offset in the WAL
func NewOffsetForTS ¶
NewOffsetForTS creates an offset for a given timestamp.
func (Offset) FileSequence ¶
type Opts ¶
type Opts struct { // Dir is the location of the WAL Dir string // SyncInterval determines how frequently to force an fsync to flush data to disk. // If syncInterval is 0, it will force sync on every write to the WAL. SyncInterval time.Duration // MaxMemoryBacklog determines the maximum number of writes that will be held in memory // pending write to the WAL. Set this to 0 to use no backlog, set to a value greater than 0 // to allow buffering in memory. This can be useful to avoid slowing down clients while background // fsync takes place. MaxMemoryBacklog int }
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader allows reading from a WAL. It is NOT safe to read from a single Reader from multiple goroutines.
func (*Reader) Offset ¶
Offset returns the furthest Offset read by this Reader. It is NOT safe to call this concurrently with Read().
type WAL ¶
type WAL struct {
// contains filtered or unexported fields
}
WAL provides a simple write-ahead log backed by a single file on disk. It is safe to write to a single WAL from multiple goroutines.
func (*WAL) CompressBefore ¶
CompressBefore compresses all data prior to the given offset on disk.
func (*WAL) CompressBeforeSize ¶
CompressBeforeSize compresses all segments prior to the given size
func (*WAL) CompressBeforeTime ¶
CompressBeforeTime compresses all data prior to the given offset on disk.
func (*WAL) NewReader ¶
NewReader constructs a new Reader for reading from this WAL starting at the given offset. The returned Reader is NOT safe for use from multiple goroutines. Name is just a label for the reader used during logging.
func (*WAL) TruncateBefore ¶
TruncateBefore removes all data prior to the given offset from disk.
func (*WAL) TruncateBeforeTime ¶
TruncateBeforeTime truncates WAL data prior to the given timestamp.
func (*WAL) TruncateToSize ¶
TruncateToSize caps the size of the WAL to the given number of bytes