示例#1
0
 /**
  * addBucketInput
  *
  * @param Riak\Bucket $bucket
  *
  * @return $this
  */
 public function addBucketInput(Riak\Bucket $bucket)
 {
     // default bucket type cannot be passed to the MR api due to a bug
     if ($bucket->getType() == 'default') {
         $input = $bucket->getName();
     } else {
         $input = [$bucket->getType(), $bucket->getName()];
     }
     $this->inputs[] = $input;
     return $this;
 }
示例#2
0
 public function __construct($statusCode, $headers = [], $body = '', Bucket $bucket = null)
 {
     parent::__construct($statusCode, $headers, $body);
     // make sure body is not only whitespace
     if (trim($body)) {
         $properties = json_decode($this->body, true);
         if ($bucket) {
             $this->bucket = new Bucket($bucket->getName(), $bucket->getType(), $properties['props']);
         }
     }
 }
示例#3
0
 /**
  * Generates the URL path for a 2i Query
  *
  * @param Bucket $bucket
  * @return string
  * @throws Exception if 2i query is invalid.
  */
 private function createIndexQueryPath(Bucket $bucket)
 {
     /**  @var Command\Indexes\Query $command */
     $command = $this->command;
     if ($command->isMatchQuery()) {
         $path = sprintf('/types/%s/buckets/%s/index/%s/%s', $bucket->getType(), $bucket->getName(), $command->getIndexName(), $command->getMatchValue());
     } elseif ($command->isRangeQuery()) {
         $path = sprintf('/types/%s/buckets/%s/index/%s/%s/%s', $bucket->getType(), $bucket->getName(), $command->getIndexName(), $command->getLowerBound(), $command->getUpperBound());
     } else {
         throw new Exception("Invalid Secondary Index Query.");
     }
     return $path;
 }
示例#4
0
 /**
  * @param Pb\Message\RpbGetReq|Pb\Message\RpbPutReq|\ProtobufMessage $message
  * @param Bucket|null $bucket
  */
 protected function setBucketOnMessage(\ProtobufMessage &$message, Bucket $bucket = null)
 {
     if (!empty($bucket)) {
         $message->setBucket($bucket->getName());
         $message->setType($bucket->getType());
     }
 }