stream

package
v0.0.0-...-baca244 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSimpleDatapack

func NewSimpleDatapack(ctx context.Context, r io.ReadCloser) *simpleDatapack

Types

type Datapack

type Datapack interface {
	Context() context.Context
	ReadCloser() io.ReadCloser
}

Datapack is a io.ReadCloser with some extra info.

type DatapackProducer

type DatapackProducer interface {
	Next() (datapack Datapack, hasNext bool, err error)
}

type ErrorPasser

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

func NewClosedErrorPasser

func NewClosedErrorPasser(errs ...error) *ErrorPasser

func NewErrorPasser

func NewErrorPasser() *ErrorPasser

func NewErrorPasserWithCap

func NewErrorPasserWithCap(maxErrCnt int) *ErrorPasser

func (*ErrorPasser) Cap

func (e *ErrorPasser) Cap() int

func (*ErrorPasser) Check

func (e *ErrorPasser) Check() (err error, done bool)

Check try get err in a non-block way. NOTE: if done, err is nil.

func (*ErrorPasser) Close

func (e *ErrorPasser) Close()

func (*ErrorPasser) Get

func (e *ErrorPasser) Get() error

func (*ErrorPasser) Put

func (e *ErrorPasser) Put(err error)

type IOStream

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

IOStream is a stream of Datapack.

func NewClosedIOStream

func NewClosedIOStream(datapacks ...Datapack) *IOStream

func NewIOStream

func NewIOStream() *IOStream

func NewIOStreamWithCap

func NewIOStreamWithCap(maxDatapackCnt int) *IOStream

func (*IOStream) Close

func (s *IOStream) Close()

func (*IOStream) Read

func (s *IOStream) Read() (data Datapack, streamClosed bool)

func (*IOStream) TryRead

func (s *IOStream) TryRead() (data Datapack, streamClosed bool)

TryRead try read datapack in a non-block way. NOTE: if streamClosed, data is nil

func (*IOStream) Write

func (s *IOStream) Write(data Datapack) (streamClosed bool)

type Processor

type Processor func(inputStream *IOStream, inputErr *ErrorPasser) (outputStream *IOStream, outputErr *ErrorPasser)

Processor is a function which handles input stream and send result into output stream. WARN: inputStream / inputErr should be closed by the previous Processor, while outputStream / outputErr should be closed by the current one.

func BuildProcChain

func BuildProcChain(procs ...Processor) Processor

func (Processor) Next

func (cur Processor) Next(next Processor) Processor

type SafeIOStreamHandler

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

func NewSafeIOStreamHandler

func NewSafeIOStreamHandler(
	inputStream *IOStream,
	inputErr *ErrorPasser,
	handler func(context.Context, io.ReadCloser) error,
	finalizer func(),
) *SafeIOStreamHandler

func (*SafeIOStreamHandler) BuildStream

func (s *SafeIOStreamHandler) BuildStream() (*IOStream, *ErrorPasser)

func (*SafeIOStreamHandler) Start

func (s *SafeIOStreamHandler) Start()

type SafeIOStreamWriter

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

func NewSafeIOStreamWriter

func NewSafeIOStreamWriter(p DatapackProducer) *SafeIOStreamWriter

func (*SafeIOStreamWriter) Start

func (s *SafeIOStreamWriter) Start() (*IOStream, *ErrorPasser)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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