4: Runtime helpers and scheduling
Two consumers ride the daemon without you calling /dispatch yourself: the async runtime helpers, and the scheduler.
4.1: The runtime helpers
Phlo's helpers for running a target out of band all use the pool when the app opts in, and fall back to a one-shot subprocess otherwise:
| Helper | Does |
|---|---|
phlo_sync('Class::method', ...$args) |
Run a target and wait for its return value |
phlo_async('Class::method', ...$args) |
Queue a target fire-and-forget; returns once accepted |
await($job, $job, ...) |
Run many targets concurrently and collect their results |
phlo_stream('Class::method', ...$args) |
Yield a target's output line by line |
The opt-in is one constant in the app entrypoint:
phlo_app(
id: 'Api',
host: 'api.example.com',
daemon: 3001,
);
With daemon set, the helpers dispatch by app path onto the pool; without it, they spawn a one-shot process exactly as before. The app code is identical either way, so adopting the daemon only changes throughput.
The gain is largest when one request fans out. await() over a hundred jobs is a hundred app boots on the one-shot path, but a hundred dispatches onto a resident pool with the daemon, bounded by the worker count instead of an unbounded burst of subprocesses:
$results = await(
['translate::run', 'nl', $text],
['translate::run', 'de', $text],
['translate::run', 'fr', $text],
)4.2: Scheduling without cron
The daemon runs tasks::run every minute on every app in its host map, which replaces the per-app cron entry behind the tasks resource. There is nothing to configure: the per-task schedule lives in %app->tasks (the every: on each task), and an app that does not load the tasks resource is skipped automatically after its first tick:
{
'dashboard.example.nl': { app: '/var/www/dashboard/www/app.php', build: true },
'api.example.nl': { app: '/var/www/api/www/app.php', build: false },
}
Everything downstream is unchanged: the same %app->tasks matching, the same due-check, the same on-disk state. Cron stays the fallback for hosts without a daemon; you pick one trigger, not both.