OnSignal<T extends DataObject, TState extends Enum, TSignal extends DataObject> class
final
Runs when a signal of type TSignal was sent for an element.
target tells which element (by id) a signal is meant for. The step runs as soon as that element is in one of the accept states and not busy. Until then the signal waits, which covers signals that arrive early or while another step runs for the element. A signal that was not applied within expireAfter is parked and logged as error.
A signal is applied once, but may be duplicated by its sender. The accept states are what protects from that: the handler SHOULD move the element out of them, otherwise it has to be idempotent.
OnSignal($PaymentSignal.bean,
accept: [InvoiceState.paymentRequested],
target: (signal) => signal.invoiceId,
handle: (step) async =>
step.element.copyWith(state: InvoiceState.paid)),
- Inheritance
-
- Object
- WorkflowStep<
T, TState> - OnSignal
Constructors
-
OnSignal(DataBean<
TSignal> signalBean, {required List<TState> accept, required Object target(TSignal signal), required Future<T> handle(SignalStepContext<T, TSignal> context), String? name, Duration expireAfter = const Duration(days: 1), RetryPolicy retry = const RetryPolicy(), TState? failureState, Duration timeout = const Duration(minutes: 5)}) -
const
Properties
-
accept
→ List<
TState> -
States in which the step accepts its signal. Must not be empty.
final
- expireAfter → Duration
-
Time after which a signal that was not applied is given up.
final
- failureState → TState?
-
State an element is moved to when all attempts failed.
finalinherited
-
handle
→ Future<
T> Function(SignalStepContext<T, TSignal> context) -
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isSignalForElement → bool
-
Whether
TSignalis declared as signal for the element typeT.no setter - name → String
-
Identifies the step in logs and in the stored events of the workflow.
no setterinherited
- retry → RetryPolicy
-
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
signalBean
→ DataBean<
TSignal> -
The bean of the signal, which is used to store and restore it.
It also determines
TSignal, which has to implementWorkflowSignal<T>(see isSignalForElement).final - target → Object Function(TSignal signal)
-
The id of the element a signal is meant for.
final
- timeout → Duration
-
Maximum time the handler may run.
finalinherited
Methods
-
accepts(
Object signal) → bool -
Whether
signalis of the type handled by this step. -
encode(
Object signal) → Map< String, dynamic> -
Serializes
signalfor storage. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
run(
Map< String, dynamic> payload, {required T element, required int attempt, required String idempotencyKey, required Future<void> lockExpired, required Workflow<T> workflow}) → Future<T> -
Restores the signal from
payloadand runs the handler for it. -
targetOf(
Object signal) → Object -
The id of the element
signalis meant for. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited