@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add a 15-second timeout to external service calls to fill Doorkeeper link tags

Summary:
Depends on D20528. Ref T13291. Ref T13285. Currently, we don't put a timeout on external service calls when enriching URIs for external Asana/JIRA tasks.

Add a 15-second timeout so we'll do something reasonable-ish in the face of a downed service provider. Later, I plan to healthcheck Asana/JIRA providers in a generic way (see T13287) so we can stop making calls if they time out / fail too frequently.

Test Plan:
- Linked to JIRA and Asana tasks in comments.
- Set timeout to 0.0001 seconds, saw requests time out.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13291, T13285

Differential Revision: https://secure.phabricator.com/D20530

+44 -4
+10
src/applications/doorkeeper/bridge/DoorkeeperBridge.php
··· 5 5 private $viewer; 6 6 private $context = array(); 7 7 private $throwOnMissingLink; 8 + private $timeout; 9 + 10 + public function setTimeout($timeout) { 11 + $this->timeout = $timeout; 12 + return $this; 13 + } 14 + 15 + public function getTimeout() { 16 + return $this->timeout; 17 + } 8 18 9 19 public function setThrowOnMissingLink($throw_on_missing_link) { 10 20 $this->throwOnMissingLink = $throw_on_missing_link;
+5
src/applications/doorkeeper/bridge/DoorkeeperBridgeAsana.php
··· 62 62 $template = id(new PhutilAsanaFuture()) 63 63 ->setAccessToken($token); 64 64 65 + $timeout = $this->getTimeout(); 66 + if ($timeout !== null) { 67 + $template->setTimeout($timeout); 68 + } 69 + 65 70 $futures = array(); 66 71 foreach ($id_map as $key => $id) { 67 72 $futures[$key] = id(clone $template)
+9 -1
src/applications/doorkeeper/bridge/DoorkeeperBridgeJIRA.php
··· 47 47 // (by querying all instances). For now, just query the one instance. 48 48 $account = head($accounts); 49 49 50 + $timeout = $this->getTimeout(); 51 + 50 52 $futures = array(); 51 53 foreach ($id_map as $key => $id) { 52 - $futures[$key] = $provider->newJIRAFuture( 54 + $future = $provider->newJIRAFuture( 53 55 $account, 54 56 'rest/api/2/issue/'.phutil_escape_uri($id), 55 57 'GET'); 58 + 59 + if ($timeout !== null) { 60 + $future->setTimeout($timeout); 61 + } 62 + 63 + $futures[$key] = $future; 56 64 } 57 65 58 66 $results = array();
+1
src/applications/doorkeeper/controller/DoorkeeperTagsController.php
··· 26 26 $refs = id(new DoorkeeperImportEngine()) 27 27 ->setViewer($viewer) 28 28 ->setRefs($refs) 29 + ->setTimeout(15) 29 30 ->execute(); 30 31 31 32 $results = array();
+19 -3
src/applications/doorkeeper/engine/DoorkeeperImportEngine.php
··· 8 8 private $localOnly; 9 9 private $throwOnMissingLink; 10 10 private $context = array(); 11 + private $timeout; 11 12 12 13 public function setViewer(PhabricatorUser $viewer) { 13 14 $this->viewer = $viewer; ··· 41 42 public function setContextProperty($key, $value) { 42 43 $this->context[$key] = $value; 43 44 return $this; 45 + } 46 + 47 + public function setTimeout($timeout) { 48 + $this->timeout = $timeout; 49 + return $this; 50 + } 51 + 52 + public function getTimeout() { 53 + return $this->timeout; 44 54 } 45 55 46 56 /** ··· 98 108 ->setFilterMethod('isEnabled') 99 109 ->execute(); 100 110 111 + $timeout = $this->getTimeout(); 101 112 foreach ($bridges as $key => $bridge) { 102 - $bridge->setViewer($viewer); 103 - $bridge->setThrowOnMissingLink($this->throwOnMissingLink); 104 - $bridge->setContext($this->context); 113 + $bridge 114 + ->setViewer($viewer) 115 + ->setThrowOnMissingLink($this->throwOnMissingLink) 116 + ->setContext($this->context); 117 + 118 + if ($timeout !== null) { 119 + $bridge->setTimeout($timeout); 120 + } 105 121 } 106 122 107 123 $working_set = $refs;