PHP Класс Disque\Connection\Manager

Наследование: implements Disque\Connection\ManagerInterface
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$credentials Disque\Connection\Credentials[] After connecting to one, the server returns a list of other nodes in the cluster so we can connect to them automatically, unless the discovered nodes are secured with a password. 'serverAddress' => Credentials
$nodeId string The ID of the node we are currently connected to
$nodePrefixes array Node prefix consists of the first 8 bytes from the node ID. Because job IDs contain the node prefix, it can be used to identify on which node a job lives. 'nodePrefix' => 'nodeId'
$nodes Disque\Connection\Node\Node[] 'nodeId' => Node
$priorityStrategy Disque\Connection\Node\NodePrioritizerInterface The default strategy is the ConservativeJobCountPrioritizer. It prioritizes nodes by their job count, but prefers the current node in order to avoid switching until there is a clearly better node.

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

Метод Описание
__construct ( )
addServer ( Disque\Connection\Credentials $credentials )
connect ( )
execute ( Disque\Command\CommandInterface $command )
getConnectionFactory ( )
getCredentials ( )
getCurrentNode ( )
getPriorityStrategy ( )
isConnected ( )
setConnectionFactory ( Disque\Connection\Factory\ConnectionFactoryInterface $connectionFactory )
setPriorityStrategy ( Disque\Connection\Node\NodePrioritizerInterface $priorityStrategy )

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

Метод Описание
findAvailableConnection ( ) : Node Get a functional connection to any known node
getNodeConnection ( Disque\Connection\Credentials $server ) : Node Connect to the node given in the credentials
postprocessExecution ( Disque\Command\CommandInterface $command, mixed $response ) : mixed Postprocess the command execution, eg. update node stats
preprocessExecution ( Disque\Command\CommandInterface $command ) : Disque\Command\CommandInterface Hook into the command execution and do anything before it's executed
resetNodeCounters ( ) Reset node counters that should be reset upon node switch
updateNodeStats ( array $jobs ) Update node counters indicating how many jobs the node has produced

Приватные методы

Метод Описание
copyNodeStats ( Node $oldNode, Node $newNode ) Copy node stats from the old to the new node
createNode ( Disque\Connection\Credentials $credentials ) : Node Create a new Node object
getNodeIdFromJobId ( string $jobId ) : string | null Get a node ID based off a Job ID
getNodePrefixFromJobId ( string $jobId ) : string Get the node prefix from the job ID
revealClusterFromHello ( Node $node ) Reveal the whole Disque cluster from a node HELLO response
revealNodeFromHello ( string $nodeId, array $node ) : Node Reveal a single node from a HELLO response, or use an existing node
shouldBeConnected ( ) : void We should be connected
switchNodeIfNeeded ( ) Decide if we should switch to a better node
switchToNode ( Node $node ) Switch to the given node and map the cluster from its HELLO
wasAlreadyConnected ( ) : boolean Check if the manager held a connection to Disque already

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

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

public __construct ( )

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

public addServer ( Disque\Connection\Credentials $credentials )
$credentials Disque\Connection\Credentials

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

public connect ( )

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

public execute ( Disque\Command\CommandInterface $command )
$command Disque\Command\CommandInterface

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

Disque suggests the first connection should be chosen randomly We go through the user-supplied credentials randomly and try to connect.
protected findAvailableConnection ( ) : Node
Результат Disque\Connection\Node\Node A connected node

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

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

public getCredentials ( )

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

public getCurrentNode ( )

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

Connect to the node given in the credentials
protected getNodeConnection ( Disque\Connection\Credentials $server ) : Node
$server Disque\Connection\Credentials
Результат Disque\Connection\Node\Node A connected node

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

public getPriorityStrategy ( )

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

public isConnected ( )

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

Postprocess the command execution, eg. update node stats
protected postprocessExecution ( Disque\Command\CommandInterface $command, mixed $response ) : mixed
$command Disque\Command\CommandInterface
$response mixed
Результат mixed

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

Eg. start measuring node latency etc.
protected preprocessExecution ( Disque\Command\CommandInterface $command ) : Disque\Command\CommandInterface
$command Disque\Command\CommandInterface
Результат Disque\Command\CommandInterface $command

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

Reset node counters that should be reset upon node switch
protected resetNodeCounters ( )

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

public setConnectionFactory ( Disque\Connection\Factory\ConnectionFactoryInterface $connectionFactory )
$connectionFactory Disque\Connection\Factory\ConnectionFactoryInterface

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

public setPriorityStrategy ( Disque\Connection\Node\NodePrioritizerInterface $priorityStrategy )
$priorityStrategy Disque\Connection\Node\NodePrioritizerInterface

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

Update node counters indicating how many jobs the node has produced
protected updateNodeStats ( array $jobs )
$jobs array Jobs

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

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

After connecting to one, the server returns a list of other nodes in the cluster so we can connect to them automatically, unless the discovered nodes are secured with a password. 'serverAddress' => Credentials
protected Credentials[],Disque\Connection $credentials
Результат Disque\Connection\Credentials[]

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

The ID of the node we are currently connected to
protected string $nodeId
Результат string

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

Node prefix consists of the first 8 bytes from the node ID. Because job IDs contain the node prefix, it can be used to identify on which node a job lives. 'nodePrefix' => 'nodeId'
protected array $nodePrefixes
Результат array

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

'nodeId' => Node
protected Node[],Disque\Connection\Node $nodes
Результат Disque\Connection\Node\Node[]

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

The default strategy is the ConservativeJobCountPrioritizer. It prioritizes nodes by their job count, but prefers the current node in order to avoid switching until there is a clearly better node.
protected NodePrioritizerInterface,Disque\Connection\Node $priorityStrategy
Результат Disque\Connection\Node\NodePrioritizerInterface