Problem/Motivation

Orchestra dispatches InstanceStartedEvent when an instance is created, and OrchestraAuditableEvent at each transition for observability. There is no first-class, typed lifecycle event for when an instance reaches a terminal state (completed, cancelled or failed). A consumer that wants to react to a run ending (release a reserved resource, delete a stored credential, notify an external system) has to hang that logic off OrchestraAuditableEvent, filtering by channel and action strings, which is the wrong layer: the auditable event exists for recording, not for driving business logic.

Proposed resolution

Add InstanceEndedEvent as an @api event, the symmetric counterpart to InstanceStartedEvent, carrying the instance and the terminal status so a listener can tell completed from cancelled from failed. The engine dispatches it at the three terminal transitions, after the status is saved and the teardown is done: completed in checkCompletion(), cancelled in cancelInstance(), failed in failInstance(). Because the cancelled and failed transitions run inside a database transaction, the event documents that listeners must be side-effect-light and must not throw.

Remaining tasks

  • Add the event class and dispatch it from the three terminal sites.
  • Kernel test covering the completed and cancelled dispatch.

Issue fork orchestra-3606795

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mably created an issue. See original summary.

  • mably committed 1bbb345b on 1.x
    feat: #3606795 Add an InstanceEndedEvent for reacting to a process...
mably’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.