ProcessQueueInterface
Defines a queue responsible for collecting and executing process instances.
Description
Implementations MUST preserve the execution contract defined by this interface and SHALL provide deterministic behavior for adding queued processes and running them.
Queued processes MAY be configured to run detached from the main blocking flow and MAY also be configured to not affect the final execution result. These behaviors are independent and MUST be interpreted according to the method contract declared below.
Constants
Methods
Exit code indicating a queue failure.
public
int
FAILURE
=
1
Description
This constant SHALL be returned when at least one queued process that affects the final result fails during startup or execution. Processes configured to ignore failures MUST NOT cause this value to be returned.
Exit code indicating successful queue execution.
public
int
SUCCESS
=
0
Description
This constant SHALL be returned when all queued processes that affect the final result complete successfully. Processes configured to ignore failures MUST NOT prevent this value from being returned.
Adds a process to the queue.
public
add(Process
$process[,
bool
$ignoreFailure = false][,
bool
$detached = false][,
string|null
$label = null]) : void
Description
The provided process MUST be accepted for later execution by the queue.
When $ignoreFailure is set to true, a failure of the process MUST NOT affect the final status code returned by run(). Implementations SHOULD still report or record such a failure when that information is useful for diagnostics.
When $detached is set to true, the process SHALL be started without blocking the execution of subsequent queue entries. A detached process MAY continue running after the queue advances to the next entry.
Implementations MUST NOT mutate the semantic intent of the supplied process in a way that would make its execution meaningfully different from what the caller configured before enqueueing it.
Parameters
$process
:
Process
Description
the process instance that SHALL be added to the queue
$ignoreFailure
:
bool
=
false
Description
indicates whether a failure of this process MUST NOT affect the final queue result
$detached
:
bool
=
false
Description
indicates whether this process SHALL be started without blocking the next queued process
$label
:
string|null
=
null
Description
an optional label that MAY be used to present the process output as a grouped block
Runs the queued processes and returns the resulting status code.
public
run([OutputInterface|null
$output = null]) : int
Description
Implementations MUST return an integer exit status representing the overall execution result of the queue.
Failures from processes added with $ignoreFailure set to true MUST NOT be reflected in the final returned status code.
The returned status code SHOULD represent the aggregated outcome of all queued processes whose failures are not configured to be ignored.
Parameters
$output
:
OutputInterface|null
=
null
Description
the output interface to which process output and diagnostics MAY be written
Return values
Description
the final exit status code produced by the queue execution
Waits for all detached processes to finish execution.
public
wait([OutputInterface|null
$output = null]) : void
Description
Implementations MUST block the execution thread until all previously started detached processes complete. This ensures the main process does not exit prematurely, preventing detached children from being abruptly terminated.
Parameters
$output
:
OutputInterface|null
=
null
Description
the output interface to which process output and diagnostics MAY be written