flunc

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2019 License: MIT Imports: 2 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Flunc

type Flunc func(context.Context) (context.Context, error)

A Flunc is a function that is able to run in a given context. It may manipulate the context by returning a new one.

func MakeFlunc added in v0.15.0

func MakeFlunc(f Flunc) Flunc

MakeFlunc turns an arbitrary function, that satisfies the signature of a Flunc into a function of type flunc.Flunc.

This is useful to do type assertions like ff, ok := f.(flunc.Func).

func Parallel

func Parallel(children ...Flunc) Flunc

Parallel executes the given Fluncs concurrently. Because of the nature of concurrency context manipulations are neither propagated to sibling nor to parent Fluncs. The first return value is always nil.

If a Flunc returns an error, the context handed to its sibling Fluncs is canceled (context.Context.Done is closed). Siblings should honor this and stop execution, although this is not enforced. The error is returned to the calling Flunc.

If more than one Flunc errors at a time, there is a race, which error gets to read first. Later errors will be lost.

func Sequential

func Sequential(children ...Flunc) Flunc

Sequential executes the given Fluncs one after the other. Context manipulations are propagated to later running Fluncs.

If a Flunc returns an error, execution of following Fluncs is canceled and the error is returned to the calling Flunc.

Jump to

Keyboard shortcuts

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