java.lang.Object
io.axoniq.framework.workflow.runtime.execution.RunningSteps
All Implemented Interfaces:
DescribableComponent

@Internal public class RunningSteps extends Object implements DescribableComponent
Tracks running CompletableFutures for workflow steps, keyed by step name.
Since:
5.4.0
Author:
Stefan Dragisic
  • Constructor Details

    • RunningSteps

      public RunningSteps()
  • Method Details

    • register

      public void register(String stepName, CompletableFuture<?> future)
      Register a new running step.
      Parameters:
      stepName - step name.
      future - future to register.
    • remove

      public void remove(String stepName)
      Remove a running step.
      Parameters:
      stepName - step name.
    • stepNames

      public Set<String> stepNames()
      Returns a snapshot of the names of the currently-running steps.
      Returns:
      a snapshot set of the running step names.
    • cancelAndRemove

      public void cancelAndRemove(String stepName, boolean mayInterruptIfRunning)
      Cancel and remove a running step.
      Parameters:
      stepName - step name.
      mayInterruptIfRunning - whether to interrupt the step if it is running.
    • cancelWithCause

      public boolean cancelWithCause(String stepName, @Nullable Throwable cause)
      Cancel a running step providing a cause to be used for the cancellation as a failed future cause.
      Parameters:
      stepName - step name.
      cause - a cause for the cancellation.
      Returns:
      true, if the future was cancelled successfully.
    • cancelAll

      public void cancelAll(@Nullable Throwable cause, Consumer<Set<String>> awaitTermination)
      Cancel all running steps, waiting for them to complete and passing the cancelled step names to the given consumer.
      Parameters:
      cause - the cause of the cancellation.
      awaitTermination - consumer of cancelled step names.
    • describeTo

      public void describeTo(ComponentDescriptor descriptor)
      Description copied from interface: DescribableComponent
      Describe the properties of this DescribableComponent with the given descriptor.

      Components should call the appropriate describeProperty methods on the descriptor to register their properties. The descriptor is responsible for determining how these properties are formatted and structured in the final output.

      Best Practices: As a general rule, all relevant fields of a DescribableComponent implementation should be described in this method. However, developers have discretion to include only the fields that make sense in the context. Not every field may be meaningful for description purposes, especially internal implementation details. Furthermore, components might want to expose different information based on their current state. The final decision on what properties to include lies with the person implementing the describeTo method, who should focus on providing information that is useful for understanding the component's configuration and state.

      Example implementation:

       public void describeTo(ComponentDescriptor descriptor) {
           descriptor.describeProperty("name", this.name);
           descriptor.describeProperty("enabled", this.enabled);
           descriptor.describeProperty("configuration", this.configuration); // A nested component
           descriptor.describeProperty("handlers", this.eventHandlers);      // A collection
       }
       
      Specified by:
      describeTo in interface DescribableComponent
      Parameters:
      descriptor - The component descriptor to describe this DescribableComponentn its properties in.