README

Go Reference

golang.org/x/build/maintner/reclog

Package reclog contains readers and writers for a record wrapper format used by maintner.

Documentation

Overview

    Package reclog contains readers and writers for a record wrapper format used by maintner.

    Index

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    func AppendRecordToFile

    func AppendRecordToFile(filename string, data []byte) error

      AppendRecordToFile opens the named filename for append (creating it if necessary) and adds the provided data record to the end. The caller is responsible for file locking.

      func ForeachFileRecord

      func ForeachFileRecord(path string, fn RecordCallback) error

        ForeachFileRecord calls fn for each record in the named file. Calls to fn are made serially. If fn returns an error, iteration ends and that error is returned.

        func ForeachRecord

        func ForeachRecord(r io.Reader, startOffset int64, fn RecordCallback) error

          ForeachRecord calls fn for each record in r. Calls to fn are made serially. If fn returns an error, iteration ends and that error is returned. The startOffset is where in the file r represents. It should be 0 if reading from the beginning of a file.

          func WriteRecord

          func WriteRecord(w io.Writer, off int64, data []byte) error

            WriteRecord writes the record data to w, formatting the record wrapper with the given offset off. It is the caller's responsibility to pass the correct offset. Exactly one Write call will be made to w.

            Types

            type RecordCallback

            type RecordCallback func(off int64, hdr, rec []byte) error

              RecordCallback is the callback signature accepted by ForeachFileRecord and ForeachRecord, which read the mutation log format used by DiskMutationLogger.

              Offset is the offset in the logical of physical file. hdr and bytes are only valid until the function returns and must not be retained.

              hdr is the record header, in the form "REC@c765c9a+1d3=" (REC@ <hex offset> + <hex len(rec)> + '=').

              rec is the proto3 binary marshalled representation of *maintpb.Mutation.

              If the callback returns an error, iteration stops.

              Source Files