flow

package module
v0.0.0-...-53148d6 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2022 License: MIT Imports: 6 Imported by: 0

README

goflow

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Next = errors.New("next")

Functions

This section is empty.

Types

type BuildFlow

type BuildFlow func() FlowHandler

func (BuildFlow) Build

func (bf BuildFlow) Build(in Inline) Inline

type BuildSink

type BuildSink func() SinkHandler

func (BuildSink) Build

func (bs BuildSink) Build(inline Inline) Runnable

type BuildSource

type BuildSource func() SourceHandler

func (BuildSource) Build

func (bs BuildSource) Build() Inline

type Command

type Command uint8
const (
	PULL Command = iota
	CANCEL
)

type Emittable

type Emittable interface {
	Emit(any)
	Close()
}

type EmittableInlet

type EmittableInlet interface {
	Inlet
	Emittable
}

type EmittableInline

type EmittableInline interface {
	Inline
	Emittable
}

type Event

type Event struct {
	Data     any
	Error    error
	Complete bool
}

func (Event) Type

func (e Event) Type() EventType

type EventType

type EventType uint8
const (
	PUSH EventType = iota
	ERROR
	COMPLETE
)

type FanInWorker

type FanInWorker func(Outline, ...Inline)

type Flow

type Flow struct {
	Pull     func(IOlet)
	Cancel   func(IOlet)
	Push     func(IOlet, any)
	Error    func(IOlet, error)
	Complete func(Outlet)
}

func (Flow) OnCancel

func (f Flow) OnCancel(io IOlet)

func (Flow) OnComplete

func (f Flow) OnComplete(o Outlet)

func (Flow) OnError

func (f Flow) OnError(io IOlet, e error)

func (Flow) OnPull

func (f Flow) OnPull(io IOlet)

func (Flow) OnPush

func (f Flow) OnPush(io IOlet, v any)

type FlowBuilder

type FlowBuilder interface {
	Build(Inline) Inline
}

type FlowBuilderFunc

type FlowBuilderFunc func(Inline) Inline

func (FlowBuilderFunc) Build

func (fbf FlowBuilderFunc) Build(in Inline) Inline

type FlowGraph

type FlowGraph interface {
	FlowBuilder
	Via(FlowBuilder) FlowGraph
	To(SinkBuilder) SinkBuilder
}

func Drop

func Drop(n uint64) FlowGraph

func DropWhile

func DropWhile[T any](f func(T) bool) FlowGraph

func Filter

func Filter[T any](f func(T) bool) FlowGraph

func FlowFunc

func FlowFunc[T, K any](f func(T) (K, error)) FlowGraph

func Fold

func Fold[T, K any](k K, f func(K, T) K) FlowGraph

func Map

func Map[T, K any](f func(T) K) FlowGraph

func Reduce

func Reduce[T any](f func(T, T) T) FlowGraph

func Take

func Take(n uint64) FlowGraph

func TakeWhile

func TakeWhile[T any](f func(T) bool) FlowGraph

type FlowGraphFunc

type FlowGraphFunc func() FlowBuilder

func (FlowGraphFunc) Build

func (fgf FlowGraphFunc) Build(in Inline) Inline

func (FlowGraphFunc) From

func (fgf FlowGraphFunc) From(source SourceBuilder) Graph

func (FlowGraphFunc) To

func (fgf FlowGraphFunc) To(sink SinkBuilder) SinkBuilder

func (FlowGraphFunc) Via

func (fgf FlowGraphFunc) Via(flow FlowBuilder) FlowGraph

type FlowHandler

type FlowHandler interface {
	OnPull(IOlet)
	OnCancel(IOlet)
	OnPush(IOlet, any)
	OnError(IOlet, error)
	OnComplete(Outlet)
}

type FlowHandlerFunc

type FlowHandlerFunc[T, K any] func(T) (K, error)

func (FlowHandlerFunc[T, K]) OnCancel

func (FlowHandlerFunc[T, K]) OnCancel(iolet IOlet)

func (FlowHandlerFunc[T, K]) OnComplete

func (FlowHandlerFunc[T, K]) OnComplete(outlet Outlet)

func (FlowHandlerFunc[T, K]) OnError

func (FlowHandlerFunc[T, K]) OnError(iolet IOlet, e error)

func (FlowHandlerFunc[T, K]) OnPull

func (FlowHandlerFunc[T, K]) OnPull(iolet IOlet)

func (FlowHandlerFunc[T, K]) OnPush

func (fhf FlowHandlerFunc[T, K]) OnPush(iolet IOlet, v any)

type Graph

type Graph interface {
	Runnable
	From(SourceBuilder) Graph
	Via(FlowBuilder) Graph
	To(SinkBuilder) Graph
}

func Join

func Join(sources ...SourceBuilder) Graph

func Merge

func Merge(sources ...SourceBuilder) Graph

func NewFanIn

func NewFanIn(worker FanInWorker, sources ...SourceBuilder) Graph

