Basho\Riak::execute PHP Method

execute() public method

Execute a Riak command
public execute ( Basho\Riak\Command $command ) : Basho\Riak\Command\Response
$command Basho\Riak\Command
return Basho\Riak\Command\Response
    public function execute(Command $command)
    {
        $response = $this->getActiveNode()->execute($command, $this->api);
        // if more than 1 node configured, lets try a different node up to max connection attempts
        if (empty($response) && count($this->nodes) > 1 && $this->attempts < $this->getConfigValue('max_connect_attempts')) {
            $response = $this->pickNewNode()->execute($command);
        } elseif (empty($response) && $this->attempts >= $this->getConfigValue('max_connect_attempts')) {
            throw new Exception('Nodes unreachable. Error Msg: ' . $this->api->getError());
        } elseif ($response == false) {
            throw new Exception('Command failed to execute against Riak. Error Msg: ' . $this->api->getError());
        }
        return $response;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Executes the command against the API
  *
  * @return Command\Response
  */
 public function execute()
 {
     return $this->riak->execute($this);
 }