From 59c855276b0b60d759af0be3ed662f7fafcee989 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 14 Apr 2020 12:47:37 -0700 Subject: [PATCH] Provide a "--local" flag to "bin/conduit call" to force in-process execution Summary: See PHI1692. Currently, it's hard to get a local profile or "--trace" of some Diffusion API methods, since they always proxy via HTTP -- even if the local node can serve the request. This always-proxy behavior is intentional (so we always go down the same code path, to limit surprises) but inconvenient when debugging. Allow an operator to connect to a node which can serve a request and issue a `--local` call to force in-process execution. This makes it straightforward to "--trace" or "--xprofile" the call. Test Plan: Ran `bin/conduit call ...` with and without `--local` using a Diffusion method on a clustered repository. Without `--local`, saw proxy via HTTP. With `--local`, saw in-process execution. Differential Revision: https://secure.phabricator.com/D21114 --- .../PhabricatorConduitCallManagementWorkflow.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/applications/conduit/management/PhabricatorConduitCallManagementWorkflow.php b/src/applications/conduit/management/PhabricatorConduitCallManagementWorkflow.php index dc241a04b4..a12d1374dc 100644 --- a/src/applications/conduit/management/PhabricatorConduitCallManagementWorkflow.php +++ b/src/applications/conduit/management/PhabricatorConduitCallManagementWorkflow.php @@ -22,6 +22,12 @@ final class PhabricatorConduitCallManagementWorkflow 'stdin.'), ), array( + 'name' => 'local', + 'help' => pht( + 'Force the request to execute in this process, rather than '. + 'proxying to another host in the cluster.'), + ), + array( 'name' => 'as', 'param' => 'username', 'help' => pht( @@ -75,9 +81,17 @@ final class PhabricatorConduitCallManagementWorkflow $params = phutil_json_decode($input_json); - $result = id(new ConduitCall($method, $params)) - ->setUser($actor) - ->execute(); + $call = id(new ConduitCall($method, $params)) + ->setUser($actor); + + $api_request = $call->getAPIRequest(); + + $is_local = $args->getArg('local'); + if ($is_local) { + $api_request->setIsClusterRequest(true); + } + + $result = $call->execute(); $output = array( 'result' => $result, -- 2.11.4.GIT