Documentation ¶
Index ¶
- func EmptyNext[T any](param T) error
- type Callback
- type ChainedCommand
- type DataFlow
- func (d *DataFlow[T]) ChainedCommand(param T, next Next[T]) error
- func (d *DataFlow[T]) Run(param T) (err error)
- func (d *DataFlow[T]) WithAbortCallback(callback Callback[T]) *DataFlow[T]
- func (d *DataFlow[T]) WithErrorCallback(callback ErrorCallback[T]) *DataFlow[T]
- func (d *DataFlow[T]) WithSuccessCallback(callback Callback[T]) *DataFlow[T]
- func (d *DataFlow[T]) WithTerminationCallback(callback Callback[T]) *DataFlow[T]
- type ErrorCallback
- type Next
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Callback ¶
type Callback[T any] func(param T)
Callback represents the interface for the callback functions.
type ChainedCommand ¶
ChainedCommand represents the interface for the callbacks used in a DataFlow.
type DataFlow ¶
type DataFlow[T any] struct { // contains filtered or unexported fields }
DataFlow represents a chain of commands where the next command gets executed by the previous one passing on a common object holding the shared state. The recursive nature of the calls causes acquired resources (e.g. CachedObjects) to be held until the full data flow terminates.
This allows us to pass through unwrapped objects in most of the business logic which relaxes the stress on the caching layer and makes the code less verbose.
func New ¶
func New[T any](commands ...ChainedCommand[T]) (dataFlow *DataFlow[T])
New creates a new DataFlow from the given ChainedCommands.
func (*DataFlow[T]) ChainedCommand ¶
ChainedCommand is a method that exposes the DataFlow as a ChainedCommand - use without calling it (without parentheses).
func (*DataFlow[T]) Run ¶
Run executes the DataFlow with the given parameter. It aborts execution and returns an error if any of the chained commands returns an error.
Note: A DataFlow can only be run a single.
func (*DataFlow[T]) WithAbortCallback ¶
WithAbortCallback modifies the DataFlow to execute a callback after it has been aborted.
func (*DataFlow[T]) WithErrorCallback ¶
func (d *DataFlow[T]) WithErrorCallback(callback ErrorCallback[T]) *DataFlow[T]
WithErrorCallback modifies the DataFlow to execute a callback after it has ended with an error.
func (*DataFlow[T]) WithSuccessCallback ¶
WithSuccessCallback modifies the DataFlow to execute a callback after all its commands have been executed.
func (*DataFlow[T]) WithTerminationCallback ¶
WithTerminationCallback modifies the DataFlow to execute a callback after it has terminated.
type ErrorCallback ¶
ErrorCallback represents the interface for the error callback functions.