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

Function plugin_send_basic_msg

src/mgmt/rpc/handlers/plugins/Plugins.cc:59–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57namespace err = rpc::handlers::errors;
58
59swoc::Rv<YAML::Node>
60plugin_send_basic_msg(std::string_view const & /* id ATS_UNUSED */, YAML::Node const &params)
61{
62 // The rpc could be ready before plugins are initialized.
63 // We make sure it is ready.
64 if (!g_lifecycle_hooks) {
65 return err::make_errata(err::Codes::PLUGIN, "Plugin is not yet ready to handle any messages.");
66 }
67
68 swoc::Rv<YAML::Node> resp;
69 try {
70 // keep the data.
71 PluginMsgInfo info = params.as<PluginMsgInfo>();
72
73 TSPluginMsg msg;
74 msg.tag = info.tag.c_str();
75 msg.data = info.data.data();
76 msg.data_size = info.data.size();
77
78 APIHook *hook = g_lifecycle_hooks->get(TS_LIFECYCLE_MSG_HOOK);
79
80 while (hook) {
81 TSPluginMsg tmp(msg); // Just to make sure plugins don't mess this up for others.
82 hook->invoke(TS_EVENT_LIFECYCLE_MSG, &tmp);
83 hook = hook->next();
84 }
85 } catch (std::exception const &ex) {
86 Dbg(dbg_ctl, "Invalid params %s", ex.what());
87 resp = err::make_errata(err::Codes::PLUGIN, "Error parsing the incoming data: {}", ex.what());
88 }
89
90 return resp;
91}
92} // namespace rpc::handlers::plugins

Callers

nothing calls this directly

Calls 8

make_errataFunction · 0.85
c_strMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
getMethod · 0.45
invokeMethod · 0.45
nextMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected