func newSnapshotReaderCloser(snapshot dstorage.Snapshot) io.ReadCloser { pr, pw := io.Pipe() go func() { _, err := snapshot.WriteTo(pw) pw.CloseWithError(err) snapshot.Close() }() return pr }
func newSnapshot(r raftpb.Snapshot, kv dstorage.Snapshot) *snapshot { done := make(chan struct{}) pr, pw := io.Pipe() go func() { _, err := kv.WriteTo(pw) pw.CloseWithError(err) kv.Close() close(done) }() return &snapshot{ r: r, ReadCloser: pr, done: done, } }