gocess

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2022 License: GPL-3.0 Imports: 3 Imported by: 1

README

gocess

a simple lib to split work as manageable units

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoProcess

type GoProcess[T any] struct {
	Steps []Step[T]
}

GoProcess is a bunch of steps that are executed in sequence.

func NewGoProcess

func NewGoProcess[T any](steps ...Step[T]) *GoProcess[T]

NewGoProcess creates a new GoProcess.

func (*GoProcess[T]) AddStep added in v0.0.2

func (p *GoProcess[T]) AddStep(step Step[T])

AddStep adds a step to a defined GoProcess

func (*GoProcess[T]) Execute

func (p *GoProcess[T]) Execute(ctx context.Context, input T) (T, error)

Execute will execute the steps in the process.

type MockProcess added in v0.0.3

type MockProcess[T interface{}] struct {
	mock.Mock
}

MockProcess is an autogenerated mock type for the Process type

func NewMockProcess added in v0.0.3

func NewMockProcess[T interface{}](t mockConstructorTestingTNewMockProcess) *MockProcess[T]

NewMockProcess creates a new instance of MockProcess. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*MockProcess[T]) Execute added in v0.0.3

func (_m *MockProcess[T]) Execute(ctx context.Context, input T) (T, error)

Execute provides a mock function with given fields: ctx, input

type MockStep

type MockStep[T interface{}] struct {
	mock.Mock
}

MockStep is an autogenerated mock type for the Step type

func NewMockStep added in v0.0.3

func NewMockStep[T interface{}](t mockConstructorTestingTNewMockStep) *MockStep[T]

NewMockStep creates a new instance of MockStep. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*MockStep[T]) Execute

func (_m *MockStep[T]) Execute(ctx context.Context, input T) (T, error)

Execute provides a mock function with given fields: ctx, input

type Process

type Process[T any] interface {
	Execute(ctx context.Context, input T) (T, error)
}

Process is a collection of steps.

type Step

type Step[T any] interface {
	Execute(ctx context.Context, input T) (T, error)
}

Step is a single step in a process.

func NewStepFromFunction added in v0.0.4

func NewStepFromFunction[T any](f func(ctx context.Context, input T) (T, error)) Step[T]

NewStepFromFunction allows to create an empty step structure to allow execution of simple steps as Step. will execute passed f function when called.

func ParallelSteps

func ParallelSteps[T any](m merger[T], array ...Step[T]) Step[T]

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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