Task
Task
Base class for executable tasks managed by the agent.
class Task extends \Hazaar\Warlock\Agent\ProcessProperties
status
Current task lifecycle status.
public TaskStatus $status = 'TaskStatus'agent
Owning agent process.
public Main $agentstart
Next scheduled execution timestamp.
public int $startretries
Number of retry attempts already consumed.
public int $retriesexpire
Expiration timestamp after completion/cancellation.
public int $expiretimeout
Max runtime timeout in seconds.
public int $timeoutrespawn
Whether the task should be respawned after completion.
public bool $respawnrespawnDelay
Delay in seconds before respawn.
public int $respawnDelaylastHeartbeat
Timestamp of the last heartbeat received.
public int $lastHeartbeatheartbeats
Number of heartbeats received.
public int $heartbeatsconfig
public array $configConfiguration for the task, such as retry count, retry delay, and expiration time.
endpoint
Endpoint definition to execute for this task.
public Endpoint $endpointparams
protected array $paramsrecvBuffer
Buffered receive data awaiting full packet extraction.
private string $recvBuffersubscriptions
private array $subscriptionsMethods
__construct
public __construct(Main $agent, Logger $log): voidParameters
| Parameter | Type | Description |
|---|---|---|
$agent | Main | owning agent process |
$log | Logger | task logger |
exec
Executes the task with the given callable and parameters.
public exec(Endpoint $endpoint, mixed $params): selfParameters
| Parameter | Type | Description |
|---|---|---|
$endpoint | Endpoint | |
$params | mixed |
ready
Returns true when the task is queued and ready to start.
public ready(): boolstart
Starts child process execution for this task.
public start(): voidprocess
Advances task state machine and runtime monitoring.
public process(): selfrun
Default run implementation for tasks that do not override execution.
public run(): selfcancel
Cancels task execution and schedules task expiry.
public cancel(int $expire = 30): selfParameters
| Parameter | Type | Description |
|---|---|---|
$expire | int |
expired
Returns true when task is eligible for queue cleanup.
public expired(): boolrecv
Consumes inbound data buffer and processes decoded packets.
public recv(string $buf): selfParameters
| Parameter | Type | Description |
|---|---|---|
$buf | string |
destruct
public destruct(): voidtouch
Returns the next scheduled timestamp for this task.
public touch(): ?inttimeout
Returns true when runtime has exceeded configured timeout.
public timeout(): boolsend
Encodes and writes a packet to the child process.
public send(PacketType $command, mixed $payload): boolParameters
| Parameter | Type | Description |
|---|---|---|
$command | PacketType | |
$payload | mixed |
getEndpoint
public getEndpoint(): EndpointprocessCommand
protected processCommand(PacketType $command, mixed $payload): boolParameters
| Parameter | Type | Description |
|---|---|---|
$command | PacketType | |
$payload | mixed |
commandTrigger
private commandTrigger(string $eventID, mixed $data, bool $echoClient = true): boolParameters
| Parameter | Type | Description |
|---|---|---|
$eventID | string | |
$data | mixed | |
$echoClient | bool |
commandSubscribe
private commandSubscribe(string $eventID, ?array $filter): boolParameters
| Parameter | Type | Description |
|---|---|---|
$eventID | string | |
$filter | array |
commandUnsubscribe
private commandUnsubscribe(string $eventID): boolParameters
| Parameter | Type | Description |
|---|---|---|
$eventID | string |
commandLog
private commandLog(\stdClass $payload): boolParameters
| Parameter | Type | Description |
|---|---|---|
$payload | \stdClass |
monitor
private monitor(): voidprocessPacket
private processPacket(?string $buffer): stringParameters
| Parameter | Type | Description |
|---|---|---|
$buffer | string |
Generated by Hazaar API Doc Generator on Tue, 21 Apr 2026 04:00:25 +0000