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 theRPCClient
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 subclassshared::rpc::ClientRequest
and override theget_method()
member function. You can checkCtrlRPCRequests.h
for examples. The basic encoding and decoding for these structures are already implemented insideyaml_codecs.h
. In case you define your own message then you should provide you own codec implementation, there are some examples available inctrl_yaml_codecs.h