mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-09 16:32:39 +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:
parent
4655a5f059
commit
59c855276b
1 changed files with 17 additions and 3 deletions
|
@ -21,6 +21,12 @@ final class PhabricatorConduitCallManagementWorkflow
|
|||
'File to read parameters from, or "-" to read from '.
|
||||
'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',
|
||||
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue