jsonstream

package
v0.0.0-...-f2d3d7a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Formater

type Formater interface {
	// BegineWrite write some datas at the stream beginning.
	BeginWrite() ([]byte, error)

	// EndWrite write some datas at the stream ending.
	EndWrite() ([]byte, error)

	// Write write a object be serialized.
	Write(o interface{}) ([]byte, error)
}

Formater define the data's format via stream transfer.

type JSONStream

type JSONStream struct {
	// contains filtered or unexported fields
}

JSONStream represents a stream transfer, the data be encoded with json.

func New

func New(out io.Writer, f ...Formater) *JSONStream

New creates a 'JSONStream' instance and use a goroutine to recv/send data.

func (*JSONStream) Close

func (s *JSONStream) Close() error

Close closes the stream transfer.

func (*JSONStream) Wait

func (s *JSONStream) Wait()

Wait waits the stream to finish.

func (*JSONStream) WriteObject

func (s *JSONStream) WriteObject(obj interface{}) error

WriteObject writes a object to client via stream tranfer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL