Traffic Server JSONRPC Node C++ Client Implementation

Basics

Traffic Server provides a set of basic C++ classes to perform request and handle responses from server’s rpc node. Files under include/shared/rpc are meant to be used by client applications like traffic_ctl and traffic_top to send a receive messages from the Traffic Server jsonrpc node.

This helper classes provides:

  • RPCClient class which provides functionality to connect and invoke remote command inside the Traffic Server JSONRPC 2.0 node. This class already knows where the unix socket is located.

  • IPCSocketClient class which provides the socket implementation for the IPC socket in the JSONRPC 2.0 node. If what you want is just to invoke a remote function and get the response, then it’s recommended to just use the RPCClient class instead.

  • RPCRequests class which contains all the basic classes to map the basic JSONRPC 2.0 messages(requests and responses). If what you want is a custom message you can just subclass shared::rpc::ClientRequest and override the get_method() member function. You can check CtrlRPCRequests.h for examples. The basic encoding and decoding for these structures are already implemented inside yaml_codecs.h. In case you define your own message then you should provide you own codec implementation, there are some examples available in ctrl_yaml_codecs.h

Building