func newSnapshotReaderCloser(snapshot backend.Snapshot) io.ReadCloser { pr, pw := io.Pipe() go func() { _, err := snapshot.WriteTo(pw) pw.CloseWithError(err) snapshot.Close() }() return pr }
func newSnapshotReaderCloser(snapshot backend.Snapshot) io.ReadCloser { pr, pw := io.Pipe() go func() { n, err := snapshot.WriteTo(pw) if err == nil { plog.Infof("wrote database snapshot out [total bytes: %d]", n) } pw.CloseWithError(err) snapshot.Close() }() return pr }