当前位置: 首页>>代码示例>>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;未经允许,请勿转载。