pipeline

package
v1.3.9 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package pipeline Package middleware define middlewares for Actions.

Package pipeline Package pipes provides generic errors for pipes to use.

Package pipeline Package skip can skip an entire Action.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsSkip

func IsSkip(err error) bool

IsSkip returns true if the error is an ErrSkip.

Types

type Action

type Action func(ctx context.ApplicationContext) error

Action is a function that takes a context and returns an error. It is used on Pipers, Defaulters and Publishers, although they are not aware of this generalization.

func Handle

func Handle(action Action) Action

Handle handles an action error, ignoring and logging pipe skipped errors.

func Log

func Log(title string, next Action) Action

Log pretty prints the given action and its title.

func Maybe

func Maybe(skipper interface{}, next Action) Action

Maybe returns an action that skips immediately if the given p is a Skipper and its Skip method returns true.

type ErrSkip

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

ErrSkip occurs when a pipe is skipped for some reason.

func Skip

func Skip(reason string) ErrSkip

Skip skips this pipe with the given reason.

func (ErrSkip) Error

func (e ErrSkip) Error() string

Error implements the error interface. returns the reason the pipe was skipped.

type Pipelines

type Pipelines interface {
	Execute() (context.ApplicationContext, error)
	Register(pipe ...Piper)
	// contains filtered or unexported methods
}

func NewPipelines

func NewPipelines(ctx context.ApplicationContext) Pipelines

type Piper

type Piper interface {
	fmt.Stringer
	Run(ctx context.ApplicationContext) error
}

Piper defines a pipes, which can be part of a pipeline (a series of pipes).

type SkipMemento

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

SkipMemento remembers previous skip errors, so you can return them all at once later.

func (*SkipMemento) Evaluate

func (sm *SkipMemento) Evaluate() error

Evaluate return a skip error with all previous skips, or nil if none happened.

func (*SkipMemento) Remember

func (sm *SkipMemento) Remember(err error)

Remember a skip.

func (*SkipMemento) Size

func (sm *SkipMemento) Size() int

Size gets the skip memento size

type Skipper

type Skipper interface {
	// Skip returns true if the Piper should be skipped.
	Skip(ctx context.ApplicationContext) bool
	fmt.Stringer
}

Skipper defines a method to skip an entire Piper.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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