InMemoryBackgroundJobManager
Tracks long-running work so the interface can show progress. It records job state — it does not spawn processes: the caller runs the work and reports output, progress and outcome back here.
InMemoryBackgroundJobManager::__construct()
public function __construct(?Milpa\Live\Contracts\Tui\TuiEventBusInterface $events = null):Parameters
| Name | Type | Description |
|---|---|---|
| $events | ?Milpa\Live\Contracts\Tui\TuiEventBusInterface |
InMemoryBackgroundJobManager::start()
public function start(string $label, string $command = ''): Milpa\Live\ValueObjects\Tui\BackgroundJobRecords a new running job and returns it.
Parameters
| Name | Type | Description |
|---|---|---|
| $label | string | |
| $command | string |
InMemoryBackgroundJobManager::appendOutput()
public function appendOutput(string $jobId, string $line, string $stream = 'stdout'): Milpa\Live\ValueObjects\Tui\BackgroundJobAppends one output line to the job, tagged with the stream it came from.
Parameters
| Name | Type | Description |
|---|---|---|
| $jobId | string | |
| $line | string | |
| $stream | string |
InMemoryBackgroundJobManager::progress()
public function progress(string $jobId, float $progress): Milpa\Live\ValueObjects\Tui\BackgroundJobUpdates the job's completion fraction, in [0,1].
Parameters
| Name | Type | Description |
|---|---|---|
| $jobId | string | |
| $progress | float |
InMemoryBackgroundJobManager::finish()
public function finish(string $jobId, int $exitCode = 0): Milpa\Live\ValueObjects\Tui\BackgroundJobMarks the job finished with the given exit code.
Parameters
| Name | Type | Description |
|---|---|---|
| $jobId | string | |
| $exitCode | int |
InMemoryBackgroundJobManager::fail()
public function fail(string $jobId, string $reason, int $exitCode = 1): Milpa\Live\ValueObjects\Tui\BackgroundJobMarks the job failed, recording why and the exit code.
Parameters
| Name | Type | Description |
|---|---|---|
| $jobId | string | |
| $reason | string | |
| $exitCode | int |
InMemoryBackgroundJobManager::cancel()
public function cancel(string $jobId): Milpa\Live\ValueObjects\Tui\BackgroundJobMarks the job cancelled. It records the outcome — it does not stop the work, which the caller owns.
Parameters
| Name | Type | Description |
|---|---|---|
| $jobId | string |
InMemoryBackgroundJobManager::get()
public function get(string $jobId): ?Milpa\Live\ValueObjects\Tui\BackgroundJobThe job with this id, or null when it is unknown.
Parameters
| Name | Type | Description |
|---|---|---|
| $jobId | string |
InMemoryBackgroundJobManager::all()
public function all(): arrayEvery job this manager has seen, finished ones included.