/**
  * @param AdapterInterface $adapter
  */
 public function addAdapter(AdapterInterface $adapter)
 {
     if (!$adapter->getHttpClient()) {
         $adapter->setHttpClient(new \GuzzleHttp\Client());
     }
     $this->adapters[] = $adapter;
 }
Esempio n. 2
0
 /**
  * Wait for the processes started via call().
  *
  * @param int $pid The pid to wait for, if none is passed then all threads created by this object will be waited for
  *
  * @return void
  */
 public function wait($pid = null)
 {
     if ($pid) {
         $threads = [$pid];
     } else {
         $threads = $this->threads;
     }
     $error = 0;
     $status = 0;
     foreach ($threads as $pid) {
         $status = $this->adapter->wait($pid);
         if ($status > 0) {
             $error = $status;
         }
         unset($this->threads[$pid]);
     }
     # If no errors occured then we're done
     if ($error === 0) {
         return;
     }
     $exceptions = $this->adapter->getExceptions();
     $message = "An error occurred within a thread, the return code was: {$error}\n";
     foreach ($exceptions as $exception) {
         $message .= "  - {$exception}\n";
     }
     throw new Exception($message, $error);
 }
Esempio n. 3
0
 /**
  * Upload image
  *
  * @param ImageInterface $image   Image entity
  * @param string         $path    Image source path
  * @param array          $options Upload options
  *
  * @return ImageInterface
  */
 public function upload(ImageInterface $image, $path, array $options = [])
 {
     $itemLength = $this->adapter->directoryLength($this->fileSystem->getCurrentDirectory());
     $image = $this->fileSystem->hydrateImageInfo($image, $path);
     $destination = $this->fileSystem->defineImagePath($image, $itemLength);
     $this->adapter->upload($path, $destination, $options);
     $image->setPath($destination);
     return $image;
 }
Esempio n. 4
0
 /**
  */
 public function test_saveDeffered()
 {
     $item = \Mockery::mock('Dspacelabs\\Component\\Cache\\CacheItemInterface');
     $this->adapter->shouldReceive('saveItem')->once()->with($item);
     $this->pool->saveDeffered($item);
     $this->pool->commit();
 }
Esempio n. 5
0
 public function getNumberOfResults()
 {
     if (-1 === $this->numberOfResults) {
         $this->numberOfResults = $this->adapter->getNumberOfResults($this->queryParameters, $this->uriParameters);
     }
     return $this->numberOfResults;
 }
Esempio n. 6
0
 /**
  * @return \Magento\Framework\DB\Select
  */
 public function getLogDataSelect()
 {
     $fields = ['visitor_id' => 'lv.visitor_id', 'customer_id' => 'lc.customer_id', 'session_id' => 'lv.session_id', 'last_visit_at' => 'lv.last_visit_at'];
     /** @var \Magento\Framework\DB\Select $select */
     $select = $this->sourceAdapter->getSelect();
     $select->from(['lv' => $this->source->addDocumentPrefix('log_visitor')], $fields)->joinLeft(['lc' => $this->source->addDocumentPrefix('log_customer')], 'lv.visitor_id = lc.visitor_id', [])->group('lv.visitor_id')->order('lv.visitor_id');
     return $select;
 }
Esempio n. 7
0
 /**
  * Resolve timeouts
  * Retrieves all expired timeouts and triggers proper events
  * Return array of run histories
  *
  * @return array
  */
 public function resolveTimeouts()
 {
     $this->lockHandler->releaseTimedOut(new \DateInterval(self::LOCK_TIMEOUT_INTERVAL));
     $result = [];
     $process = $this->adapter->getProcess();
     $timeouts = $this->timeoutHandler->getExpired();
     foreach ($timeouts as $timeout) {
         $this->resolveTimeout($process, $timeout, $result);
     }
     return $result;
 }
