// Read reads the next chunk from the WAL, blocking until one is available.
Read reads the next chunk from the WAL, blocking until one is available.
// Read reads the next chunk from the WAL blocking until one is available .
func (r *Reader) Read() ([]byte, error) {
	for {
		length, checksum, err := r.readHeader()
		if err != nil {
			return nil, err
		}
		if length > maxEntrySize {
			fmt.Printf("Discarding wal entry of size %v exceeding %v, probably corrupted\n", humanize.Bytes(uint64(length)), humanize.Bytes(uint64(maxEntrySize)))
			_, discardErr := io.CopyN(ioutil.Discard, r.reader, int64(length))
			if discardErr == io.EOF {
				discardErr = nil
			}
			return nil, discardErr
		}
		data, err := r.readData(int(length))
		if data != nil || err != nil {
			if data != nil {
				r.h.Reset()
				r.h.Write(data)
				if checksum != r.h.Sum32() {
					r.log.Errorf("Checksum mismatch, skipping entry")
					continue
				}
			}
			return data, err
		}
	}
}
func ( r * Reader ) Read ( ) ( [ ] byte , error ) { for { length , checksum , err := r . readHeader ( ) if err != nil { return nil , err } if length > maxEntrySize { fmt . Printf ( " \n " , humanize . Bytes ( uint64 ( length ) ) , humanize . Bytes ( uint64 ( maxEntrySize ) ) ) _ , discardErr := io . CopyN ( ioutil . Discard , r . reader , int64 ( length ) ) if discardErr == io . EOF { discardErr = nil } return nil , discardErr } data , err := r . readData ( int ( length ) ) if data != nil || err != nil { if data != nil { r . h . Reset ( ) r . h . Write ( data ) if checksum != r . h . Sum32 ( ) { r . log . Errorf ( " " ) continue } } return data , err } } }
Read reads the next chunk from the WAL, blocking until one is available.
Read reads the next chunk from the WAL blocking until one is available .