PHP Class Disque\Connection\Node\Node

Show file Open project: mariano/disque-php Class Usage Examples

Public Methods

Method Description
__construct ( Disque\Connection\Credentials $credentials, Disque\Connection\ConnectionInterface $connection )
addJobCount ( integer $jobsAdded ) Increase the node job counts by the given number
connect ( ) : array Connect to the node and return the HELLO response
execute ( Disque\Command\CommandInterface $command ) : mixed Execute a command on this Disque node
getConnection ( ) : Disque\Connection\ConnectionInterface Get the node connection
getCredentials ( ) : Disque\Connection\Credentials Get the node credentials
getHello ( ) : array Get the node's last HELLO response
getId ( ) : string Get the node ID
getJobCount ( ) : integer Get the node job count since the last reset (usually a node switch)
getPrefix ( ) : string Get the node prefix - the first 8 bytes from the ID
getPriority ( ) : integer Get the node priority as set by the cluster. 1-100, lower is better.
getTotalJobCount ( ) : integer Get the total job count since the node instantiation
isConnected ( ) : boolean Check if this object holds a working connection to Disque node
resetJobCount ( ) Reset the node job count
sayHello ( ) : array Say a new HELLO to the node and parse the response
setPriority ( integer $priority )

Private Methods

Method Description
authenticateWithPassword ( ) Authenticate with the node with a password, if set
connectToTheNode ( ) Connect to the node
createPrefix ( string $id ) Create a node prefix from the node ID
readPriorityFromHello ( array $hello, string $id ) : integer Read out the node's own priority from a HELLO response

Method Details

__construct() public method

public __construct ( Disque\Connection\Credentials $credentials, Disque\Connection\ConnectionInterface $connection )
$credentials Disque\Connection\Credentials
$connection Disque\Connection\ConnectionInterface

addJobCount() public method

Increase the node job counts by the given number
public addJobCount ( integer $jobsAdded )
$jobsAdded integer

connect() public method

This method is idempotent and can be called multiple times
public connect ( ) : array
return array The HELLO response

execute() public method

Execute a command on this Disque node
public execute ( Disque\Command\CommandInterface $command ) : mixed
$command Disque\Command\CommandInterface
return mixed Response

getConnection() public method

Get the node connection
public getConnection ( ) : Disque\Connection\ConnectionInterface
return Disque\Connection\ConnectionInterface

getCredentials() public method

Get the node credentials
public getCredentials ( ) : Disque\Connection\Credentials
return Disque\Connection\Credentials

getHello() public method

Get the node's last HELLO response
public getHello ( ) : array
return array

getId() public method

Get the node ID
public getId ( ) : string
return string

getJobCount() public method

Get the node job count since the last reset (usually a node switch)
public getJobCount ( ) : integer
return integer

getPrefix() public method

Get the node prefix - the first 8 bytes from the ID
public getPrefix ( ) : string
return string

getPriority() public method

Get the node priority as set by the cluster. 1-100, lower is better.
public getPriority ( ) : integer
return integer

getTotalJobCount() public method

Get the total job count since the node instantiation
public getTotalJobCount ( ) : integer
return integer

isConnected() public method

Check if this object holds a working connection to Disque node
public isConnected ( ) : boolean
return boolean

resetJobCount() public method

Reset the node job count
public resetJobCount ( )

sayHello() public method

Say a new HELLO to the node and parse the response
public sayHello ( ) : array
return array The HELLO response

setPriority() public method

public setPriority ( integer $priority )
$priority integer Disque priority as revealed by a HELLO