helpers

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: MIT Imports: 5 Imported by: 1

Documentation

Overview

Package helpers provides some utility functions for asyncmachine, which are out of scope of the main package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrFromCtxs

func ErrFromCtxs(ctxs ...context.Context) error

ErrFromCtxs returns the first non-nil error from a list of contexts.

func IndexesToStates

func IndexesToStates(mach *am.Machine, indexes []int) am.S

IndexesToStates converts a list of state indexes to a list of state names, for a given machine.

func NestedState

func NestedState(
	e *am.Event, strIDField string, machGetter func(id string) *am.Machine,
) (am.Result, <-chan struct{}, error)

NestedState forwards the mutation to one of the composed submachines. Parent state should be a Multi state and only called directly (not from a relation). TODO test case, solve locking by passing the event to the submachine

func RaceCtx

func RaceCtx[T *any](ctx context.Context, ch chan T) (T, error)

func StatesToIndexes

func StatesToIndexes(mach *am.Machine, states am.S) []int

StatesToIndexes converts a list of state names to a list of state indexes, for a given machine.

func TimeMatrix

func TimeMatrix(machines []*am.Machine) ([]am.T, error)

TimeMatrix returns a matrix of state clocks for the given machines.

Types

This section is empty.

Jump to

Keyboard shortcuts

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