smn_stream

package
v0.0.0-...-8887d1c Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ErrRepeatExecution            = "RepeatExecution"
	ErrRequestSizeLargerThanCache = "ErrRequestSizeLargerThanCache"
	ErrTimeOut                    = "ErrTimeOut"
)
View Source
const ErrByteCacheClosed = "ErrByteCacheClosed"

ErrByteCacheClosed try call a closed ByteCache.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByteCache

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

ByteCache .

func NewByteCache

func NewByteCache(writeTime int, timeout time.Duration) *ByteCache

NewByteCache .

func (*ByteCache) Close

func (cache *ByteCache) Close()

Close .

func (*ByteCache) ErrorClose

func (cache *ByteCache) ErrorClose(err error)

ErrorClose .

func (*ByteCache) Len

func (cache *ByteCache) Len() int

Len .

func (*ByteCache) Read

func (cache *ByteCache) Read(b []byte) (n int, err error)

Read .

func (*ByteCache) SetTimeOut

func (cache *ByteCache) SetTimeOut(t time.Duration)

SetTimeOut how much time can wait.

func (*ByteCache) Write

func (cache *ByteCache) Write(msg []byte)

Write .

type ConditionFunc

type ConditionFunc func(inp []byte) error

type ReadPipeline

type ReadPipeline struct {
	BuffSize  int //the size when read from reader.
	CacheSize int //the size save in chan.

	ErrChan chan error
	TimeOut time.Duration
	// contains filtered or unexported fields
}

func NewFileReadPipeline

func NewFileReadPipeline(fname string) (*ReadPipeline, error)

func NewReadPipeline

func NewReadPipeline(reader io.Reader, closer io.Closer) *ReadPipeline

func (*ReadPipeline) ByteBreakRead

func (this *ReadPipeline) ByteBreakRead(condition ...byte) (res []byte, err error)

func (*ReadPipeline) Capture

func (this *ReadPipeline) Capture() error

func (*ReadPipeline) ConditionRead

func (this *ReadPipeline) ConditionRead(condition ConditionFunc) (res []byte, err error)

func (*ReadPipeline) Read

func (this *ReadPipeline) Read(buff []byte) (size int, err error)

func (*ReadPipeline) RemainingSize

func (this *ReadPipeline) RemainingSize() int64

type ReadPipelineItf

type ReadPipelineItf interface {
	Capture() error
	RemainingSize() int64 //unknow return -1,
	Read(buff []byte) (int, error)
	ConditionRead(condition ConditionFunc) ([]byte, error) //
	ByteBreakRead(condition ...byte) ([]byte, error)       //when get byte, end read
}

Jump to

Keyboard shortcuts

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