Base process implementation for Warlock clients, agents, and services.
Process start timestamp.
Current lifecycle state for the process.
public Status $state = 'Status'
Protocol encoder/decoder used for connection packets.
public Protocol $protocol
Active transport connection implementation.
protected Connection $conn
Whether process should reconnect when a connection drops.
protected bool $reconnect
protected array $subscriptions
Indicates whether sleep() executed in the current run loop.
Suppresses selected runtime logging when true.
Logger instance for process diagnostics.
A queue of messages to send when the connection is established. This allows messages
private array $messageQueue
to be sent before the connection is ready, which is useful for services that need to trigger events or set keys on startup.
public __construct(Protocol $protocol): void
| Parameter | Type | Description |
|---|
$protocol | Protocol | protocol encoder/decoder instance |
Ensures transport disconnect on process cleanup.
public __destruct(): void
public __errorHandler(int $errno, string $errstr, ?string $errfile, ?int $errline, array $errcontext): bool
| Parameter | Type | Description |
|---|
$errno | int | |
$errstr | string | |
$errfile | string | |
$errline | int | |
$errcontext | array | |
public __exceptionHandler(\Throwable $e): void
| Parameter | Type | Description |
|---|
$e | \Throwable | |
Shared process signal handler for registered process instances.
public __signalHandler(int $signo, mixed $siginfo): void
| Parameter | Type | Description |
|---|
$signo | int | POSIX signal number |
$siginfo | mixed | optional signal metadata |
private __kv_send_recv(PacketType $command, array $data): mixed
| Parameter | Type | Description |
|---|
$command | PacketType | |
$data | array | |
Constructor placeholder for child classes.
public construct(Application $app): void
| Parameter | Type | Description |
|---|
$app | Application | |
Initialisation placeholder for child classes.
public send(PacketType $command, mixed $payload): bool
| Parameter | Type | Description |
|---|
$command | PacketType | |
$payload | mixed | |
public recv(mixed $payload, int $tvSec = 3, int $tvUsec): null
| Parameter | Type | Description |
|---|
$payload | mixed | |
$tvSec | int | |
$tvUsec | int | |
public ping(bool $waitPong): string
| Parameter | Type | Description |
|---|
$waitPong | bool | |
public on(string $event, callable $callable, ?array $filter): bool
| Parameter | Type | Description |
|---|
$event | string | |
$callable | callable | |
$filter | array | |
public subscribe(string $event, callable $callable, ?array $filter): bool
| Parameter | Type | Description |
|---|
$event | string | |
$callable | callable | |
$filter | array | |
public addEventEndpoint(string $event, Endpoint $endpoint): bool
| Parameter | Type | Description |
|---|
$event | string | |
$endpoint | Endpoint | |
public unsubscribe(string $event): bool
| Parameter | Type | Description |
|---|
$event | string | |
public trigger(string $event, mixed $data, bool $echoSelf): bool
| Parameter | Type | Description |
|---|
$event | string | |
$data | mixed | |
$echoSelf | bool | |
public log(string $message, LogLevel $level = 'LogLevel::NOTICE', ?string $name): bool
| Parameter | Type | Description |
|---|
$message | string | |
$level | LogLevel | |
$name | string | |
public debug(mixed $data, ?string $name): bool
| Parameter | Type | Description |
|---|
$data | mixed | |
$name | string | |
public spawn(string $service, array $params): bool
| Parameter | Type | Description |
|---|
$service | string | |
$params | array | |
public kill(string $service): bool
| Parameter | Type | Description |
|---|
$service | string | |
public status(): \stdClass
public exec(callable $callable, array $params, ?string $tag, bool $overwrite): string
| Parameter | Type | Description |
|---|
$callable | callable | this can be a string in the format 'Class::method' or a callable function |
$params | array | |
$tag | string | |
$overwrite | bool | |
public execDelay(int $delay, callable $callable, array $params, ?string $tag, bool $overwrite): string
| Parameter | Type | Description |
|---|
$delay | int | |
$callable | callable | this can be a string in the format 'Class::method' or a callable function |
$params | array | |
$tag | string | |
$overwrite | bool | |
public interval(int $seconds, string $callable, array $params, ?string $tag, bool $overwrite): string
| Parameter | Type | Description |
|---|
$seconds | int | |
$callable | string | |
$params | array | |
$tag | string | |
$overwrite | bool | |
public schedule(DateTime $when, string $callable, array $params, ?string $tag, bool $overwrite): string
| Parameter | Type | Description |
|---|
$when | DateTime | |
$callable | string | |
$params | array | |
$tag | string | |
$overwrite | bool | |
public cancelTask(string $taskID): bool
| Parameter | Type | Description |
|---|
$taskID | string | |
public startService(string $name): bool
| Parameter | Type | Description |
|---|
$name | string | |
public stopService(string $name): bool
| Parameter | Type | Description |
|---|
$name | string | |
public service(string $name): string
| Parameter | Type | Description |
|---|
$name | string | |
public get(string $key, ?string $namespace): mixed
| Parameter | Type | Description |
|---|
$key | string | |
$namespace | string | |
public set(string $key, mixed $value, ?int $timeout, ?string $namespace): bool
| Parameter | Type | Description |
|---|
$key | string | |
$value | mixed | |
$timeout | int | |
$namespace | string | |
public has(string $key, ?string $namespace): bool
| Parameter | Type | Description |
|---|
$key | string | |
$namespace | string | |
public del(string $key, ?string $namespace): bool
| Parameter | Type | Description |
|---|
$key | string | |
$namespace | string | |
public clear(?string $namespace): bool
| Parameter | Type | Description |
|---|
$namespace | string | |
List all keys in the key-value store.
public (?string $namespace): void
If a namespace is provided, it will list keys only in that namespace.
| Parameter | Type | Description |
|---|
$namespace | string | |
public pull(string $key, ?string $namespace): mixed
| Parameter | Type | Description |
|---|
$key | string | |
$namespace | string | |
public push(string $key, mixed $value, ?string $namespace): bool
| Parameter | Type | Description |
|---|
$key | string | |
$value | mixed | |
$namespace | string | |
public pop(string $key, ?string $namespace): mixed
| Parameter | Type | Description |
|---|
$key | string | |
$namespace | string | |
public shift(string $key, ?string $namespace): mixed
| Parameter | Type | Description |
|---|
$key | string | |
$namespace | string | |
public unshift(string $key, mixed $value, ?string $namespace): bool
| Parameter | Type | Description |
|---|
$key | string | |
$value | mixed | |
$namespace | string | |
public incr(string $key, ?int $step, ?string $namespace): int
| Parameter | Type | Description |
|---|
$key | string | |
$step | int | |
$namespace | string | |
public decr(string $key, ?int $step, ?string $namespace): int
| Parameter | Type | Description |
|---|
$key | string | |
$step | int | |
$namespace | string | |
Get all keys in the key-value store.
public keys(?string $namespace): void
If a namespace is provided, it will return keys only in that namespace.
| Parameter | Type | Description |
|---|
$namespace | string | |
Get all values in the key-value store.
public vals(?string $namespace): void
If a namespace is provided, it will return values only in that namespace.
| Parameter | Type | Description |
|---|
$namespace | string | |
Count the number of keys in the key-value store.
public count(string $key, ?string $namespace): int
If a namespace is provided, it will count keys only in that namespace.
| Parameter | Type | Description |
|---|
$key | string | |
$namespace | string | |
public connect(?string $username, ?string $password): bool
| Parameter | Type | Description |
|---|
$username | string | |
$password | string | |
public disconnect(): bool
public authenticated(): bool
public authenticate(string $username, string $password): bool
| Parameter | Type | Description |
|---|
$username | string | |
$password | string | |
public main(?array $params, bool $dynamic): int
| Parameter | Type | Description |
|---|
$params | array | |
$dynamic | bool | |
public stop(bool $force, ?string $pid): bool
| Parameter | Type | Description |
|---|
$force | bool | |
$pid | string | |
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): 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.
| Parameter | Type | Description |
|---|
$timeout | int | number of seconds to sleep for |
$checkStatus | 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. |
protected createConnection(Protocol $protocol, ?string $guid): false
| Parameter | Type | Description |
|---|
$protocol | Protocol | |
$guid | string | |
protected setErrorHandler(string $methodName): void
| Parameter | Type | Description |
|---|
$methodName | string | |
protected setExceptionHandler(string $methodName): void
| Parameter | Type | Description |
|---|
$methodName | string | |
protected processCommand(PacketType $command, ?\stdClass $payload): bool
| Parameter | Type | Description |
|---|
$command | PacketType | |
$payload | \stdClass | |
private sendExec(string $command, mixed $data, callable $callable, ?array $params, ?string $tag, bool $overwrite): string
| Parameter | Type | Description |
|---|
$command | string | |
$data | mixed | |
$callable | callable | this can be a string in the format 'Class::method' or a callable function |
$params | array | |
$tag | string | |
$overwrite | bool | |
Generated by Hazaar API Doc Generator on Fri, 05 Jun 2026 06:08:15 +0000