flowctl

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNegativeWindowUpdate  = errors.New("invalid window update, negative value")
	ErrFlowWindowIncOverflow = errors.New("invalid inc, flow control window overflow")
	ErrFlowControlUnderflow  = errors.New("invalid data, flow control window underflow")
)
View Source
var (
	ErrClosedBuffer = errors.New("buffer was closed")
)

Functions

This section is empty.

Types

type RxBuffer

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

func NewRxBuffer

func NewRxBuffer(initWindow int32) *RxBuffer

func (*RxBuffer) CloseWithErr

func (l *RxBuffer) CloseWithErr(err error)

Close this buffer. Unblock any blocked ops. The [err] will pass to all blocked called. If [err] is nil, the default error is io.EOF

func (*RxBuffer) IncWindow

func (l *RxBuffer) IncWindow(d int32) RxStatus

func (*RxBuffer) Read

func (l *RxBuffer) Read(p []byte) (stat RxStatus, n int, err error)

func (*RxBuffer) ReadChunk

func (l *RxBuffer) ReadChunk(r io.Reader, limit int) (stat RxStatus, n int, err error)

Call r.Read() with inner buffer chunk. If limit > 0, then the read buffer will not larger than the limit.

func (*RxBuffer) SetMaxWindow

func (l *RxBuffer) SetMaxWindow(d int32) RxStatus

func (*RxBuffer) Status

func (l *RxBuffer) Status() RxStatus

func (*RxBuffer) WriteChunk

func (l *RxBuffer) WriteChunk(w io.Writer) (stat RxStatus, n int, err error)

Write one chunk to w. If there is nothing to write, it blocks until more data is available or l.CloseRead() was called.

type RxStatus

type RxStatus struct {
	WindowMax      int32
	WindowRemained int32
	Size           int32
}

type TxCtrl

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

func NewTxCtrl

func NewTxCtrl(initWindow int32) *TxCtrl

func (*TxCtrl) CloseWithErr

func (c *TxCtrl) CloseWithErr(err error)

If err == nil, the close err will be io.EOF.

func (*TxCtrl) ConsumeWindow

func (c *TxCtrl) ConsumeWindow(n int32) (int32, error)

ConsumeWindow tries to consume n bytes window. It will consume less than n window size if the available size is small than n. It blocks if window size is zero. If c was closed, it returns with an error. Concurrent safe.

func (*TxCtrl) IncWindow

func (c *TxCtrl) IncWindow(i int32) error

Returns ErrFlowWindowOverflow if window was overflowed. ErrNegativeWindowUpdate if i < 0.

Jump to

Keyboard shortcuts

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