Process
Process
Base process implementation for Warlock clients, agents, and services.
class ProcessProperties
instances
public array $instancesType: array
start
Process start timestamp.
public int $startType: int
state
Current lifecycle state for the process.
public Status $state = 'Status'Type: Hazaar\Warlock\Enum\Status
protocol
Protocol encoder/decoder used for connection packets.
public Protocol $protocolType: Hazaar\Warlock\Protocol
conn
Active transport connection implementation.
protected Connection $connType: Hazaar\Warlock\Interface\Connection
reconnect
Whether process should reconnect when a connection drops.
protected bool $reconnectType: bool
id
public string $idType: string
clientId
public string $clientIdType: string
subscriptions
protected array $subscriptionsType: array
slept
Indicates whether sleep() executed in the current run loop.
protected bool $sleptType: bool
silent
Suppresses selected runtime logging when true.
protected bool $silentType: bool
log
Logger instance for process diagnostics.
protected Logger $logType: Hazaar\Warlock\Logger
messageQueue
A queue of messages to send when the connection is established. This allows messages
private array $messageQueueType: array
to be sent before the connection is ready, which is useful for services that need to trigger events or set keys on startup.
Methods
__construct
public __construct(Protocol $protocol): voidParameters
| Parameter | Type | Description |
|---|---|---|
$protocol | Hazaar\Warlock\Protocol | protocol encoder/decoder instance |
__destruct
Ensures transport disconnect on process cleanup.
public __destruct(): void__errorHandler
public __errorHandler(int $errno, string $errstr, ?string $errfile, ?int $errline, array $errcontext): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$errno | int | |
$errstr | string | |
$errfile | string | |
$errline | int | |
$errcontext | array |
__exceptionHandler
public __exceptionHandler(\Throwable $e): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$e | Throwable |
__signalHandler
Shared process signal handler for registered process instances.
public __signalHandler(int $signo, mixed $siginfo): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$signo | int | POSIX signal number |
$siginfo | mixed | optional signal metadata |
__kv_send_recv
private __kv_send_recv(PacketType $command, array $data): mixedReturns: mixed
Parameters
| Parameter | Type | Description |
|---|---|---|
$command | Hazaar\Warlock\Enum\PacketType | |
$data | array |
construct
Constructor placeholder for child classes.
public construct(Application $app): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$app | Hazaar\Application |
init
Initialisation placeholder for child classes.
public init(): boolReturns: bool
id
public id(): ?stringReturns: string
send
public send(PacketType $command, mixed $payload): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$command | Hazaar\Warlock\Enum\PacketType | |
$payload | mixed |
recv
public recv(mixed $payload, int $tvSec = 3, int $tvUsec): bool|PacketType|nullReturns: bool|Hazaar\Warlock\Enum\PacketType|null
Parameters
| Parameter | Type | Description |
|---|---|---|
$payload | mixed | |
$tvSec | int | |
$tvUsec | int |
ping
public ping(bool $waitPong): bool|stringReturns: bool|string
Parameters
| Parameter | Type | Description |
|---|---|---|
$waitPong | bool |
on
public on(string $event, callable $callable, ?array $filter): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$event | string | |
$callable | callable | |
$filter | array |
subscribe
public subscribe(string $event, callable $callable, ?array $filter): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$event | string | |
$callable | callable | |
$filter | array |
addEventEndpoint
public addEventEndpoint(string $event, Endpoint $endpoint): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$event | string | |
$endpoint | Hazaar\Warlock\Agent\Struct\Endpoint |
unsubscribe
public unsubscribe(string $event): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$event | string |
trigger
public trigger(string $event, mixed $data, bool $echoSelf): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$event | string | |
$data | mixed | |
$echoSelf | bool |
log
public log(string $message, LogLevel $level = 'LogLevel::NOTICE', ?string $name): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$message | string | |
$level | Hazaar\Warlock\Enum\LogLevel | |
$name | string |
debug
public debug(mixed $data, ?string $name): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$data | mixed | |
$name | string |
spawn
public spawn(string $service, array $params): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$service | string | |
$params | array |
kill
public kill(string $service): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$service | string |
status
public status(): false|\stdClassReturns: false|stdClass
exec
public exec(array|callable $callable, array $params, ?string $tag, bool $overwrite): bool|stringReturns: bool|string
Parameters
| Parameter | Type | Description |
|---|---|---|
$callable | array | callable |
$params | array | |
$tag | string | |
$overwrite | bool |
execDelay
public execDelay(int $delay, array|callable $callable, array $params, ?string $tag, bool $overwrite): bool|stringReturns: bool|string
Parameters
| Parameter | Type | Description |
|---|---|---|
$delay | int | |
$callable | array | callable |
$params | array | |
$tag | string | |
$overwrite | bool |
interval
public interval(int $seconds, string $callable, array $params, ?string $tag, bool $overwrite): bool|stringReturns: bool|string
Parameters
| Parameter | Type | Description |
|---|---|---|
$seconds | int | |
$callable | string | |
$params | array | |
$tag | string | |
$overwrite | bool |
schedule
public schedule(DateTime $when, string $callable, array $params, ?string $tag, bool $overwrite): bool|stringReturns: bool|string
Parameters
| Parameter | Type | Description |
|---|---|---|
$when | Hazaar\Util\DateTime | |
$callable | string | |
$params | array | |
$tag | string | |
$overwrite | bool |
cancelTask
public cancelTask(string $taskID): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$taskID | string |
startService
public startService(string $name): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string |
stopService
public stopService(string $name): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string |
service
public service(string $name): bool|stringReturns: bool|string
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string |
get
public get(string $key, ?string $namespace): mixedReturns: mixed
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | |
$namespace | string |
set
public set(string $key, mixed $value, ?int $timeout, ?string $namespace): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | |
$value | mixed | |
$timeout | int | |
$namespace | string |
has
public has(string $key, ?string $namespace): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | |
$namespace | string |
del
public del(string $key, ?string $namespace): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | |
$namespace | string |
clear
public clear(?string $namespace): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$namespace | string |
List all keys in the key-value store.
public (?string $namespace): arrayReturns: array
If a namespace is provided, it will list keys only in that namespace.
Parameters
| Parameter | Type | Description |
|---|---|---|
$namespace | string |
pull
public pull(string $key, ?string $namespace): mixedReturns: mixed
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | |
$namespace | string |
push
public push(string $key, mixed $value, ?string $namespace): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | |
$value | mixed | |
$namespace | string |
pop
public pop(string $key, ?string $namespace): mixedReturns: mixed
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | |
$namespace | string |
shift
public shift(string $key, ?string $namespace): mixedReturns: mixed
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | |
$namespace | string |
unshift
public unshift(string $key, mixed $value, ?string $namespace): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | |
$value | mixed | |
$namespace | string |
incr
public incr(string $key, ?int $step, ?string $namespace): intReturns: int
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | |
$step | int | |
$namespace | string |
decr
public decr(string $key, ?int $step, ?string $namespace): intReturns: int
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | |
$step | int | |
$namespace | string |
keys
Get all keys in the key-value store.
public keys(?string $namespace): arrayReturns: array
If a namespace is provided, it will return keys only in that namespace.
Parameters
| Parameter | Type | Description |
|---|---|---|
$namespace | string |
vals
Get all values in the key-value store.
public vals(?string $namespace): arrayReturns: array
If a namespace is provided, it will return values only in that namespace.
Parameters
| Parameter | Type | Description |
|---|---|---|
$namespace | string |
count
Count the number of keys in the key-value store.
public count(string $key, ?string $namespace): intReturns: int
If a namespace is provided, it will count keys only in that namespace.
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | |
$namespace | string |
connect
public connect(?string $username, ?string $password): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$username | string | |
$password | string |
disconnect
public disconnect(): boolReturns: bool
connected
public connected(): boolReturns: bool
ready
public ready(): boolReturns: bool
authenticated
public authenticated(): boolReturns: bool
authenticate
public authenticate(string $username, string $password): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$username | string | |
$password | string |
main
public main(?array $params, bool $dynamic): intReturns: int
Parameters
| Parameter | Type | Description |
|---|---|---|
$params | array | |
$dynamic | bool |
shutdown
public shutdown(): voidReturns: void
cancel
public cancel(): voidReturns: void
stop
public stop(bool $force, ?string $pid): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$force | bool | |
$pid | string |
state
public state(): StatusReturns: Hazaar\Warlock\Enum\Status
run
protected run(): voidReturns: void
sleep
Sleep for a number of seconds. If data is received during the sleep it is processed. If the timeout is greater
protected sleep(int $timeout, Status $checkStatus = 'Status::RUNNING', ?callable $iterationCallback): boolReturns: bool
than zero and data is received, the remaining timeout amount will be used in subsequent selects to ensure the full sleep period is used. If the timeout parameter is not set then the loop will just dump out after one execution.
Parameters
| Parameter | Type | Description |
|---|---|---|
$timeout | int | number of seconds to sleep for |
$checkStatus | Hazaar\Warlock\Enum\Status | the status to check for when sleeping. If the process status changes from this value, the sleep will end early. |
$iterationCallback | callable | an optional callback that is executed at the end of each sleep iteration. This can be used to perform regular checks or maintenance tasks during long sleep periods. |
createConnection
protected createConnection(Protocol $protocol, ?string $guid): Connection|falseReturns: Hazaar\Warlock\Interface\Connection|false
Parameters
| Parameter | Type | Description |
|---|---|---|
$protocol | Hazaar\Warlock\Protocol | |
$guid | string |
setErrorHandler
protected setErrorHandler(string $methodName): ?callableReturns: callable
Parameters
| Parameter | Type | Description |
|---|---|---|
$methodName | string |
setExceptionHandler
protected setExceptionHandler(string $methodName): ?callableReturns: callable
Parameters
| Parameter | Type | Description |
|---|---|---|
$methodName | string |
processCommand
protected processCommand(PacketType $command, ?\stdClass $payload): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$command | Hazaar\Warlock\Enum\PacketType | |
$payload | stdClass |
sendExec
private sendExec(string $command, mixed $data, array|callable $callable, ?array $params, ?string $tag, bool $overwrite): false|stringReturns: false|string
Parameters
| Parameter | Type | Description |
|---|---|---|
$command | string | |
$data | mixed | |
$callable | array | callable |
$params | array | |
$tag | string | |
$overwrite | bool |
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:17 +0000