func Zip

func Zip(f func([]any) (any, error), sources ...SourceBuilder) Graph

type IOlet

type IOlet interface {
	Inlet
	Outlet
}

type Inlet

type Inlet interface {
	Pull()
	Cancel()
}

type InletChan

type InletChan chan<- Command

func (InletChan) Cancel

func (ic InletChan) Cancel()

func (InletChan) Pull

func (ic InletChan) Pull()

type Inline

type Inline interface {
	Inlet
	Close()
	Events() <-chan Event
}

type Outlet

type Outlet interface {
	Push(any)
	Error(error)
	Complete()
}

type OutletChan

type OutletChan chan<- Event

func (OutletChan) Complete

func (oc OutletChan) Complete()

func (OutletChan) Error

func (oc OutletChan) Error(e error)

func (OutletChan) Push

func (oc OutletChan) Push(v any)

type Outline

type Outline interface {
	Outlet
	Commands() <-chan Command
}

type Pipe

type Pipe interface {
	Inline
	Outline
}

type Runnable

type Runnable interface {
	Await() error
	AwaitWithContext(context.Context) error
	Run() <-chan any
	RunWithContext(context.Context) <-chan any
	Execute() (any, error)
	ExecuteWithContext(context.Context) (any, error)
}

type SinkBuilder

type SinkBuilder interface {
	Build(Inline) Runnable
}

func Empty

func Empty() SinkBuilder

func ForEach

func ForEach[T any](f func(T)) SinkBuilder

func Printf

func Printf(format string) SinkBuilder

func Println

func Println() SinkBuilder

func SinkFunc

func SinkFunc[T any](f func(T) error) SinkBuilder

type SinkBuilderFunc

type SinkBuilderFunc func(Inline) Runnable

func (SinkBuilderFunc) Build

func (sbf SinkBuilderFunc) Build(in Inline) Runnable

type SinkHandler

type SinkHandler interface {
	OnPush(EmittableInlet, any)
	OnError(EmittableInlet, error)
	OnComplete(Emittable)
}

type SinkHandlerFunc

type SinkHandlerFunc[T any] func(T) error

func (SinkHandlerFunc[T]) OnComplete

func (SinkHandlerFunc[T]) OnComplete(emittable Emittable)

func (SinkHandlerFunc[T]) OnError

func (SinkHandlerFunc[T]) OnError(inlet EmittableInlet, e error)

func (SinkHandlerFunc[T]) OnPush

func (shf SinkHandlerFunc[T]) OnPush(inlet EmittableInlet, v any)

type SourceBuilder

type SourceBuilder interface {
	Build() Inline
}

type SourceBuilderFunc

type SourceBuilderFunc func() Inline

func (SourceBuilderFunc) Build

func (sbf SourceBuilderFunc) Build() Inline

type SourceGraph

type SourceGraph interface {
	SourceBuilder
	Graph
}

func Slice

func Slice[T any](slice []T) SourceGraph

func SourceFunc

func SourceFunc[T any](f func() (T, error)) SourceGraph

func ZeroSource

func ZeroSource() SourceGraph

type SourceGraphFunc

type SourceGraphFunc func() SourceBuilder

func (SourceGraphFunc) Await

func (sg SourceGraphFunc) Await() error

func (SourceGraphFunc) AwaitWithContext

func (sg SourceGraphFunc) AwaitWithContext(ctx context.Context) error

func (SourceGraphFunc) Build

func (sg SourceGraphFunc) Build() Inline

func (SourceGraphFunc) Execute

func (sg SourceGraphFunc) Execute() (any, error)

func (SourceGraphFunc) ExecuteWithContext

func (sg SourceGraphFunc) ExecuteWithContext(ctx context.Context) (any, error)

func (SourceGraphFunc) From

func (sg SourceGraphFunc) From(source SourceBuilder) Graph

func (SourceGraphFunc) Run

func (sg SourceGraphFunc) Run() <-chan any

func (SourceGraphFunc) RunWithContext

func (sg SourceGraphFunc) RunWithContext(ctx context.Context) <-chan any

func (SourceGraphFunc) To

func (sg SourceGraphFunc) To(sink SinkBuilder) Graph

func (SourceGraphFunc) Via

func (sg SourceGraphFunc) Via(flow FlowBuilder) Graph

type SourceHandler

type SourceHandler interface {
	OnPull(Outlet)
	OnCancel(Outlet)
}

type SourceHandlerFunc

type SourceHandlerFunc[T any] func() (T, error)

func (SourceHandlerFunc[T]) OnCancel

func (SourceHandlerFunc[T]) OnCancel(outlet Outlet)

func (SourceHandlerFunc[T]) OnPull

func (shf SourceHandlerFunc[T]) OnPull(outlet Outlet)

type StartFunc

type StartFunc func() (<-chan any, context.CancelFunc)

Jump to

Keyboard shortcuts

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