Esempio n. 8
0
 public function testResolveTimeoutsWithPayloadInCorrectState()
 {
     $timeout = $this->getMockBuilder('\\StateMachine\\PayloadTimeout')->disableOriginalConstructor()->getMock();
     $timeout->expects($this->any())->method('getState')->willReturn('timeout');
     $this->timeoutHandler->expects($this->any())->method('getExpired')->willReturn([$timeout]);
     $this->payload->expects($this->any())->method('getState')->willReturn('timeout');
     $this->payloadHandler->expects($this->any())->method('restore')->willReturn($this->payload);
     $this->adapter->expects($this->any())->method('getProcess')->willReturn($this->process);
     $this->process->expects($this->once())->method('triggerEvent');
     $this->timeoutHandler->expects($this->once())->method('remove');
     $machine = new StateMachine($this->adapter, $this->payloadHandler, $this->timeoutHandler, $this->lockHandler);
     $machine->resolveTimeouts();
 }
Esempio n. 9
0
 /**
  * Call method authenticate() of adater class
  *
  * @return bool
  */
 public function authenticate()
 {
     return $this->adapter->authenticate();
 }
Esempio n. 10
0
 /**
  *
  */
 public function testCreateTable()
 {
     $this->pdo->expects($this->once())->method('exec')->with($this->equalTo("CREATE TABLE IF NOT EXISTS `migrations` (\n  `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,\n  `name` VARCHAR(255) NOT NULL,\n  `migration` VARCHAR(255) NOT NULL,\n  `direction` TINYINT(1) UNSIGNED NOT NULL,\n  `migrated_on` DATETIME NOT NULL,\n  PRIMARY KEY (`id`))"));
     $this->adapter->setup();
 }
Esempio n. 11
0
 /**
  * Retrieves tables list
  *
  * @param string $schema
  * @return array
  */
 public function getTables($schema)
 {
     return $this->_adapter->getTables($schema);
 }
Esempio n. 12
0
 /**
  * Send a raw HTTP request
  * 
  * @param \apiTalk\Request $request The request object
  * 
  * @return \apiTalk\Response The response object  
  */
 public function send(Request $request)
 {
     return $this->adapter->send($request);
 }
Esempio n. 13
0
 /**
  * Class constructor.
  *
  * Consumes Phalcon paginator adapter and options array.
  * Option keys:
  *     - rangeClass:  Class name which determines scrolling style type (e.g. Phalcon\Paginator\Pager\Range\Sliding).
  *                    Defaults to "Phalcon\Paginator\Pager\Range\Sliding".
  *     - rangeLength: Size of range to be used. Default size is 10.
  *     - layoutClass: Used with getLayout() method. Defaults to "Phalcon\Paginator\Pager\Layout".
  *     - urlMask:     Required with getLayout() method.
  *
  * @param \Phalcon\Paginator\AdapterInterface $adapter Phalcon paginator adapter
  * @param array                               $options options array
  *
  */
 public function __construct(AdapterInterface $adapter, array $options = array())
 {
     $this->paginateResult = $adapter->getPaginate();
     $this->limit = $adapter->getLimit();
     $this->options = $options;
 }
Esempio n. 14
0
 /**
  * 强制删除缓存中的某个key
  */
 public function delete($key)
 {
     unset($this->_pool[$key]);
     $this->_adapter->deleteCacheKey($key);
 }
Esempio n. 15
0
 /**
  * @param string $component Name of the component to render
  * @param array  $data      Data to pass to the component
  *
  * @return string
  */
 public function render($component, array $data = [])
 {
     return $this->adapter->render($component, $data);
 }
Esempio n. 16
0
 /**
  * @param string $message
  * @param array $params
  * @return MessageSentInterface
  */
 public function sendMessage($message, array $params = [])
 {
     return $this->adapter->sendMessage($message, $params);
 }
 /**
  * Delete multiple records from document
  *
  * @param string $documentName
  * @param string $idKey
  * @param [] $ids
  * @return void
  */
 public function deleteRecords($documentName, $idKey, $ids)
 {
     $this->adapter->deleteRecords($documentName, $idKey, $ids);
 }
Esempio n. 18
0
 /**
  * {@inheritdoc}
  */
 public function search(RequestInterface $request)
 {
     return $this->adapter->query($request);
 }