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

Function TSPluginInit

plugins/experimental/wasm/wasm_main.cc:889–934  ·  view source on GitHub ↗

main function for the plugin

Source from the content-addressed store, hash-verified

887
888// main function for the plugin
889void
890TSPluginInit(int argc, const char *argv[])
891{
892 TSPluginRegistrationInfo info;
893 info.plugin_name = "wasm";
894 info.vendor_name = "Apache Software Foundation";
895 info.support_email = "dev@trafficserver.apache.org";
896 if (TSPluginRegister(&info) != TS_SUCCESS) {
897 TSError("[wasm] Plugin registration failed");
898 }
899
900 if (argc < 2) {
901 TSError("[wasm][%s] wasm config argument missing", __FUNCTION__);
902 return;
903 }
904
905 wasm_config = std::make_unique<WasmInstanceConfig>();
906
907 for (int i = 1; i < argc; i++) {
908 std::string filename = std::string(argv[i]);
909 if (*filename.begin() != '/') {
910 filename = std::string(TSConfigDirGet()) + "/" + filename;
911 }
912 wasm_config->config_filenames.push_front(filename);
913 }
914
915 if (!read_configuration()) {
916 return;
917 }
918
919 // global handler
920 TSCont global_contp = TSContCreate(global_hook_handler, nullptr);
921 if (global_contp == nullptr) {
922 TSError("[wasm][%s] could not create transaction start continuation", __FUNCTION__);
923 return;
924 }
925 TSHttpHookAdd(TS_HTTP_TXN_START_HOOK, global_contp);
926
927 // configuration handler
928 TSCont config_contp = TSContCreate(config_handler, nullptr);
929 if (config_contp == nullptr) {
930 TSError("[ts_lua][%s] could not create configuration continuation", __FUNCTION__);
931 return;
932 }
933 TSMgmtUpdateRegister(config_contp, "wasm");
934}

Callers

nothing calls this directly

Calls 9

TSPluginRegisterFunction · 0.85
stringClass · 0.85
TSConfigDirGetFunction · 0.85
read_configurationFunction · 0.85
TSContCreateFunction · 0.85
TSHttpHookAddFunction · 0.85
TSMgmtUpdateRegisterFunction · 0.85
TSErrorFunction · 0.50
beginMethod · 0.45

Tested by

no test coverage detected