當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ClientBuilder::defaultHandler方法代碼示例

本文整理匯總了PHP中Elasticsearch\ClientBuilder::defaultHandler方法的典型用法代碼示例。如果您正苦於以下問題:PHP ClientBuilder::defaultHandler方法的具體用法?PHP ClientBuilder::defaultHandler怎麽用?PHP ClientBuilder::defaultHandler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Elasticsearch\ClientBuilder的用法示例。


在下文中一共展示了ClientBuilder::defaultHandler方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: build

 /**
  * @return Client
  */
 public function build()
 {
     $this->buildLoggers();
     if (is_null($this->handler)) {
         $this->handler = ClientBuilder::defaultHandler();
     }
     $sslOptions = null;
     if (isset($this->sslKey)) {
         $sslOptions['ssl_key'] = $this->sslKey;
     }
     if (isset($this->sslCert)) {
         $sslOptions['cert'] = $this->sslCert;
     }
     if (isset($this->sslVerification)) {
         $sslOptions['verify'] = $this->sslVerification;
     }
     if (!is_null($sslOptions)) {
         $sslHandler = function (callable $handler, array $sslOptions) {
             return function (array $request) use($handler, $sslOptions) {
                 // Add our custom headers
                 foreach ($sslOptions as $key => $value) {
                     $request['client'][$key] = $value;
                 }
                 // Send the request using the handler and return the response.
                 return $handler($request);
             };
         };
         $this->handler = $sslHandler($this->handler, $sslOptions);
     }
     if (is_null($this->serializer)) {
         $this->serializer = new SmartSerializer();
     } elseif (is_string($this->serializer)) {
         $this->serializer = new $this->serializer();
     }
     if (is_null($this->connectionFactory)) {
         $connectionParams = [];
         $this->connectionFactory = new ConnectionFactory($this->handler, $connectionParams, $this->serializer, $this->logger, $this->tracer);
     }
     if (is_null($this->hosts)) {
         $this->hosts = $this->getDefaultHost();
     }
     if (is_null($this->selector)) {
         $this->selector = new Selectors\RoundRobinSelector();
     } elseif (is_string($this->selector)) {
         $this->selector = new $this->selector();
     }
     $this->buildTransport();
     if (is_null($this->endpoint)) {
         $transport = $this->transport;
         $serializer = $this->serializer;
         $this->endpoint = function ($class) use($transport, $serializer) {
             $fullPath = '\\Elasticsearch\\Endpoints\\' . $class;
             if ($class === 'Bulk' || $class === 'Msearch' || $class === 'MPercolate') {
                 return new $fullPath($transport, $serializer);
             } else {
                 return new $fullPath($transport);
             }
         };
     }
     return new Client($this->transport, $this->endpoint);
 }
開發者ID:GerDner,項目名稱:luck-docker,代碼行數:64,代碼來源:ClientBuilder.php


注:本文中的Elasticsearch\ClientBuilder::defaultHandler方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。