1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52:41 +01:00

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
This commit is contained in:
epriestley 2020-04-14 12:47:37 -07:00
parent 4655a5f059
commit 59c855276b

View file

@ -21,6 +21,12 @@ final class PhabricatorConduitCallManagementWorkflow
'File to read parameters from, or "-" to read from '. 'File to read parameters from, or "-" to read from '.
'stdin.'), 'stdin.'),
), ),
array(
'name' => 'local',
'help' => pht(
'Force the request to execute in this process, rather than '.
'proxying to another host in the cluster.'),
),
array( array(
'name' => 'as', 'name' => 'as',
'param' => 'username', 'param' => 'username',
@ -75,9 +81,17 @@ final class PhabricatorConduitCallManagementWorkflow
$params = phutil_json_decode($input_json); $params = phutil_json_decode($input_json);
$result = id(new ConduitCall($method, $params)) $call = id(new ConduitCall($method, $params))
->setUser($actor) ->setUser($actor);
->execute();
$api_request = $call->getAPIRequest();
$is_local = $args->getArg('local');
if ($is_local) {
$api_request->setIsClusterRequest(true);
}
$result = $call->execute();
$output = array( $output = array(
'result' => $result, 'result' => $result,