workflow

package
v0.0.0-...-623dc82 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingFromContext = errors.New("missing from context")

Functions

func CapturePanic

func CapturePanic(ctx context.Context)

func GetStepID

func GetStepID(ctx context.Context) (uuid.UUID, error)

func Merge

func Merge[T any](ctx context.Context, req *T, responses ...*T) (*T, error)

func Name

func Name[T any](s Step[T]) string

func Parallel

func Parallel[T any](mid Mid[T], merge MergeRequest[T], steps ...Step[T]) *parallel[T]

Parallel executes a list of steps in parallel. Once all the steps are done, the merge request MergeRequest will combine all the results into one struct T.

func Series

func Series[T any](mid Mid[T], steps ...Step[T]) *series[T]

Series executes a series of steps in sequential order.

func SetIDGenerator

func SetIDGenerator(g IDGenerator)

SetIDGenerator allows to set a StaticID generator for testing purposes.

Types

type IDGenerator

type IDGenerator interface {
	ID() uuid.UUID
}

func GetIDGenerator

func GetIDGenerator() IDGenerator

type MergeRequest

type MergeRequest[T any] func(context.Context, *T, ...*T) (*T, error)

func MergeTransform

func MergeTransform[T any](t ...func(*mergo.Config)) MergeRequest[T]

type Mid

type Mid[T any] []Middleware[T]

type MidFunc

type MidFunc[T any] func(context.Context, *T) (*T, error)

func (MidFunc[T]) Run

func (f MidFunc[T]) Run(ctx context.Context, req *T) (*T, error)

type Middleware

type Middleware[T any] func(s Step[T]) Step[T]

type Pipeline

type Pipeline[T any] struct {
	Steps []Step[T]
	Mid[T]
}

func NewPipeline

func NewPipeline[T any](mid ...Middleware[T]) *Pipeline[T]

func (*Pipeline[T]) Run

func (p *Pipeline[T]) Run(ctx context.Context, req *T) (*T, error)

type Selector

type Selector[T any] func(context.Context, *T) bool

type StaticID

type StaticID struct{ sync.Mutex }

func (*StaticID) ID

func (g *StaticID) ID() uuid.UUID

ID returns a uuid.UUID starting at 1 in the form of "00000000-0000-0000-0000-000000000001". Each following calls increment by 1.

Note: It is meant for debugging and testing.

type Step

type Step[T any] interface {
	Run(context.Context, *T) (*T, error)
}

func Select

func Select[T any](mid Mid[T], s Selector[T], ifStep, elseStep Step[T]) Step[T]

type StepFunc

type StepFunc[T any] func(context.Context, *T) (*T, error)

func (StepFunc[T]) Run

func (f StepFunc[T]) Run(ctx context.Context, res *T) (*T, error)

func (StepFunc[T]) String

func (f StepFunc[T]) String() string

type UUIDv7

type UUIDv7 struct{ sync.Mutex }

func (*UUIDv7) ID

func (g *UUIDv7) ID() uuid.UUID

Jump to

Keyboard shortcuts

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