Пример #1
0
func newSnapshotReaderCloser(snapshot backend.Snapshot) io.ReadCloser {
	pr, pw := io.Pipe()
	go func() {
		_, err := snapshot.WriteTo(pw)
		pw.CloseWithError(err)
		snapshot.Close()
	}()
	return pr
}
Пример #2
0
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
}