wal: reorgnize wal file

This commit is contained in:
Xiang Li 2014-07-27 21:01:39 -07:00 committed by Yicheng Qin
parent a25cd45876
commit d70df4a15d
2 changed files with 11 additions and 11 deletions

View File

@ -58,3 +58,10 @@ func readBlock(r io.Reader, b *block) error {
b.d = d
return nil
}
func unexpectedEOF(err error) error {
if err == io.EOF {
return io.ErrUnexpectedEOF
}
return err
}

View File

@ -65,6 +65,10 @@ func Open(path string) (*WAL, error) {
return newWAL(f), nil
}
func (w *WAL) Flush() error {
return w.bw.Flush()
}
func (w *WAL) Close() {
if w.f != nil {
w.Flush()
@ -102,10 +106,6 @@ func (w *WAL) SaveState(s *raft.State) error {
return writeBlock(w.bw, stateType, w.buf.Bytes())
}
func (w *WAL) Flush() error {
return w.bw.Flush()
}
func (w *WAL) checkAtHead() error {
o, err := w.f.Seek(0, os.SEEK_CUR)
if err != nil {
@ -199,13 +199,6 @@ func readInt64(r io.Reader) (int64, error) {
return n, err
}
func unexpectedEOF(err error) error {
if err == io.EOF {
return io.ErrUnexpectedEOF
}
return err
}
func max(a, b int64) int64 {
if a > b {
return a