runway

package module
v0.0.0-...-c28f065 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2022 License: BSD-3-Clause Imports: 4 Imported by: 0

README

Runway

Package runway starts coruotines in an ErrGroup and links them via channels.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Runway

type Runway struct {
	ChannelSize int
	// contains filtered or unexported fields
}

Runway starts coroutines and links them with channels.

func New

func New(group *errgroup.Group, channelSize int) *Runway[T]

New returns a new Runway.

func (*Runway[T]) AddOutput

func (e *Runway[T]) AddOutput(ctx context.Context, source Source[T])

AddOutput adds given Sources output to the begin of the next Source or Stage.

func (*Runway[T]) Group

func (e *Runway[T]) Group() *errgroup.Group

Group returns the err group of the Runway.

func (*Runway[T]) Guard

func (e *Runway[T]) Guard(w sync.WaitGroup)

Guard adds a delta to given WaitGroup and clears it after the next Source, Stage or Sink is done.

func (*Runway[T]) PopOutput

func (e *Runway[T]) PopOutput() <-chan T

PopOutput returns the output channel.

func (*Runway[T]) Sink

func (e *Runway[T]) Sink(ctx context.Context, step string, sink Sink[T])

Sink starts a go routine that sinks all Ts into given sink.

func (*Runway[T]) Source

func (e *Runway[T]) Source(ctx context.Context, stage string, source Source[T])

Consume reads the source into the editor.

func (*Runway[T]) Stage

func (e *Runway[T]) Stage(ctx context.Context, name string, f Stage[T])

Stage starts given stage in a new go routine.

func (*Runway[T]) StageInput

func (e *Runway[T]) StageInput() chan<- T

StageInput returns a new input channel.

func (*Runway[T]) Wait

func (e *Runway[T]) Wait(w sync.WaitGroup)

Wait blocks the next Source, Stage or Sink until the WaitGroup counter is zero.

type Sink

type Sink func(ctx context.Context, in <-chan T) error

Sink consumes Ts or return an error.

type Source

type Source func(ctx context.Context, out chan<- T) error

Source provides Ts or return an error.

type Stage

type Stage func(ctx context.Context, in <-chan T, out chan<- T) error

Stage modifies Ts or return an error.

Jump to

Keyboard shortcuts

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