Files
litestream/db_linux.go
Ben Johnson a090706421 Implement live read replication
This commit adds an http server and client for streaming snapshots
and WAL pages from an upstream Litestream primary to a read-only
replica.
2022-02-19 09:06:49 -07:00

19 lines
410 B
Go

//go:build linux
package litestream
import "os"
// WithFile executes fn with a file handle for the main database file.
// On Linux, this is a unique file handle for each call. On non-Linux
// systems, the file handle is shared because of lock semantics.
func (db *DB) WithFile(fn func(f *os.File) error) error {
f, err := os.Open(db.path)
if err != nil {
return err
}
defer f.Close()
return fn(f)
}