Walrog is a Go library that implements a simple yet functional Write-Ahead Logging (WAL) system. It was designed as a personal project to understand and demonstrate the fundamentals of WAL, offering reliable data persistence and crash recovery mechanisms.
- Sequential logging with LSN, length, and CRC validation.
- Buffered writes to disk with automatic WAL file rotation.
- Recovery of valid records from existing WAL files.
- Configurable segmentation and initial checkpoint system.
- CRC-based data integrity checks.
- Unit tests covering the main functional use cases.
Clone the repository:
git clone https://github.com/casteloig/walrog.git
cd walrogMake sure you have Go 1.18 or higher installed.
package main
import (
"fmt"
"github.com/casteloig/walrog/internal/core"
)
func main() {
// Initialize with default options
wal, err := core.InitWal(nil)
if err != nil {
panic(err)
}
// Write a message
err = wal.WriteBuffer([]byte("Hello World!"))
if err != nil {
panic(err)
}
// Flush to disk
err = wal.FlushBuffer()
if err != nil {
panic(err)
}
fmt.Println("Entry successfully written.")
}MIT License. See the LICENSE file for more details.