Documentation
¶
Overview ¶
Package stream implements a Reader and Writer for simple streams of either length-delimited byte records (using shipshape/util/delimited) or newline-delimited JSON values.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Reader ¶
type Reader interface { // Next returns the next record from the input, or io.EOF if there are no // more records available. // // The slice returned is valid only until a subsequent call to Next. Next() ([]byte, error) }
Reader provides sequential access to a stream of RPC values.
Usage:
rd := stream.NewReader(r, false) for { rec, err := rd.Next() if err == io.EOF { break } else if err != nil { log.Fatal(err) } doStuffWith(rec) }
type Writer ¶
type Writer interface { // Put writes the specified record to the Writer's stream. Put(data []byte) error }
A Writer outputs delimited records to an io.Writer.
Basic usage:
wr := stream.NewWriter(w, false) for record := range records { if err := wr.Put(record); err != nil { log.Fatal(err) } }
Click to show internal directories.
Click to hide internal directories.