gowfnet

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2020 License: MIT Imports: 3 Imported by: 0

README

gowfnet

Test Lint

The Golang implementation of Workflow networks.

Development

Use make for run lint and tests.

Status

The only minimal implementation is finished.

It's tested and works well. The Docs for this is in progress.

You can see examples in e2e tests.

Listener overwriting model

You can set the listener for the state in few ways according to next priority list from low to high.

  1. Set for the state.
  2. Set for the net.

The state store only one listener in time. If you set a listener for the state when you try to make an operation with a net than had a listener only the net's listener will be called.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSubject

func GetSubject(ctx context.Context) (interface{}, bool)

func SetSubject

func SetSubject(ctx context.Context, subj interface{}) context.Context

Types

type ListenerInterface

type ListenerInterface interface {
	BeforeStart(ctx context.Context) error
	AfterStart(ctx context.Context)
	BeforeTransition(ctx context.Context, transitionID string, state StateOpInterface) error
	AfterTransition(ctx context.Context, transitionID string, state StateOpInterface)
	HasStateListener() bool
	GetStateListener() state.ListenerInterface
}

type Net

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

func NewNet

func NewNet(config cfg.Interface) *Net

func (*Net) Start

func (n *Net) Start(ctx context.Context, s StateInterface) error

Start workflow net.

Use ctx for cancel operation and send subject of operation.

func (*Net) Transit

func (n *Net) Transit(ctx context.Context, s StateInterface, transitionID string) error

Transit to new places(state).

Use ctx for cancel operation and send subject of operation.

func (*Net) WithListener

func (n *Net) WithListener(listener ListenerInterface)

type StateInterface

type StateInterface interface {
	StateOpInterface
	WithListener(listener state.ListenerInterface)
	MoveTokensFromPlacesToPlaces(ctx context.Context, from []string, to []string) error
}

type StateOpInterface

type StateOpInterface interface {
	StateReadInterface
	SetFinished() error
	AddError(err error)
}

type StateReadInterface

type StateReadInterface interface {
	IsStarted() bool
	IsFinished() bool
	IsError() bool
	GetErrorStack() state.ErrStackInterface
	GetPlaces() []string
}

type StubListener

type StubListener struct{}

func NewStubListener

func NewStubListener() *StubListener

func (*StubListener) AfterStart

func (l *StubListener) AfterStart(ctx context.Context)

func (*StubListener) AfterTransition

func (l *StubListener) AfterTransition(ctx context.Context, transitionID string, state StateOpInterface)

func (*StubListener) BeforeStart

func (l *StubListener) BeforeStart(ctx context.Context) error

func (*StubListener) BeforeTransition

func (l *StubListener) BeforeTransition(ctx context.Context, transitionID string, state StateOpInterface) error

func (*StubListener) GetStateListener

func (l *StubListener) GetStateListener() state.ListenerInterface

func (*StubListener) HasStateListener

func (l *StubListener) HasStateListener() bool

Directories

Path Synopsis
cfg
validator
nolint:dupl nolint:dupl
nolint:dupl nolint:dupl
listener
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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