PHP Class PHPDaemon\Core\AppInstance

Author: Vasily Zorin ([email protected])
Inheritance: use trait PHPDaemon\Traits\ClassWatchdog, use trait PHPDaemon\Traits\StaticObjectWatchdog
Afficher le fichier Open project: kakserpom/phpdaemon Class Usage Examples

Méthodes publiques

Свойство Type Description
$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 Properties

Свойство Type Description
$name Instance name

Méthodes publiques

Méthode Description
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

Méthodes protégées

Méthode Description
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

Method Details

RPCall() public méthode

Function handles incoming Remote Procedure Calls You can override it
public RPCall ( string $method, array $args ) : mixed
$method string Method name
$args array Arguments
Résultat mixed Result

__construct() public méthode

Application constructor
public __construct ( string $name = '' ) : void
$name string Instance name
Résultat void

beginRequest() public méthode

Create Request instance
public beginRequest ( object $req, object $upstream ) : object
$req object Generic
$upstream object Upstream application instance
Résultat object Request

broadcastCall() public méthode

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
Résultat boolean Success

directCall() public méthode

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
Résultat boolean Success

getConfig() public méthode

Returns a config section
public getConfig ( ) : Section
Résultat PHPDaemon\Config\Section

getConfigDefaults() protected méthode

Function to get default config options from application Override to set your own
protected getConfigDefaults ( ) : boolean
Résultat boolean

getInstance() public static méthode

public static getInstance ( string $name, boolean $spawn = true ) : AppInstance
$name string Instance name
$spawn boolean If true, we spawn an instance if absent
Résultat AppInstance

getName() public méthode

Returns the instance name
public getName ( ) : string
Résultat string

handleRequest() public méthode

Handle the request
public handleRequest ( object $parent, object $upstream ) : object
$parent object Parent request
$upstream object Upstream application
Résultat object Request

handleStatus() public méthode

Handle the worker status
public handleStatus ( integer $ret ) : boolean
$ret integer Status code
Résultat boolean Result

init() protected méthode

Called when creates instance of the application
protected init ( ) : void
Résultat void

isEnabled() public méthode

Returns whether if this application is enabled
public isEnabled ( ) : boolean
Résultat boolean

log() public méthode

Log something
public log ( string $message ) : void
$message string Message
Résultat void

onConfigUpdated() public méthode

Called when worker is going to update configuration
public onConfigUpdated ( ) : void
Résultat void

onReady() public méthode

Called when the worker is ready to go
public onReady ( ) : void
Résultat void

onShutdown() protected méthode

Called when application instance is going to shutdown
protected onShutdown ( $graceful = false ) : boolean
Résultat boolean Ready to shutdown?

singleCall() public méthode

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
Résultat boolean Success

Property Details

$config public_oe property

Related config section
public $config

$enableRPC public_oe property

Is RPC enabled?
public $enableRPC

$name protected_oe property

Instance name
protected $name

$passphrase public_oe property

Optional passphrase
public $passphrase

$ready public_oe property

Ready to run?
public $ready

$requestClass public_oe property

Default class of incoming requests
public $requestClass

$runOnDemand public_oe static_oe property

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