step<T> method
Future<T>
step<T>(
- String name,
- Future<
T> action(), { - Future<
void> compensate(- T result
- RetryPolicy retry = RetryPolicy.none,
- String serialize(
- T value
- T deserialize(
- String data
override
Executes a named step with checkpoint/resume semantics.
name: Human-readable step name (used as checkpoint key).action: The function to execute. Should contain a single side effect.compensate: Optional compensation function for saga rollback. Receives the step result as a parameter, enabling direct access to the result without mutable variable workarounds.retry: Retry policy for this step. Defaults to no retry.serialize: Custom serializer to convert the step result to a string for checkpoint persistence. If omitted,jsonEncode(result)is used.deserialize: Custom deserializer to reconstruct the step result from the persisted string on recovery. If omitted,jsonDecode+ cast is used, which only works for primitive types. Required for custom object types.
Returns the result of action (or the cached result on resume).
Implementation
@override
Future<T> step<T>(
String name,
Future<T> Function() action, {
Future<void> Function(T result)? compensate,
RetryPolicy retry = RetryPolicy.none,
String Function(T value)? serialize,
T Function(String data)? deserialize,
}) {
validateIdentifier(name, 'name');
return _executor.executeStep<T>(
name,
action,
serialize: serialize,
deserialize: deserialize,
retryPolicy: retry,
compensate: compensate,
);
}