Record Class EventExecution

java.lang.Object
java.lang.Record
com.iantapply.orchestra.domain.EventExecution
Record Components:
id - unique execution identifier
definitionId - source definition identifier
status - current lifecycle status
stageIndex - zero-based current stage, or -1 before starting
version - optimistic-lock version
createdAt - creation time
updatedAt - last persisted update time
dueAt - next time at which the engine should process this execution
stageStartedAt - time at which the current stage began
variables - immutable global variables for this execution
completedActions - idempotency keys already persisted as complete
failure - terminal failure detail, when failed

public record EventExecution(UUID id, String definitionId, EventStatus status, int stageIndex, long version, Instant createdAt, Instant updatedAt, Instant dueAt, Instant stageStartedAt, Map<String,Object> variables, Set<String> completedActions, String failure) extends Record
Immutable, versioned runtime state for one event execution.
  • Constructor Details

  • Method Details

    • scheduled

      public static EventExecution scheduled(UUID id, String definitionId, Instant now, Instant dueAt)
      Creates a new scheduled execution at version zero.
      Parameters:
      id - unique execution identifier
      definitionId - source definition identifier
      now - creation time
      dueAt - requested start time
      Returns:
      new scheduled execution
    • transition

      public EventExecution transition(EventStatus next, int nextStage, Instant now, Instant nextDueAt)
      Creates the next version with a new lifecycle state.
      Parameters:
      next - next status
      nextStage - next stage index
      now - transition time
      nextDueAt - next processing time
      Returns:
      incremented immutable execution
    • withFailure

      public EventExecution withFailure(String message, Instant now)
      Creates a failed copy of this execution.
      Parameters:
      message - failure description
      now - failure time
      Returns:
      incremented failed execution
    • withCompletedAction

      public EventExecution withCompletedAction(String key, Instant now)
      Records one action as durably completed.
      Parameters:
      key - completed action idempotency key
      now - completion time
      Returns:
      incremented execution containing the key
    • withVariables

      public EventExecution withVariables(Map<String,Object> nextVariables, Instant now)
      Replaces the complete variable snapshot.
      Parameters:
      nextVariables - complete replacement variable map
      now - update time
      Returns:
      incremented execution with an immutable variable snapshot
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • id

      public UUID id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • definitionId

      public String definitionId()
      Returns the value of the definitionId record component.
      Returns:
      the value of the definitionId record component
    • status

      public EventStatus status()
      Returns the value of the status record component.
      Returns:
      the value of the status record component
    • stageIndex

      public int stageIndex()
      Returns the value of the stageIndex record component.
      Returns:
      the value of the stageIndex record component
    • version

      public long version()
      Returns the value of the version record component.
      Returns:
      the value of the version record component
    • createdAt

      public Instant createdAt()
      Returns the value of the createdAt record component.
      Returns:
      the value of the createdAt record component
    • updatedAt

      public Instant updatedAt()
      Returns the value of the updatedAt record component.
      Returns:
      the value of the updatedAt record component
    • dueAt

      public Instant dueAt()
      Returns the value of the dueAt record component.
      Returns:
      the value of the dueAt record component
    • stageStartedAt

      public Instant stageStartedAt()
      Returns the value of the stageStartedAt record component.
      Returns:
      the value of the stageStartedAt record component
    • variables

      public Map<String,Object> variables()
      Returns the value of the variables record component.
      Returns:
      the value of the variables record component
    • completedActions

      public Set<String> completedActions()
      Returns the value of the completedActions record component.
      Returns:
      the value of the completedActions record component
    • failure

      public String failure()
      Returns the value of the failure record component.
      Returns:
      the value of the failure record component