payload

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: BSD-3-Clause Imports: 13 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error interface {
	Error() string
	Temporary() bool
}

Error is payload error.

type OpError

type OpError struct {
	Op  string
	Err error
}

OpError is operation error.

func (*OpError) Error

func (e *OpError) Error() string

func (*OpError) Temporary

func (e *OpError) Temporary() bool

Temporary returns true if error can retry.

type Payload

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

Payload does encode or decode to payload protocol.

func New

func New(supportBinary bool) *Payload

New returns a new payload.

func (*Payload) Close

func (p *Payload) Close() error

Close closes the payload. It can call in multi-goroutine.

func (*Payload) FeedIn

func (p *Payload) FeedIn(r io.Reader, supportBinary bool) error

FeedIn feeds in a new reader for NextReader. Multi-FeedIn needs be called sync.

If Close called when FeedIn, it returns io.EOF. If have Pause-ed when FeedIn, it returns ErrPaused. If NextReader has timeout, it returns ErrTimeout. If read error while FeedIn, it returns read error.

func (*Payload) FlushOut

func (p *Payload) FlushOut(w io.Writer) error

FlushOut write data from NextWriter. FlushOut needs be called sync.

If Close called when Flushout, it return io.EOF. If Pause called when Flushout, it flushs out a NOOP message and return nil. If NextWriter has timeout, it returns ErrTimeout. If write error while FlushOut, it returns write error.

func (*Payload) NextReader

func (p *Payload) NextReader() (frame.Type, packet.Type, io.ReadCloser, error)

NextReader returns a reader for next frame. NextReader and SetReadDeadline needs be called sync.

If Close called when NextReader, it return io.EOF. Pause doesn't effect to NextReader. NextReader should wait till resumed and next FeedIn.

func (*Payload) NextWriter

func (p *Payload) NextWriter(ft frame.Type, pt packet.Type) (io.WriteCloser, error)

NextWriter returns a writer for next frame. NextWriter and SetWriterDeadline needs be called sync. NextWriter will wait a FlushOut call, then it returns WriteCloser which encode package to FlushOut's Writer.

If Close called when NextWriter, it returns io.EOF. If beyond the time set by SetWriteDeadline, it returns ErrTimeout. If Pause called when NextWriter, it returns ErrPaused.

func (*Payload) Pause

func (p *Payload) Pause()

Pause pauses the payload. It will wait all reader and writer closed which created from NextReader or NextWriter. It can call in multi-goroutine.

func (*Payload) Resume

func (p *Payload) Resume()

Resume resumes the payload. It can call in multi-goroutine.

func (*Payload) SetReadDeadline

func (p *Payload) SetReadDeadline(t time.Time) error

SetReadDeadline sets next reader deadline. NextReader and SetReadDeadline needs be called sync. NextReader will wait a FeedIn call, then it returns ReadCloser which decodes packet from FeedIn's Reader.

If Close called when SetReadDeadline, it return io.EOF. If beyond the time set by SetReadDeadline, it returns ErrTimeout. Pause doesn't effect to SetReadDeadline.

func (*Payload) SetWriteDeadline

func (p *Payload) SetWriteDeadline(t time.Time) error

SetWriteDeadline sets next writer deadline. NextWriter and SetWriteDeadline needs be called sync.

If Close called when SetWriteDeadline, it return io.EOF. Pause doesn't effect to SetWriteDeadline.

func (*Payload) Store

func (p *Payload) Store(op string, err error) error

Store stores a error in payload, and block all other request.

Jump to

Keyboard shortcuts

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