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


PHP ConduitAPIRequest::getIsClusterRequest方法代碼示例

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


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

示例1: execute

 /**
  * This method is final because most queries will need to construct a
  * @{class:DiffusionRequest} and use it. Consolidating this codepath and
  * enforcing @{method:getDiffusionRequest} works when we need it is good.
  *
  * @{method:getResult} should be overridden by subclasses as necessary, e.g.
  * there is a common operation across all version control systems that
  * should occur after @{method:getResult}, like formatting a timestamp.
  */
 protected final function execute(ConduitAPIRequest $request)
 {
     $drequest = DiffusionRequest::newFromDictionary(array('user' => $request->getUser(), 'callsign' => $request->getValue('callsign'), 'branch' => $request->getValue('branch'), 'path' => $request->getValue('path'), 'commit' => $request->getValue('commit')));
     // Figure out whether we're going to handle this request on this device,
     // or proxy it to another node in the cluster.
     // If this is a cluster request and we need to proxy, we'll explode here
     // to prevent infinite recursion.
     $is_cluster_request = $request->getIsClusterRequest();
     $repository = $drequest->getRepository();
     $client = $repository->newConduitClient($request->getUser(), $is_cluster_request);
     if ($client) {
         // We're proxying, so just make an intracluster call.
         return $client->callMethodSynchronous($this->getAPIMethodName(), $request->getAllParameters());
     } else {
         // We pass this flag on to prevent proxying of any other Conduit calls
         // which we need to make in order to respond to this one. Although we
         // could safely proxy them, we take a big performance hit in the common
         // case, and doing more proxying wouldn't exercise any additional code so
         // we wouldn't gain a testability/predictability benefit.
         $drequest->setIsClusterRequest($is_cluster_request);
         $this->setDiffusionRequest($drequest);
         return $this->getResult($request);
     }
 }
開發者ID:patelhardik,項目名稱:phabricator,代碼行數:33,代碼來源:DiffusionQueryConduitAPIMethod.php

示例2: execute

 /**
  * This method is final because most queries will need to construct a
  * @{class:DiffusionRequest} and use it. Consolidating this codepath and
  * enforcing @{method:getDiffusionRequest} works when we need it is good.
  *
  * @{method:getResult} should be overridden by subclasses as necessary, e.g.
  * there is a common operation across all version control systems that
  * should occur after @{method:getResult}, like formatting a timestamp.
  */
 protected final function execute(ConduitAPIRequest $request)
 {
     $identifier = $request->getValue('repository');
     if ($identifier === null) {
         $identifier = $request->getValue('callsign');
     }
     $drequest = DiffusionRequest::newFromDictionary(array('user' => $request->getUser(), 'repository' => $identifier, 'branch' => $request->getValue('branch'), 'path' => $request->getValue('path'), 'commit' => $request->getValue('commit')));
     if (!$drequest) {
         throw new Exception(pht('Repository "%s" is not a valid repository.', $identifier));
     }
     // Figure out whether we're going to handle this request on this device,
     // or proxy it to another node in the cluster.
     // If this is a cluster request and we need to proxy, we'll explode here
     // to prevent infinite recursion.
     $is_cluster_request = $request->getIsClusterRequest();
     $viewer = $request->getUser();
     $repository = $drequest->getRepository();
     $client = $repository->newConduitClient($viewer, $is_cluster_request);
     if ($client) {
         // We're proxying, so just make an intracluster call.
         return $client->callMethodSynchronous($this->getAPIMethodName(), $request->getAllParameters());
     } else {
         // We pass this flag on to prevent proxying of any other Conduit calls
         // which we need to make in order to respond to this one. Although we
         // could safely proxy them, we take a big performance hit in the common
         // case, and doing more proxying wouldn't exercise any additional code so
         // we wouldn't gain a testability/predictability benefit.
         $drequest->setIsClusterRequest($is_cluster_request);
         $this->setDiffusionRequest($drequest);
         // TODO: Allow web UI queries opt out of this if they don't care about
         // fetching the most up-to-date data? Synchronization can be slow, and a
         // lot of web reads are probably fine if they're a few seconds out of
         // date.
         id(new DiffusionRepositoryClusterEngine())->setViewer($viewer)->setRepository($repository)->synchronizeWorkingCopyBeforeRead();
         return $this->getResult($request);
     }
 }
開發者ID:rchicoli,項目名稱:phabricator,代碼行數:46,代碼來源:DiffusionQueryConduitAPIMethod.php


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