PHP Класс PHPDaemon\Core\AppInstance

Автор: Vasily Zorin ([email protected])
Наследование: use trait PHPDaemon\Traits\ClassWatchdog, use trait PHPDaemon\Traits\StaticObjectWatchdog
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$config Related config section
$enableRPC Is RPC enabled?
$passphrase Optional passphrase
$ready Ready to run?
$requestClass Default class of incoming requests
$runOnDemand If true, it's allowed to be run without defined config section'

Защищенные свойства (Protected)

Свойство Тип Описание
$name Instance name

Открытые методы

Метод Описание
RPCall ( string $method, array $args ) : mixed Function handles incoming Remote Procedure Calls You can override it
__construct ( string $name = '' ) : void Application constructor
beginRequest ( object $req, object $upstream ) : object Create Request instance
broadcastCall ( string $method, array $args = [], callable $cb = null ) : boolean Send broadcast RPC You can override it
directCall ( integer $workerId, string $method, array $args = [], mixed $cb = null ) : boolean Send RPC, executed once in certain worker You can override it
getConfig ( ) : Section Returns a config section
getInstance ( string $name, boolean $spawn = true ) : AppInstance
getName ( ) : string Returns the instance name
handleRequest ( object $parent, object $upstream ) : object Handle the request
handleStatus ( integer $ret ) : boolean Handle the worker status
isEnabled ( ) : boolean Returns whether if this application is enabled
log ( string $message ) : void Log something
onConfigUpdated ( ) : void Called when worker is going to update configuration
onReady ( ) : void Called when the worker is ready to go
singleCall ( string $method, array $args = [], mixed $cb = null ) : boolean Send RPC, executed once in any worker You can override it

Защищенные методы

Метод Описание
getConfigDefaults ( ) : boolean Function to get default config options from application Override to set your own
init ( ) : void Called when creates instance of the application
onShutdown ( $graceful = false ) : boolean Called when application instance is going to shutdown

Описание методов

RPCall() публичный Метод

Function handles incoming Remote Procedure Calls You can override it
public RPCall ( string $method, array $args ) : mixed
$method string Method name
$args array Arguments
Результат mixed Result

__construct() публичный Метод

Application constructor
public __construct ( string $name = '' ) : void
$name string Instance name
Результат void

beginRequest() публичный Метод

Create Request instance
public beginRequest ( object $req, object $upstream ) : object
$req object Generic
$upstream object Upstream application instance
Результат object Request

broadcastCall() публичный Метод

Send broadcast RPC You can override it
public broadcastCall ( string $method, array $args = [], callable $cb = null ) : boolean
$method string Method name
$args array Arguments
$cb callable Callback
Результат boolean Success

directCall() публичный Метод

Send RPC, executed once in certain worker You can override it
public directCall ( integer $workerId, string $method, array $args = [], mixed $cb = null ) : boolean
$workerId integer Worker Id
$method string Method name
$args array Arguments
$cb mixed Callback
Результат boolean Success

getConfig() публичный Метод

Returns a config section
public getConfig ( ) : Section
Результат PHPDaemon\Config\Section

getConfigDefaults() защищенный Метод

Function to get default config options from application Override to set your own
protected getConfigDefaults ( ) : boolean
Результат boolean

getInstance() публичный статический Метод

public static getInstance ( string $name, boolean $spawn = true ) : AppInstance
$name string Instance name
$spawn boolean If true, we spawn an instance if absent
Результат AppInstance

getName() публичный Метод

Returns the instance name
public getName ( ) : string
Результат string

handleRequest() публичный Метод

Handle the request
public handleRequest ( object $parent, object $upstream ) : object
$parent object Parent request
$upstream object Upstream application
Результат object Request

handleStatus() публичный Метод

Handle the worker status
public handleStatus ( integer $ret ) : boolean
$ret integer Status code
Результат boolean Result

init() защищенный Метод

Called when creates instance of the application
protected init ( ) : void
Результат void

isEnabled() публичный Метод

Returns whether if this application is enabled
public isEnabled ( ) : boolean
Результат boolean

log() публичный Метод

Log something
public log ( string $message ) : void
$message string Message
Результат void

onConfigUpdated() публичный Метод

Called when worker is going to update configuration
public onConfigUpdated ( ) : void
Результат void

onReady() публичный Метод

Called when the worker is ready to go
public onReady ( ) : void
Результат void

onShutdown() защищенный Метод

Called when application instance is going to shutdown
protected onShutdown ( $graceful = false ) : boolean
Результат boolean Ready to shutdown?

singleCall() публичный Метод

Send RPC, executed once in any worker You can override it
public singleCall ( string $method, array $args = [], mixed $cb = null ) : boolean
$method string Method name
$args array Arguments
$cb mixed Callback
Результат boolean Success

Описание свойств

$config публичное свойство

Related config section
public $config

$enableRPC публичное свойство

Is RPC enabled?
public $enableRPC

$name защищенное свойство

Instance name
protected $name

$passphrase публичное свойство

Optional passphrase
public $passphrase

$ready публичное свойство

Ready to run?
public $ready

$requestClass публичное свойство

Default class of incoming requests
public $requestClass

$runOnDemand публичное статическое свойство

If true, it's allowed to be run without defined config section'
public static $runOnDemand