stream

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Consumer

type Consumer interface {
	Consume(io.Reader) error
}

Consumer is really only defined for symmetry with "Producer"; nothing actually uses it.

type ExternalRequest

type ExternalRequest struct {
	RequestParams  interface{}
	StreamProducer Producer
}

An ExternalRequest is anything that can create and then consume any stream. The request comes bundled with something that can produce a stream (io.Reader), and something that can read from that stream to populate some arbitrary data structure.

type Fake

type Fake struct {
	Bytes []byte
	// contains filtered or unexported fields
}

Fake is a predefined stream (set with Bytes).

func (*Fake) Close

func (producer *Fake) Close() error

Close does nothing, as there is no actual subprocess to close.

func (*Fake) Produce

func (producer *Fake) Produce() (io.Reader, io.Reader, error)

Produce a fake stream on stdout (and an empty stderr). Unlike a real stream, this does not call a subprocess --- instead it just provides a predefined stream (Bytes) to create an io.Reader for stdout. The stderr stream is empty.

type Producer

type Producer interface {
	// The first two io.Readers are expected to be the stdout and stderr streams
	// from the process, respectively.
	Produce() (io.Reader, io.Reader, error)
	Close() error
}

Producer is an interface for anything that can generate an io.Reader from which we can read from (typically JSON output).

type Subprocess

type Subprocess struct {
	CmdInvocation []string
	// contains filtered or unexported fields
}

Subprocess can spawn a subprocess and read from it. It can be used to read from an io.Reader that produces JSON, or whatever else.

func (*Subprocess) Close

func (sp *Subprocess) Close() error

Close the subprocess by waiting for it.

func (*Subprocess) Produce

func (sp *Subprocess) Produce() (io.Reader, io.Reader, error)

Produce runs the external process and returns two io.Readers (to stdout and stderr).

Jump to

Keyboard shortcuts

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