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
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
Comment #4
mably commented