datastream

package
v0.37.1 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2021 License: GPL-2.0, GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package datastream provides a composable data stream, which pipes multiple inputs to multiple outputs according to the defined compositions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ComposableDataStream

type ComposableDataStream struct {
	Name string
	// contains filtered or unexported fields
}

ComposableDataStream is a data stream that can be composed with other data streams

You can combine an arbitrary number of io.WriteCloser inputs and io.Reader outputs. Call Close when all compositions have been defined. This will start the data flow. Once all data has been passed through (all inputs are closed), the data stream will complete.

func NewClosedComposableDataStreamFromBuffer

func NewClosedComposableDataStreamFromBuffer(buffer *bytes.Buffer) *ComposableDataStream

NewClosedComposableDataStreamFromBuffer creates an already closed ComposableDataStream with the specified result

func NewComposableDataStream

func NewComposableDataStream(name string, errorHandler func(error)) *ComposableDataStream

NewComposableDataStream creates a new ComposableDataStream

name is a description of the data stream for debugging convenience

func (*ComposableDataStream) Bytes

func (stream *ComposableDataStream) Bytes() []byte

Bytes returns the result of a completed data stream as a byte slice

If you call Bytes before the data stream has completed, the result is undefined.

func (*ComposableDataStream) Close

func (stream *ComposableDataStream) Close()

Close finalizes the data stream

It should be called when all compositions have been defined in order to start the data flow. It is a prerequisite for the data stream to complete.

func (*ComposableDataStream) Closed

func (stream *ComposableDataStream) Closed() bool

Closed indicates whether the data stream has been closed

func (*ComposableDataStream) Completed

func (stream *ComposableDataStream) Completed() bool

Completed indicates whether the data stream has completed

func (*ComposableDataStream) Copy

func (stream *ComposableDataStream) Copy() io.Reader

Copy provides all data passing through the data stream through the io.Reader interface

This function should not be called on closed data streams. You should read all data until io.EOF to prevent deadlocks.

func (*ComposableDataStream) Intercept

Intercept provides a way of reading and manipulating all data passing through the data stream

The data stream's input is available through the intercept's io.Reader interface. You should read all input data provided in this way (until io.EOF) to prevent deadlocks. The intercepted data stream's output will be replaced completely by the data written to the io.Writer interface. You must close the data stream when you have written all output data through the io.Writer.

func (*ComposableDataStream) Len

func (stream *ComposableDataStream) Len() int

Len returns the size of the result of a completed data stream in number of bytes

If you call Len before the data stream has completed, the result is undefined.

func (*ComposableDataStream) MergeWith

func (stream *ComposableDataStream) MergeWith(newReader io.Reader)

MergeWith combines the data passing through the data stream with the data provided by an io.Reader

func (*ComposableDataStream) Replace

func (stream *ComposableDataStream) Replace(reader io.Reader)

Replace replaces the data passing through the data stream with the data provided by an io.Reader

func (*ComposableDataStream) StartCopyingInto

func (stream *ComposableDataStream) StartCopyingInto(writer io.Writer)

StartCopyingInto writes the data passing through the data stream into the provided io.Writer

Call Wait on the data stream to ensure that the writes have completed.

func (*ComposableDataStream) String

func (stream *ComposableDataStream) String() string

String returns the result of a completed data stream as a string

If you call String before the data stream has completed, the result is undefined.

func (*ComposableDataStream) Wait

func (stream *ComposableDataStream) Wait()

Wait pauses execution until the data stream has completed

func (*ComposableDataStream) WriteCloser

func (stream *ComposableDataStream) WriteCloser() io.WriteCloser

WriteCloser creates an io.WriteCloser that allows for additional data to be written into the data stream

The data will be appended to the end of any existing data that might be passing through the data stream. You must close the io.WriteCloser once you have finished writing to it.

type ComposableDataStreamIntercept

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

ComposableDataStreamIntercept is a structure for intercepting and manipulating data passed through a data stream

func (*ComposableDataStreamIntercept) Close

func (intercept *ComposableDataStreamIntercept) Close() error

Close closes the data stream intercept to indicate that all data has been written

func (*ComposableDataStreamIntercept) CloseWithError added in v0.34.0

func (intercept *ComposableDataStreamIntercept) CloseWithError(err error) error

func (*ComposableDataStreamIntercept) Read

func (intercept *ComposableDataStreamIntercept) Read(p []byte) (int, error)

func (*ComposableDataStreamIntercept) Write

func (intercept *ComposableDataStreamIntercept) Write(p []byte) (int, error)

type WriteCloserWithError added in v0.34.0

type WriteCloserWithError = interface {
	io.WriteCloser
	CloseWithError(err error) error
}

Jump to

Keyboard shortcuts

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