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.
This commit is contained in:
21
db_bsd.go
Normal file
21
db_bsd.go
Normal file
@@ -0,0 +1,21 @@
|
||||
//go:build !linux
|
||||
|
||||
package litestream
|
||||
|
||||
import (
|
||||
"io"
|
||||
"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 {
|
||||
db.mu.Lock()
|
||||
defer db.mu.Unlock()
|
||||
|
||||
if _, err := db.f.Seek(0, io.SeekStart); err != nil {
|
||||
return err
|
||||
}
|
||||
return fn(db.f)
|
||||
}
|
||||
Reference in New Issue
Block a user