Master
Master
Properties
instance
public Master $instance
config
public Config $config
tasks
Main task queue.
public array $tasks
protocol
public Protocol $protocol
pcntlSignals
Signals that we will capture.
public array $pcntlSignals
cluster
public Cluster $cluster
silent
Enable silent mode.
private bool $silent
running
private bool $running
shutdown
public int $shutdown
tags
Task tags.
private array $tags
start
Epoch of when Warlock was started.
private int $start
time
Epoch of the last time stuff was processed.
private int $time
pid
Current process id.
private int $pid
pidfile
Current process id file.
private string $pidfile
tv
Default select() timeout.
private int $tv
stats
private $stats
rrd
private Metric $rrd
log
private Logger $log
services
Application services.
private array $services
subscriptions
The wait queue. Clients subscribe to events and are added to this array.
private array $subscriptions
events
The Event queue. Holds active events waiting to be seen.
private array $events
globals
The global event queue. Holds details about tasks that need to start up to process global events.
private array $globals
master
The main socket for listening for incomming connections.
private $master
streams
Currently connected stream resources we are listening for data on.
private $streams
clients
Currently connected clients.
private $clients
admins
private array $admins
kvStore
public KVStore $kvStore
exitCodes
private array $exitCodes
Methods
__construct
Warlock server constructor.
public __construct({Array})
The constructor here is responsible for setting up internal structures, initialising logging, RRD logging, redirecting output to log files and configuring error and exception handling.
Parameters
Parameter | Type | Description |
---|---|---|
$env | string | |
$silent | bool | By default, log output will be displayed on the screen. Silent mode will redirect all |
log output to a file. |
__destruct
Final cleanup of the PID file and logs the exit.
public __destruct({Array})
__errorHandler
public __errorHandler({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$errno | int | |
$errstr | string | |
$errfile | string | |
$errline | int |
__exceptionHandler
public __exceptionHandler({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$e | \Throwable |
__signalHandler
private __signalHandler({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$signo | int | |
$siginfo | mixed |
loadConfig
public loadConfig({Array})
shutdown
Initiate a server shutdown.
public shutdown({Array})
Because this server manages running services, it's not really a good idea to just simply exist abruptly. This method will initiate a server shutdown which will nicely stop all services and once all services stop, the server will terminate safely.
Parameters
Parameter | Type | Description |
---|---|---|
$delay | int | how long in seconds before the shutdown should commence |
getRuntimePath
Returns the application runtime directory.
public getRuntimePath({Array})
The runtime directory is a place where HazaarMVC will keep files that it needs to create during normal operation. For example, cached views, and backend applications.
Parameters
Parameter | Type | Description |
---|---|---|
$suffix | NULL | An optional suffix to tack on the end of the path |
$create_dir | boolean | if the runtime directory does not yet exist, try and create it (requires write permission) |
bootstrap
Prepares the server ready to get up and running.
public bootstrap({Array})
Bootstrapping the server allows us to restart an existing server instance without having to reinstantiate it which allows the server to essentially restart itself in memory.
run
The main server run loop.
public run({Array})
This method will not return for as long as the server is running. While it is running it will process tasks, monitor services and distribute server signals.
authorise
public authorise({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$client | Client | |
$key | string |
disconnect
public disconnect({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$stream | mixed |
processCommand
Process administative commands for a client.
public processCommand({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$client | Client | |
$command | mixed | |
$payload | mixed |
trigger
public trigger({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$eventID | string | |
$data | mixed | |
$clientID | string | |
$triggerID | string |
subscribe
Subscribe a client to an event.
public subscribe({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$client | Client | The client to subscribe |
$eventID | string | The event ID to subscribe to |
$filter | array | Any event filters |
unsubscribe
Unsubscibe a client from an event.
public unsubscribe({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$client | Client | The client to unsubscribe |
$eventID | string | The event ID to unsubscribe from |
announce
public announce({Array})
clientAdd
public clientAdd({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$stream | mixed | |
$client | Client |
clientReplace
public clientReplace({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$stream | mixed | |
$client | Client |
clientRemove
Removes a client from a stream.
public clientRemove({Array})
Because a client can have multiple stream connections (in legacy mode) this removes the client reference for that stream. Once there are no more references left the client is completely removed.
Parameters
Parameter | Type | Description |
---|---|---|
$stream | mixed |
isRunning
Check if the server is already running.
private isRunning({Array})
This checks if the PID file exists, grabs the PID from that file and checks to see if a process with that ID is actually running.
clientGet
Retrieve a client object for a stream resource.
private clientGet({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$stream | mixed | The stream resource |
clientProcess
private clientProcess({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$stream | mixed |
clientCheck
private clientCheck({Array})
getStatus
private getStatus({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$full | bool |
spawn
private spawn({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$client | Client | |
$name | string | |
$options | array |
kill
private kill({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$client | Client | |
$name | string |
signal
private signal({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$client | Client | |
$eventID | string | |
$service | string | |
$data | mixed |
scheduleRunner
private scheduleRunner({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$start | int | |
$exec | \stdClass | |
$application | Struct\Application | |
$tag | string | |
$overwrite | bool |
taskCancel
private taskCancel({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$taskID | string |
taskProcess
Main process loop.
private taskProcess({Array})
This method will monitor and manage queued running tasks.
taskMonitor
private taskMonitor({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$task | Task |
taskQueueAdd
private taskQueueAdd({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$task | Task |
eventCleanup
private eventCleanup({Array})
fieldExists
private fieldExists({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$search | array | |
$array | \stdClass |
getFieldValue
private getFieldValue({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$search | array | |
$array | \stdClass |
eventFilter
Tests whether a event should be filtered.
private eventFilter({Array})
Returns true if the event should be filtered (skipped), and false if the event should be processed.
Parameters
Parameter | Type | Description |
---|---|---|
$event | mixed | the event to check |
$filter | array | the filter rule to test against |
eventProcess
Process the event queue for a specified client.
private eventProcess({Array})
This method is executed when a client connects to see if there are any events waiting in the event queue that the client has not yet seen. If there are, the first event found is sent to the client, marked as seen and then processing stops.
Parameters
Parameter | Type | Description |
---|---|---|
$client | Client | |
$eventID | string | |
$filter | array |
subscriptionProcess
Process all subscriptions for a specified event.
private subscriptionProcess({Array})
This method is executed when a event is triggered. It is responsible for sending events to clients that are waiting for the event and marking them as seen by the client.
Parameters
Parameter | Type | Description |
---|---|---|
$eventID | string | |
$triggerID | string |
serviceEnable
private serviceEnable({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$name | string |
serviceDisable
private serviceDisable({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$name | string |
private ({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$value | mixed |
rotateLogFiles
private rotateLogFiles({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$logfiles | int |
Generated by Hazaar API Doc Generator