state

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Ready states that pipe can be started.
	Ready ready
	// Running states that pipe is executing at the moment and can be paused.
	Running running
	// Paused states that pipe is paused and can be resumed.
	Paused paused
)

states variables

View Source
var (
	// ErrInvalidState is returned if pipe method cannot be executed at this moment.
	ErrInvalidState = fmt.Errorf("invalid state")
)

Functions

func Loop

func Loop(h *Handle, s State)

Loop listens until nil state is returned.

Types

type Handle

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

Handle manages the lifecycle of the pipe.

func NewHandle

func NewHandle(start StartFunc, newMessage NewMessageFunc, pushParams PushParamsFunc) *Handle

NewHandle returns new initalized handle that can be used to manage lifecycle.

func (*Handle) Pause added in v0.6.0

func (h *Handle) Pause() chan error

Pause sends a pause event into handle.

func (*Handle) Push added in v0.6.0

func (h *Handle) Push(params Params)

Push new params into handle.

func (*Handle) Resume added in v0.6.0

func (h *Handle) Resume() chan error

Resume sends a resume event into handle.

func (*Handle) Run added in v0.6.0

func (h *Handle) Run(ctx context.Context, bufferSize int) chan error

Run sends a run event into handle.

func (*Handle) Stop added in v0.6.0

func (h *Handle) Stop() chan error

Stop sends a stop event into handle.

type NewMessageFunc

type NewMessageFunc func(pipeID string)

NewMessageFunc is the closure to send a message into a pipe.

type Params

type Params map[string][]func()

Params represent a set of parameters mapped to ID of their receivers.

func (Params) Add

func (p Params) Add(id string, fns ...func()) Params

Add appends a slice of Params.

func (Params) Append

func (p Params) Append(source Params) Params

Append param set to another set.

func (Params) ApplyTo

func (p Params) ApplyTo(id string)

ApplyTo consumes Params defined for consumer in this param set.

func (Params) Detach

func (p Params) Detach(id string) Params

Detach params for provided component id.

type PushParamsFunc

type PushParamsFunc func(params Params)

PushParamsFunc is the closure to push new params into pipe.

type StartFunc

type StartFunc func(bufferSize int, cancel <-chan struct{}, give chan<- string) []<-chan error

StartFunc is the closure to trigger the start of a pipe.

type State

type State interface {
	fmt.Stringer
	// contains filtered or unexported methods
}

State identifies one of the possible states pipe can be in.

Jump to

Keyboard shortcuts

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