Пример #1
0
 /**
  * @param PreExecuteRequest $event
  */
 public function preExecuteRequest(PreExecuteRequest $event)
 {
     $endpoint = $event->getEndpoint();
     $uri = $event->getRequest()->getUri();
     $path = sprintf('%s://%s:%s%s/%s', $endpoint->getScheme(), $endpoint->getHost(), $endpoint->getPort(), $endpoint->getPath(), urldecode($uri));
     $this->logger->startRequest($path);
 }
Пример #2
0
 public function logPreExecute(PreExecuteRequest $event)
 {
     foreach ($this->requests as &$request) {
         if ($request['request'] === $event->getRequest()) {
             $request['requestStart'] = microtime(TRUE);
             break;
         }
     }
 }
Пример #3
0
 public function testConstructorAndGetters()
 {
     $client = new Client();
     $request = new Request();
     $request->addParam('testparam', 'test value');
     $endpoint = $client->getEndpoint();
     $event = new PreExecuteRequest($request, $endpoint);
     $this->assertEquals($request, $event->getRequest());
     $this->assertEquals($endpoint, $event->getEndpoint());
     return $event;
 }
Пример #4
0
 public function onPreExecuteRequest(PreExecuteRequestEvent $event)
 {
     if (null === $this->currentRequestCacheProfile) {
         return;
     }
     if (null === $this->currentRequestCacheProfile->getKey()) {
         $this->currentRequestCacheProfile->setKey(sha1($event->getRequest()->getUri()));
     }
     $key = $this->currentRequestCacheProfile->getKey();
     if (false === ($serializedResponse = $this->getCache()->fetch($key))) {
         return;
     }
     if (false === ($response = unserialize($serializedResponse))) {
         return;
     }
     $event->setResponse($response);
     $event->stopPropagation();
     // Make sure we do not save the $response in the cache later
     $this->currentRequestCacheProfile = null;
 }
Пример #5
0
 /**
  * @param PreExecuteRequest $event
  */
 public function preExecuteRequest(PreExecuteRequest $event)
 {
     $this->logger->info(sprintf('run request: %s', urldecode($event->getRequest()->getUri())));
 }
 public function preExecuteRequest(PreExecuteRequest $event)
 {
     $this->currentRequest = $event->getRequest();
     $this->currentEndpoint = $event->getEndpoint();
     $this->currentStartTime = TimeUtil::getCurrentTime();
 }
Пример #7
0
 /**
  * Event hook to adjust client settings just before query execution
  *
  * @param PreExecuteRequestEvent $event
  */
 public function preExecuteRequest(PreExecuteRequestEvent $event)
 {
     $adapter = $this->client->getAdapter();
     // save adapter presets (once) to allow the settings to be restored later
     if ($this->defaultEndpoint == null) {
         $this->defaultEndpoint = $this->client->getEndpoint()->getKey();
     }
     // check querytype: is loadbalancing allowed?
     if (!array_key_exists($this->queryType, $this->blockedQueryTypes)) {
         $response = $this->getLoadbalancedResponse($event->getRequest());
     } else {
         $endpoint = $this->client->getEndpoint($this->defaultEndpoint);
         $this->lastEndpoint = null;
         // execute request and return result
         $response = $adapter->execute($event->getRequest(), $endpoint);
     }
     $event->setResponse($response);
 }
Пример #8
0
 public function preExecuteRequest(SolariumPreExecuteRequestEvent $event)
 {
     if (isset($this->currentRequest)) {
         $this->failCurrentRequest();
     }
     if (null !== $this->stopwatch) {
         $this->stopwatch->start('solr', 'solr');
     }
     $this->currentRequest = $event->getRequest();
     $this->currentEndpoint = $event->getEndpoint();
     if (null !== $this->logger) {
         $this->logger->debug($event->getEndpoint()->getBaseUri() . $this->currentRequest->getUri());
     }
     $this->currentStartTime = microtime(true);
 }
Пример #9
0
 public function preExecuteRequest(SolariumPreExecuteRequestEvent $event)
 {
     if (isset($this->currentRequest)) {
         // mop: hmmm not sure what happens when an exception is thrown :S lets be restrictive for the moment
         throw new \RuntimeException('Request already set');
     }
     if (null !== $this->stopwatch) {
         $this->stopwatch->start('solr', 'solr');
     }
     $this->currentRequest = $event->getRequest();
     if (null !== $this->logger) {
         $this->logger->debug($event->getEndpoint()->getBaseUri() . $this->currentRequest->getUri());
     }
     $this->currentStartTime = microtime(true);
 }