stream

package
v0.10.9 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2022 License: Apache-2.0 Imports: 2 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ReadStream

type ReadStream interface {
	// Receive receives the next result
	Receive() (Result, bool)

	// Drain drains the stream
	Drain()
}

ReadStream is a state machine read stream

type Result

type Result struct {
	Value interface{}
	Error error
}

Result is a stream result

func (Result) Failed

func (r Result) Failed() bool

Failed returns a boolean indicating whether the operation failed

func (Result) Succeeded

func (r Result) Succeeded() bool

Succeeded returns a boolean indicating whether the operation was successful

type Stream

type Stream interface {
	ReadStream
	WriteStream
}

Stream is a read/write stream

func NewBufferedStream

func NewBufferedStream() Stream

NewBufferedStream returns a new buffered read/write stream

func NewChannelStream

func NewChannelStream(ch chan Result) Stream

NewChannelStream returns a new channel-based stream

func NewUnaryStream

func NewUnaryStream() Stream

NewUnaryStream returns a new read/write stream that expects one result

type WriteStream

type WriteStream interface {
	// Send sends an output on the stream
	Send(out Result)

	// Result sends a result on the stream
	Result(value interface{}, err error)

	// Value sends a value on the stream
	Value(value interface{})

	// Error sends an error on the stream
	Error(err error)

	// Close closes the stream
	Close()
}

WriteStream is a state machine write stream

func NewCloserStream

func NewCloserStream(stream WriteStream, f func(WriteStream)) WriteStream

NewCloserStream returns a new stream that runs a function on close

func NewDecodingStream

func NewDecodingStream(stream WriteStream, encoder func(interface{}, error) (interface{}, error)) WriteStream

NewDecodingStream returns a new decoding stream

func NewEncodingStream

func NewEncodingStream(stream WriteStream, encoder func(interface{}, error) (interface{}, error)) WriteStream

NewEncodingStream returns a new encoding stream

func NewNilStream

func NewNilStream() WriteStream

NewNilStream returns a disconnected stream

Jump to

Keyboard shortcuts

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