Task
Task
Base class for executable tasks managed by the agent.
class Task extends \Hazaar\Warlock\Agent\ProcessExtends: Hazaar\Warlock\Agent\Process
Properties
status
Current task lifecycle status.
public TaskStatus $status = 'TaskStatus'Type: Hazaar\Warlock\Enum\TaskStatus
agent
Owning agent process.
public Main $agentType: Hazaar\Warlock\Agent\Main
start
Next scheduled execution timestamp.
public int $startType: int
retries
Number of retry attempts already consumed.
public int $retriesType: int
expire
Expiration timestamp after completion/cancellation.
public int $expireType: int
timeout
Max runtime timeout in seconds.
public int $timeoutType: int
respawn
Whether the task should be respawned after completion.
public bool $respawnType: bool
respawnDelay
Delay in seconds before respawn.
public int $respawnDelayType: int
lastHeartbeat
Timestamp of the last heartbeat received.
public int $lastHeartbeatType: int
heartbeats
Number of heartbeats received.
public int $heartbeatsType: int
config
public array $configType: array
Configuration for the task, such as retry count, retry delay, and expiration time.
endpoint
Endpoint definition to execute for this task.
public Endpoint $endpointType: Hazaar\Warlock\Agent\Struct\Endpoint
isErrorHandler
Whether this task is itself an error handler, scheduled in response to another
public bool $isErrorHandlerType: bool
task's failure. Prevents runaway recursion if the error handler also fails.
params
protected array $paramsType: array
recvBuffer
Buffered receive data awaiting full packet extraction.
private string $recvBufferType: string
subscriptions
private array $subscriptionsType: array
Methods
__construct
public __construct(Main $agent, Logger $log): voidParameters
| Parameter | Type | Description |
|---|---|---|
$agent | Hazaar\Warlock\Agent\Main | owning agent process |
$log | Hazaar\Warlock\Logger | task logger |
exec
Executes the task with the given callable and parameters.
public exec(Endpoint $endpoint, mixed $params): selfReturns: self
Parameters
| Parameter | Type | Description |
|---|---|---|
$endpoint | Hazaar\Warlock\Agent\Struct\Endpoint | |
$params | mixed |
ready
Returns true when the task is queued and ready to start.
public ready(): boolReturns: bool
start
Starts child process execution for this task.
public start(): voidReturns: void
process
Advances task state machine and runtime monitoring.
public process(): selfReturns: self
run
Default run implementation for tasks that do not override execution.
public run(): selfReturns: self
cancel
Cancels task execution and schedules task expiry.
public cancel(int $expire = 30): selfReturns: self
Parameters
| Parameter | Type | Description |
|---|---|---|
$expire | int |
expired
Returns true when task is eligible for queue cleanup.
public expired(): boolReturns: bool
recv
Consumes inbound data buffer and processes decoded packets.
public recv(string $buf): selfReturns: self
Parameters
| Parameter | Type | Description |
|---|---|---|
$buf | string |
destruct
public destruct(): voidReturns: void
touch
Returns the next scheduled timestamp for this task.
public touch(): ?intReturns: int
timeout
Returns true when runtime has exceeded configured timeout.
public timeout(): boolReturns: bool
send
Encodes and writes a packet to the child process.
public send(PacketType $command, mixed $payload): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$command | Hazaar\Warlock\Enum\PacketType | |
$payload | mixed |
getEndpoint
public getEndpoint(): EndpointReturns: Hazaar\Warlock\Agent\Struct\Endpoint
processCommand
protected processCommand(PacketType $command, mixed $payload): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$command | Hazaar\Warlock\Enum\PacketType | |
$payload | mixed |
commandTrigger
private commandTrigger(string $eventID, mixed $data, bool $echoClient = true): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$eventID | string | |
$data | mixed | |
$echoClient | bool |
commandSubscribe
private commandSubscribe(string $eventID, ?array $filter): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$eventID | string | |
$filter | array |
commandUnsubscribe
private commandUnsubscribe(string $eventID): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$eventID | string |
commandLog
private commandLog(\stdClass $payload): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$payload | stdClass |
monitor
private monitor(): voidReturns: void
processPacket
private processPacket(?string $buffer): false|stringReturns: false|string
Parameters
| Parameter | Type | Description |
|---|---|---|
$buffer | string |
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:17 +0000