Documentation ¶
Index ¶
Constants ¶
const ( // MessageRef indicates this is a Ref message MessageRef = 1 // MessageDef indicates this is a Def message MessageDef = 2 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DelimitedReader ¶
type DelimitedReader struct {
// contains filtered or unexported fields
}
DelimitedReader consumes length-delimited records from a byte source.
Usage:
rd := delimited.NewReader(r) for { rec, err := rd.Next() if err == io.EOF { break } else if err != nil { log.Fatal(err) } doStuffWith(rec) }
func NewDelimitedReader ¶
func NewDelimitedReader(r io.Reader) *DelimitedReader
NewDelimitedReader constructs a new delimited Reader for the records in r.
func (*DelimitedReader) Next ¶
func (r *DelimitedReader) Next() ([]byte, error)
Next returns the next length-delimited record from the input, or io.EOF if there are no more records available. Returns io.ErrUnexpectedEOF if a short record is found, with a length of n but fewer than n bytes of data. Because there is no resynchronization mechanism, it is generally not possible to recover from a short record in this format.
The slice returned is valid only until a subsequent call to Next.
type DelimitedWriter ¶
type DelimitedWriter struct {
// contains filtered or unexported fields
}
A DelimitedWriter outputs delimited records to an io.Writer.
Basic usage:
wr := delimited.NewWriter(w) for record := range records { if err := wr.Put(record); err != nil { log.Fatal(err) } }
func NewDelimitedWriter ¶
func NewDelimitedWriter(w io.Writer) *DelimitedWriter
NewDelimitedWriter constructs a new delimited Writer that writes records to w.
func (DelimitedWriter) Put ¶
func (w DelimitedWriter) Put(record []byte) error
Put writes the specified record to the writer. It equivalent to WriteRecord, but discards the number of bytes written.
func (DelimitedWriter) PutProto ¶
func (w DelimitedWriter) PutProto(msg proto.Message) error
PutProto encodes and writes the specified proto.Message to the writer.
func (DelimitedWriter) WriteRecord ¶
func (w DelimitedWriter) WriteRecord(record []byte) (int, error)
WriteRecord writes the specified record to the underlying writer, returning the total number of bytes written including the length tag.
type GobReader ¶
type GobReader struct {
// contains filtered or unexported fields
}
GobReader allows us to read gob encoded streams
type GobWriter ¶
type GobWriter struct {
// contains filtered or unexported fields
}
GobWriter implements SegmentWriter. It writes segments that are gob encoded to a given output stream
type Reader ¶
Reader interface allows callers to read a stream of protocol messages
func NewGobReader ¶
NewGobReader returns a codec.Reader capable of reading golang/gob encoded messages from input streams
type Writer ¶
Writer interface allows callers to write the protocol messages to a sink
func NewGobWriter ¶
NewGobWriter returns a codec.writer capable of emitting golang/gob encoded messages to the specified output