Documentation
¶
Overview ¶
Package journal implements WAL-like append-only “journal” files.
Intended use cases:
- Database WAL files.
- Log files of various kinds.
- Archival of historical database records.
Features:
Suitable for records of all sizes, from very short to very long. Long records can be written to the file in chunks. Multiple short records can be combined into a single transaction with minimal overhead.
Crash-resistant (if followed by an fsync). Contains a CRC32 checksum of each record, and automatically trims the file after the first corrupted record.
Performant.
Automatically rotates the files when they reach a certain size. (You can also trigger the rotation programmatically at any time.)
Manages segment file namingю
The ¶
File format: segmentHeader (recordHeader bytes* padding* recordTrailer)
- file = segmentHeader record*
- segmentHeader = magic:64 segmentNumber:32 flags:32 prevChecksum:64 fixedMarker:64*4 segmentMarker:64*4 checksum:64
- header = magic:64 seq:32 fe:16 se:16 flags:64
- record = flagsAndSize:uvarint timestamp:32? bytes* checksum:64?
Index ¶
Constants ¶
const DefaultMaxFileSize = 4 * 1024 * 1024
const IgnorableTimestampDriftSeconds = 10
Variables ¶
var ( ErrIncompatible = fmt.Errorf("incompatible journal") ErrUnsupportedVersion = fmt.Errorf("unsupported journal version") )
Functions ¶
This section is empty.
Types ¶
type Journal ¶
type Journal struct {
// contains filtered or unexported fields
}
Journal represents a set of AOFs.
func (*Journal) FinishWriting ¶
func (j *Journal) FinishWriting()
func (*Journal) StartWriting ¶
func (j *Journal) StartWriting()