Skip to content

Conversation

@brbzull0
Copy link
Contributor

Add Input option to invoke a rpc function by specifying the method name and the parameters directly
from the command line.

With this change we now can call any rpc method without the need to support it in traffic_ctl:

$ traffic_ctl rpc invoke get_service_descriptor
--> {"id": "50d9431e-85f9-4999-abc7-4f26ac3cc1e1", "jsonrpc": "2.0", "method": "get_service_descriptor"}
<--  {response}

This also removed CustomizableRequest which is no longer needed(it was unused but left it as base for this case).

Add Input option to invoke a rpc function by specifying the method name and the parameters directly
from the command line.
@brbzull0 brbzull0 added the JSONRPC JSONRPC 2.0 related work. label Feb 22, 2022
@brbzull0 brbzull0 self-assigned this Feb 22, 2022
@brbzull0 brbzull0 requested a review from bryancall as a code owner February 22, 2022 14:26
@brbzull0
Copy link
Contributor Author

[approve ci fedora]

@brbzull0
Copy link
Contributor Author

This #8694 will fix the autest

@brbzull0
Copy link
Contributor Author

[approve ci autest]

@brbzull0 brbzull0 marked this pull request as draft February 25, 2022 16:24
@brbzull0 brbzull0 marked this pull request as ready for review February 25, 2022 16:56
std::string id; //!< optional, only needed for method calls.
YAML::Node params; //!< This is defined by each remote API.

virtual std::string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dang, shouldn't that be std::string const&?

@SolidWallOfCode
Copy link
Member

Seems it would be nice to have a --json option where I can pass in the JSON literally.

@SolidWallOfCode SolidWallOfCode self-requested a review March 1, 2022 00:14
@brbzull0
Copy link
Contributor Author

brbzull0 commented Mar 1, 2022

Seems it would be nice to have a --json option where I can pass in the JSON literally.

@SolidWallOfCode You can, the --params will handle that, internally it will use the YAML parser, so you can pass json or yaml:

traffic_ctl rpc invoke read_files_method --params '{ "filenames": [  "file1", "file2" ] }'

or

traffic_ctl rpc invoke read_files_method --params 'filenames: ["file1", "file2"]'

thanks for the review

@brbzull0 brbzull0 merged commit 20d2241 into apache:10-Dev Mar 1, 2022
@zwoop zwoop added this to the 10.0.0 milestone Jan 17, 2023
JosiahWI pushed a commit to JosiahWI/trafficserver that referenced this pull request Jul 19, 2023
apache#658)

* traffic_ctl - Add rpc invoke option. (apache#8695)

Add Input option to invoke a rpc function by specifying the method name and the parameters directly
from the command line.

(cherry picked from commit 20d2241)

* MGMT - Improve invalid rpc param error description and some cleanup. (apache#8696)

(cherry picked from commit 304ea26)

* traffic_ctl - Run a clean up on the output style parameters making it easy to use. 'all,req,resp' are now grouped into the '--format rpc' option. (apache#8704)

(cherry picked from commit 68e69e2)

Co-authored-by: Damian Meden <damian.meden@gmail.com>
Co-authored-by: Brian Neradt <brian.neradt@verizonmedia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

JSONRPC JSONRPC 2.0 related work.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants