stream

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package stream contains the main logic for handling actions within a stream, such as reading the lines retrieved, setting up the command to run, and executing the command.

Index

Constants

This section is empty.

Variables

View Source
var (
	// FieldDelim - regex that matches a field pattern.
	FieldDelim = `.*\#\{[0-9]*\}.*`
)
View Source
var (
	// LogDebug controls the logging level, when true the stream will
	// write logs to stdout.
	LogDebug = false
)

Functions

This section is empty.

Types

type Publisher added in v0.3.0

type Publisher interface {
	Publish(string)
	Err() error
	Close()
}

Publisher provides functions to publish to any subscribers of a stream.

func NewPublisher added in v0.3.0

func NewPublisher(s *Stream) Publisher

NewPublisher returns an encapsulated RW allowing the consumer to publish text to any subscribers.

type RW

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

RW implements the Subscriber and Publisher interfaces for a given Stream, allowing for communication between the interested parties.

func (*RW) Close

func (srw *RW) Close()

Close finishes the channel for any Subscribers.

func (*RW) Err

func (srw *RW) Err() error

Err returns any errors associated with the RW.

func (*RW) Publish

func (srw *RW) Publish(line string)

Publish sends a string to the channel that Subscribers will recieve.

func (*RW) Subscribe

func (srw *RW) Subscribe() chan string

Subscribe returns a channel where text will be sent unless closed.

type Stream

type Stream struct {
	Regexp *regexp.Regexp
	// contains filtered or unexported fields
}

Stream holds the information for the monitored stream.

func NewStream

func NewStream(pattern, cmd, delim, file string, args []string) (*Stream, error)

NewStream constructs a Stream for processing of a file. This calls the necessary field parsing functions before returning.

func (*Stream) ExecStreamComm

func (s *Stream) ExecStreamComm(matchLn string) error

ExecStreamComm is called with a matched line from the Stream, and executes the command for that stream.

type Subscriber added in v0.3.0

type Subscriber interface {
	Subscribe() chan string
	Err() error
	Close()
}

Subscriber provides functions for a consumer of the Stream's output to subscribe, ie. receive text coming through the stream.

func NewSubscriber added in v0.3.0

func NewSubscriber(s *Stream) Subscriber

NewSubscriber returns an encapsulated RW allowing the consumer to subscribe to text coming from the Stream.

Jump to

Keyboard shortcuts

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