Documentation ¶
Index ¶
Constants ¶
const (
SUFFIX = ".log"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ReaderCloser ¶
func NewReaderCloser ¶
func NewReaderCloser(filepath string) (ReaderCloser, error)
NewReaderCloser creates and returns a new WalReaderCloser instance initialized with the provided file path. It opens the file in read-write mode and wraps it into a Wal struct which implements ReaderCloser interface. If the file cannot be opened, an error is returned. The WalReaderCloser allows reading from and closing the Write-Ahead Log (WAL) file.
type Wal ¶
type Wal struct {
// contains filtered or unexported fields
}
func (*Wal) Close ¶
Close synchronously flushes any unwritten data to disk, closes the WAL file, and removes the file from the filesystem. Returns an error if any of these operations fail.
func (*Wal) Read ¶
Read decodes the next chunk from the Write-Ahead Log (WAL), verifying its integrity using CRC checksum. It returns a pointer to a Chunk which includes the key-value pair, and a boolean indicating deletion. If the chunk is marked as deleted, the value will be nil. It returns an error if any read operation fails or if the checksum does not match.
type WriterCloser ¶
func NewWriterCloser ¶
func NewWriterCloser(walDir string) (WriterCloser, error)
NewWriterCloser creates and returns a new WriterCloser instance initialized with a Write-Ahead Log (WAL) file located in the specified directory. The filename is generated based on the current time and appended with a predefined suffix. It opens the file for writing, creating it if necessary, and wraps it within a Wal structure. Returns a WriterCloser interface and an error if the file operation fails.