Class AbstractStepExecutor
java.lang.Object
io.axoniq.framework.workflow.runtime.execution.AbstractStepExecutor
- Direct Known Subclasses:
ExecuteDelegate,PayloadDelegate,RetryableExecuteDelegate,WaitForDelegate
Abstract class for step executor implementations.
- Since:
- 5.4.0
- Author:
- Simon Zambrovski
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Clockprotected final EventNameCustomizerprotected final ReachedStepsprotected final RunningStepsprotected final WorkflowSchedulerprotected final WorkflowExecutionprotected final WorkflowExecutionOperations -
Constructor Summary
ConstructorsConstructorDescriptionAbstractStepExecutor(WorkflowExecutionOperations workflowExecutionOperations, WorkflowExecution workflowExecution, RunningSteps runningSteps, ReachedSteps reachedSteps, EventNameCustomizer parentEventNameCustomizer, Clock clock, WorkflowScheduler timeoutScheduler) Constructs the abstract step executor. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidacceptAllPendingTasksForStep(String stepName) protected CompletableFuture<Void> appendEvent(EventMessage eventMessage, Context context) Appends the giveneventMessageunder its append condition, deriving the append's unit of work from the givencontext.protected CompletableFuture<Void> cancelled(String stepName, EventNameCustomizer eventNameCustomizer) protected CompletableFuture<Void> cancelled(String stepName, @Nullable Throwable cause, EventNameCustomizer eventNameCustomizer) protected CompletableFuture<Void> cancelledWaitForEvent(String stepName, @Nullable Throwable cause, EventNameCustomizer eventNameCustomizer) protected CompletableFuture<Void> completed(String stepName, Map<String, @Nullable Object> payload, EventNameCustomizer eventNameCustomizer) protected CompletableFuture<Void> completed(String stepName, Map<String, @Nullable Object> payload, @Nullable String payloadReducerName, EventNameCustomizer eventNameCustomizer) protected CompletableFuture<Void> completedWaitForEvent(String stepName, Map<String, @Nullable Object> payload, @Nullable String payloadReducerName, EventNameCustomizer eventNameCustomizer) eventMessagePayload(EventMessage eventMessage) protected CompletableFuture<Void> failed(String stepName, Throwable ex, EventNameCustomizer eventNameCustomizer) protected ContextgetContext(String stepName) static booleanisCancellation(Throwable error) Determines whether an exceptional step completion represents cancellation rather than failure or interruption.protected voidregisterParkedStep(String stepName, CompletableFuture<?> parkedPhase, EventNameCustomizer eventNameCustomizer, Runnable onCancelled) Registers the given future as the step's running phase while the step is parked (a wait timeout window, a retry backoff window).protected voidregisterParkedStep(String stepName, CompletableFuture<?> parkedPhase, Runnable cancelTimer, EventNameCustomizer eventNameCustomizer, Runnable onCancelled) Registers a parked step and owns the lifetime of its timer.protected CompletableFuture<Void> retrying(String stepName, StepRetryInfo retryInfo, EventNameCustomizer eventNameCustomizer) protected CompletableFuture<Void> retryStarted(String stepName, StepRetryInfo retryInfo, EventNameCustomizer eventNameCustomizer) protected CompletableFuture<Void> started(String stepName, Map<String, @Nullable Object> payload, EventNameCustomizer eventNameCustomizer) protected CompletableFuture<Void> startedWaitForEvent(String stepName, Map<String, @Nullable Object> payload, EventNameCustomizer eventNameCustomizer) static WorkflowStepResultstateBased(String stepName, EventNameCustomizer eventNameCustomizer, WorkflowExecution workflowExecution) Creates a durable result handle for a step while retaining its event-name customizer for later cancellation.protected CompletableFuture<Void> timedOut(String stepName, EventNameCustomizer eventNameCustomizer) protected CompletableFuture<Void> timedOut(String stepName, Instant timeoutTimestamp, EventNameCustomizer eventNameCustomizer) protected CompletableFuture<Void> timedOutWaitForEvent(String stepName, EventNameCustomizer eventNameCustomizer) protected CompletableFuture<Void> timedOutWaitForEvent(String stepName, Instant timeoutTimestamp, EventNameCustomizer eventNameCustomizer) protected static Throwableprotected static Throwable
-
Field Details
-
workflowExecutionOperations
-
workflowExecution
-
runningSteps
-
reachedSteps
-
clock
-
parentEventNameCustomizer
-
timeoutScheduler
-
-
Constructor Details
-
AbstractStepExecutor
@Internal public AbstractStepExecutor(WorkflowExecutionOperations workflowExecutionOperations, WorkflowExecution workflowExecution, RunningSteps runningSteps, ReachedSteps reachedSteps, EventNameCustomizer parentEventNameCustomizer, Clock clock, WorkflowScheduler timeoutScheduler) Constructs the abstract step executor.- Parameters:
workflowExecutionOperations- runtime primitive-operation surfaceworkflowExecution- workflow executionrunningSteps- running step registryreachedSteps- reached steps trackerparentEventNameCustomizer- parent event name customizerclock- clock for time calculationstimeoutScheduler- timeout scheduler
-
-
Method Details
-
isCancellation
Determines whether an exceptional step completion represents cancellation rather than failure or interruption.- Parameters:
error- completion error to classify- Returns:
truewhen the error represents step or workflow cancellation
-
unwrapCancellation
-
unwrapCompletionException
-
stateBased
public static WorkflowStepResult stateBased(String stepName, EventNameCustomizer eventNameCustomizer, WorkflowExecution workflowExecution) Creates a durable result handle for a step while retaining its event-name customizer for later cancellation.- Parameters:
stepName- logical name of the stepeventNameCustomizer- customizer originally supplied for the step primitiveworkflowExecution- execution providing state access and cancellation delegation- Returns:
- state-backed step result handle
-
acceptAllPendingTasksForStep
-
getContext
-
started
protected CompletableFuture<Void> started(String stepName, Map<String, @Nullable Object> payload, EventNameCustomizer eventNameCustomizer) -
startedWaitForEvent
protected CompletableFuture<Void> startedWaitForEvent(String stepName, Map<String, @Nullable Object> payload, EventNameCustomizer eventNameCustomizer) -
completed
protected CompletableFuture<Void> completed(String stepName, Map<String, @Nullable Object> payload, EventNameCustomizer eventNameCustomizer) -
completed
protected CompletableFuture<Void> completed(String stepName, Map<String, @Nullable Object> payload, @Nullable String payloadReducerName, EventNameCustomizer eventNameCustomizer) -
completedWaitForEvent
protected CompletableFuture<Void> completedWaitForEvent(String stepName, Map<String, @Nullable Object> payload, @Nullable String payloadReducerName, EventNameCustomizer eventNameCustomizer) -
cancelled
protected CompletableFuture<Void> cancelled(String stepName, EventNameCustomizer eventNameCustomizer) -
cancelled
protected CompletableFuture<Void> cancelled(String stepName, @Nullable Throwable cause, EventNameCustomizer eventNameCustomizer) -
registerParkedStep
protected void registerParkedStep(String stepName, CompletableFuture<?> parkedPhase, EventNameCustomizer eventNameCustomizer, Runnable onCancelled) Registers the given future as the step's running phase while the step is parked (a wait timeout window, a retry backoff window). When the future is completed exceptionally with a cancellation cause, the step is recorded CANCELLED through the guarded publish path and the cleanup hook runs; any other completion only removes the running-step registration, leaving the durable step state untouched.- Parameters:
stepName- name of the parked stepparkedPhase- future representing the parked phaseeventNameCustomizer- event name customizer of the steponCancelled- cleanup to run when the parked phase is cancelled
-
registerParkedStep
protected void registerParkedStep(String stepName, CompletableFuture<?> parkedPhase, Runnable cancelTimer, EventNameCustomizer eventNameCustomizer, Runnable onCancelled) Registers a parked step and owns the lifetime of its timer.- Parameters:
stepName- name of the parked stepparkedPhase- future representing the parked phasecancelTimer- cancels the timer associated with the parked phaseeventNameCustomizer- event name customizer of the steponCancelled- cleanup to run when the parked phase is cancelled
-
cancelledWaitForEvent
protected CompletableFuture<Void> cancelledWaitForEvent(String stepName, @Nullable Throwable cause, EventNameCustomizer eventNameCustomizer) -
failed
protected CompletableFuture<Void> failed(String stepName, Throwable ex, EventNameCustomizer eventNameCustomizer) -
retrying
protected CompletableFuture<Void> retrying(String stepName, StepRetryInfo retryInfo, EventNameCustomizer eventNameCustomizer) -
retryStarted
protected CompletableFuture<Void> retryStarted(String stepName, StepRetryInfo retryInfo, EventNameCustomizer eventNameCustomizer) -
timedOut
protected CompletableFuture<Void> timedOut(String stepName, EventNameCustomizer eventNameCustomizer) -
timedOut
protected CompletableFuture<Void> timedOut(String stepName, Instant timeoutTimestamp, EventNameCustomizer eventNameCustomizer) -
timedOutWaitForEvent
protected CompletableFuture<Void> timedOutWaitForEvent(String stepName, EventNameCustomizer eventNameCustomizer) -
timedOutWaitForEvent
protected CompletableFuture<Void> timedOutWaitForEvent(String stepName, Instant timeoutTimestamp, EventNameCustomizer eventNameCustomizer) -
appendEvent
Appends the giveneventMessageunder its append condition, deriving the append's unit of work from the givencontext. Use this from a primitive that publishes an event without the step guards ofsendStepEvent, so every append still shares one condition and one fencing path.- Parameters:
eventMessage- the event to append.context- the context the append's unit of work derives its resources from.- Returns:
- a future completing once the event is appended.
-
sanitize
-
eventMessagePayload
-