Main
Main
Main Warlock agent process responsible for task orchestration.
class Main extends \Hazaar\Warlock\Agent\ProcessProperties
tasks
Main task queue.
public array $taskstags
Tags for scheduled tasks.
public array $tagsreconnect
Reconnect automatically when control channel is interrupted.
protected bool $reconnect = trueconfig
Agent configuration loaded from environment and config files.
private Config $configapp
Application metadata used by spawned task processes.
private Application $appMethods
__construct
public __construct(?string $configFile, string $env = 'development'): voidParameters
| Parameter | Type | Description |
|---|---|---|
$configFile | string | agent config filename |
$env | string | runtime environment name |
getConfig
Returns the agent configuration.
public getConfig(): ConfigsetSilent
Enables or disables agent log output.
public setSilent(bool $silent = true): voidParameters
| Parameter | Type | Description |
|---|---|---|
$silent | bool |
createConnection
Creates the agent control-channel socket connection.
public createConnection(Protocol $protocol, ?string $guid): ConnectionParameters
| Parameter | Type | Description |
|---|---|---|
$protocol | Protocol | |
$guid | string |
bootstrap
Performs one-time agent setup before entering the run loop.
public bootstrap(): selfregisterServices
Loads and registers service tasks from a services config file.
public registerServices(string $configFile = 'services'): voidParameters
| Parameter | Type | Description |
|---|---|---|
$configFile | string |
registerScheduledTasks
Registers scheduled tasks based on the provided configuration array.
public registerScheduledTasks(array $scheduleConfig): voidIterates through each task in the schedule configuration, validates the presence of the 'action' attribute, creates an Endpoint for the action, sets parameters if provided, and schedules the task to run at the specified time. Handles special scheduling keyword '@reboot' by calculating the appropriate start time with an optional boot delay. Logs notices and errors for missing or invalid configuration attributes.
Parameters
| Parameter | Type | Description |
|---|---|---|
$scheduleConfig | array |
registerEventHandlers
Registers event handlers based on the provided configuration array.
public registerEventHandlers(array $eventConfig): voidIterates through each event in the event configuration, creates an Endpoint for the handler, and subscribes to the event with the corresponding handler. Logs notices and errors for invalid configuration attributes.
Parameters
| Parameter | Type | Description |
|---|---|---|
$eventConfig | array | array of event configurations where the key is the event name and the value is the handler (callable) |
shutdown
public shutdown(): voidinit
public init(): boolannounce
public announce(): voidtrigger
public trigger(string $event, mixed $data, bool $echoSelf): boolParameters
| Parameter | Type | Description |
|---|---|---|
$event | string | |
$data | mixed | |
$echoSelf | bool |
run
protected run(): voidprocessCommand
protected processCommand(PacketType $command, ?\stdClass $payload): boolParameters
| Parameter | Type | Description |
|---|---|---|
$command | PacketType | |
$payload | \stdClass |
processEvent
private processEvent(string $event, mixed $payload): voidParameters
| Parameter | Type | Description |
|---|---|---|
$event | string | |
$payload | mixed |
scheduleRunner
private scheduleRunner(string $when, Endpoint $endpoint, mixed $args, ?string $tag, bool $overwrite): stringParameters
| Parameter | Type | Description |
|---|---|---|
$when | string | |
$endpoint | Endpoint | |
$args | mixed | |
$tag | string | |
$overwrite | bool |
taskQueueAdd
private taskQueueAdd(Task $task): voidParameters
| Parameter | Type | Description |
|---|---|---|
$task | Task |
taskCancel
private taskCancel(string $taskID): boolParameters
| Parameter | Type | Description |
|---|---|---|
$taskID | string |
Generated by Hazaar API Doc Generator on Tue, 21 Apr 2026 04:00:25 +0000