MCPcopy Create free account
hub / github.com/apache/trafficserver / RPCServer

Class RPCServer

include/mgmt/rpc/server/RPCServer.h:48–87  ·  view source on GitHub ↗

@brief RPC Server implementation for the JSONRPC Logic. This class holds a transport which implements @see BaseCommInterface Objects of this class can start @see start_thread , stop @see stop_thread the server at any? time. More than one instance of this class can be created as long as they use different transport configuration.

Source from the content-addressed store, hash-verified

46/// Objects of this class can start @see start_thread , stop @see stop_thread the server at any? time. More than one instance of
47/// this class can be created as long as they use different transport configuration.
48class RPCServer
49{
50public:
51 RPCServer() = default;
52 ///
53 /// @brief Construct a new Rpc Server object
54 /// This function have one main goal, select the transport type base on the configuration and initialize it.
55 ///
56 /// @throw std::runtime_error if:
57 /// 1 - It the configured transport isn't valid for the server to create it, then an exception will be thrown.
58 /// 2 - The transport layer cannot be initialized.
59 /// @param conf the configuration object.
60 ///
61 RPCServer(config::RPCConfig const &conf);
62
63 /// @brief The destructor will join the thread.
64 ~RPCServer();
65
66 /// @brief Returns a descriptive name that was set by the transport. Check @see BaseCommInterface
67 std::string_view selected_comm_name() const noexcept;
68
69 /// @brief Thread function that runs the transport.
70 void start_thread(std::function<TSThread()> const &cb_init = std::function<TSThread()>(),
71 std::function<void(TSThread)> const &cb_destroy = std::function<void(TSThread)>());
72
73 /// @brief Function to stop the transport and join the thread to finish.
74 void stop_thread();
75
76private:
77 /// @brief Actual thread routine. This will start the socket.
78 static void *run_thread(void *);
79
80 std::function<TSThread()> _init;
81 std::function<void(TSThread)> _destroy;
82 ink_thread _this_thread{ink_thread_null()};
83 TSThread _rpcThread{nullptr};
84
85 std::thread running_thread;
86 std::unique_ptr<comm::BaseCommInterface> _socketImpl;
87};
88} // namespace rpc
89
90extern rpc::RPCServer *jsonrpcServer;

Callers

nothing calls this directly

Calls 1

ink_thread_nullFunction · 0.85

Tested by

no test coverage detected