Documentation ¶
Overview ¶
Package protolog implements a simple file format for a sequence of blobs with ability to store a message type with each blob as well as a checksum. It is intended for logging protobuf messages. Unlike other formats, it tries to be simple, so writing a reader/writer in other languages is trivial. This design is a modified form of Eric Lesh's recordio Go implementation (github.com/eclesh/recordio). It uses fixed size headers with support for a uint16 ID of the message type and a CRC-32C checksum. Each blob must be less than 4 GiB (2^32 bytes).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBadChecksum is an error returned when a bad checksum is detected. ErrBadChecksum = fmt.Errorf("bad checksum detected while reading data") )
Functions ¶
This section is empty.
Types ¶
type MultiTypedWriter ¶
type MultiTypedWriter struct {
// contains filtered or unexported fields
}
MultiTypedWriter writes records that can have different optional type identifiers
func NewMultiTypedWriter ¶
func NewMultiTypedWriter(w io.Writer) *MultiTypedWriter
NewMultiTypedWriter returns a new writer that could have different record types.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader allows reading of checksummed binary blobs with optional uint16 type IDs.
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
A Scanner is a convenient method for reading records sequentially.
func NewScanner ¶
NewScanner creates a new Scanner from reader r.
func (*Scanner) Bytes ¶
Bytes returns the data of the most recently scanned record. Subsequent calls may overwrite the returned data, so you must copy it if not using it immediately.
type TypedWriter ¶
type TypedWriter struct {
// contains filtered or unexported fields
}
TypedWriter writes records that have a single optional type identifier
func NewTypedWriter ¶
func NewTypedWriter(recordType uint16, w io.Writer) *TypedWriter
NewTypedWriter returns a new writer that uses the same record type.