PHP Class PHPDaemon\Network\Client

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

Protected Properties

Property Type Description
$acquireOnGet boolean
$maxConnPerServ integer
$pending array
$servConn Active connections
$servConnFree array
$servers Array of servers

Public Methods

Method 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"

Protected Methods

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

Method Details

addServer() public method

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

applyConfig() protected method

Applies config
protected applyConfig ( ) : void
return void

detach() public method

Detach Connection
public detach ( object $conn ) : void
$conn object Connection
return void

detachConnFromUrl() public method

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

getConfigDefaults() protected method

Setting default config options Overriden from ConnectionPool::getConfigDefaults
protected getConfigDefaults ( ) : array
return array

getConnection() public method

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
return boolean Success|Connection

getConnectionByKey() public method

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

getConnectionRR() public method

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

markConnBusy() public method

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

markConnFree() public method

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

onShutdown() public method

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

requestByKey() public method

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
return boolean Success

requestByServer() public method

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
return boolean Success

touchPending() public method

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

Property Details

$acquireOnGet protected property

protected bool $acquireOnGet
return boolean

$maxConnPerServ protected property

protected int $maxConnPerServ
return integer

$pending protected property

protected array $pending
return array

$servConn protected property

Active connections
protected $servConn

$servConnFree protected property

protected array $servConnFree
return array

$servers protected property

Array of servers
protected $servers