Refactor Restore()

This commit refactors out the complexity of downloading ordered WAL
files in parallel to a type called `WALDownloader`. This makes it
easier to test the restore separately from the download.
This commit is contained in:
Ben Johnson
2022-01-04 14:47:11 -07:00
parent 531e19ed6f
commit 3f0ec9fa9f
130 changed files with 2943 additions and 1254 deletions

View File

@@ -8,7 +8,6 @@ import (
"testing"
"github.com/benbjohnson/litestream"
"github.com/benbjohnson/litestream/file"
"github.com/benbjohnson/litestream/mock"
"github.com/pierrec/lz4/v4"
)
@@ -45,9 +44,9 @@ func TestReplica_Sync(t *testing.T) {
// Fetch current database position.
dpos := db.Pos()
c := file.NewReplicaClient(t.TempDir())
c := litestream.NewFileReplicaClient(t.TempDir())
r := litestream.NewReplica(db, "")
c.Replica, r.Client = r, c
r.Client = c
if err := r.Sync(context.Background()); err != nil {
t.Fatal(err)
@@ -81,7 +80,7 @@ func TestReplica_Snapshot(t *testing.T) {
db, sqldb := MustOpenDBs(t)
defer MustCloseDBs(t, db, sqldb)
c := file.NewReplicaClient(t.TempDir())
c := litestream.NewFileReplicaClient(t.TempDir())
r := litestream.NewReplica(db, "")
r.Client = c