pipe

package
v0.37.1 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2021 License: GPL-2.0, GPL-3.0 Imports: 5 Imported by: 0

README

pipe - Invocation Chainer

The pipe middleware chains pipes together, so that the output of one pipe becomes the input of another. It is asynchronous in the sense that all pipes will be invoked in sequence, but the execution happens in parallel. In other words, pipes can process their input as it becomes available and do not need to wait for previous pipes to finish before they can start executing. If you are familiar with linux pipes, this is probably what you would expect.

Arguments

The pipe middleware takes an array argument, whose items are called children. The calling pipe is called the parent.

Each child can be referenced either by a string (referring to a definition located elsewhere) or a map containing additional arguments (in which case the definition is optional). Any additional arguments provided in the invocation take precedence over the default arguments in the pipe's definition.

private:
    parent-pipe:
        pipe:
            # a child can be referenced by a string
            # the input of `child-pipe-1` will be the output of `parent-pipe`
            - child-pipe-1
            # or a map with additional arguments
            # the input of `child-pipe-2` will be the output of `child-pipe-1`
            - child-pipe-2:
                invocation: arguments
            # in which case defining the pipe in another place is optional
            # the input of `child-pipe-3` will be the output of `child-pipe-2`
            - child-pipe-3:
                invocation: arguments
    # the (stdout) output of `parent-pipe` will be the output of `child-pipe-3`
    # the stderr output of `parent-pipe` will also be the stderr output of `child-pipe-3`

    # define the behavior of the child pipes
    child-pipe-1:
        # default arguments may be overwritten by invocation arguments
        default: arguments

    child-pipe-2:
        # default arguments may be overwritten by invocation arguments
        default: arguments

Documentation

Overview

Package pipe provides a middleware to execute several commands in sequence

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Middleware added in v0.32.2

type Middleware struct{}

Middleware is an invocation chainer

func NewMiddleware added in v0.32.2

func NewMiddleware() Middleware

NewMiddleware creates a new middleware instance

func (Middleware) Apply added in v0.32.2

func (pipeMiddleware Middleware) Apply(
	run *pipeline.Run,
	next func(pipelineRun *pipeline.Run),
	executionContext *middleware.ExecutionContext,
)

Apply is where the middleware's logic resides

It adapts the run based on its slice of the run's arguments. It may also trigger side effects such as executing shell commands or full runs of other pipelines. When done, this function should call next in order to continue unwinding the stack.

func (Middleware) String added in v0.32.2

func (pipeMiddleware Middleware) String() string

Jump to

Keyboard shortcuts

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