PHP Class PHPDaemon\Network\Client

Author: Vasily Zorin ([email protected])
Inheritance: extends Pool
Afficher le fichier Open project: kakserpom/phpdaemon Class Usage Examples

Protected Properties

Свойство Type Description
$acquireOnGet boolean
$maxConnPerServ integer
$pending array
$servConn Active connections
$servConnFree array
$servers Array of servers

Méthodes publiques

Méthode Description
addServer ( string $url, integer $weight = null ) : void Adds server
detach ( object $conn ) : void Detach Connection
detachConnFromUrl ( ClientConnection $conn, string $url ) : void Detaches connection from URL
getConnection ( string $url = null, callback $cb = null, integer $pri ) : boolean Returns available connection from the pool
getConnectionByKey ( string $key, callable $cb = null ) : boolean Returns available connection from the pool by key
getConnectionRR ( callable $cb = null ) : boolean Returns available connection from the pool
markConnBusy ( ClientConnection $conn, string $url ) : void Mark connection as busy
markConnFree ( ClientConnection $conn, string $url ) : void Mark connection as free
onShutdown ( boolean $graceful = false ) : boolean Called when application instance is going to shutdown
requestByKey ( string $key, string $data, callable $onResponse = null ) : boolean Sends a request to server according to the key
requestByServer ( string $server, string $data, callable $onResponse = null ) : boolean Sends a request to arbitrary server
touchPending ( string $url ) : void Touch pending "requests for connection"

Méthodes protégées

Méthode Description
applyConfig ( ) : void Applies config
getConfigDefaults ( ) : array Setting default config options Overriden from ConnectionPool::getConfigDefaults

Method Details

addServer() public méthode

Adds server
public addServer ( string $url, integer $weight = null ) : void
$url string Server URL
$weight integer Weight
Résultat void

applyConfig() protected méthode

Applies config
protected applyConfig ( ) : void
Résultat void

detach() public méthode

Detach Connection
public detach ( object $conn ) : void
$conn object Connection
Résultat void

detachConnFromUrl() public méthode

Detaches connection from URL
public detachConnFromUrl ( ClientConnection $conn, string $url ) : void
$conn ClientConnection Connection
$url string URL
Résultat void

getConfigDefaults() protected méthode

Setting default config options Overriden from ConnectionPool::getConfigDefaults
protected getConfigDefaults ( ) : array
Résultat array

getConnection() public méthode

Returns available connection from the pool
public getConnection ( string $url = null, callback $cb = null, integer $pri ) : boolean
$url string Address
$cb callback onConnected
$pri integer Optional. Priority
Résultat boolean Success|Connection

getConnectionByKey() public méthode

Returns available connection from the pool by key
public getConnectionByKey ( string $key, callable $cb = null ) : boolean
$key string Key
$cb callable Callback
Résultat boolean Success

getConnectionRR() public méthode

Returns available connection from the pool
public getConnectionRR ( callable $cb = null ) : boolean
$cb callable Callback
Résultat boolean Success

markConnBusy() public méthode

Mark connection as busy
public markConnBusy ( ClientConnection $conn, string $url ) : void
$conn ClientConnection Connection
$url string URL
Résultat void

markConnFree() public méthode

Mark connection as free
public markConnFree ( ClientConnection $conn, string $url ) : void
$conn ClientConnection Connection
$url string URL
Résultat void

onShutdown() public méthode

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

requestByKey() public méthode

Sends a request to server according to the key
public requestByKey ( string $key, string $data, callable $onResponse = null ) : boolean
$key string Key
$data string Data
$onResponse callable Callback called when the request complete
Résultat boolean Success

requestByServer() public méthode

Sends a request to arbitrary server
public requestByServer ( string $server, string $data, callable $onResponse = null ) : boolean
$server string Server
$data string Data
$onResponse callable Called when the request complete
Résultat boolean Success

touchPending() public méthode

Touch pending "requests for connection"
public touchPending ( string $url ) : void
$url string URL
Résultat void

Property Details

$acquireOnGet protected_oe property

protected bool $acquireOnGet
Résultat boolean

$maxConnPerServ protected_oe property

protected int $maxConnPerServ
Résultat integer

$pending protected_oe property

protected array $pending
Résultat array

$servConn protected_oe property

Active connections
protected $servConn

$servConnFree protected_oe property

protected array $servConnFree
Résultat array

$servers protected_oe property

Array of servers
protected $servers