main function for the plugin
| 887 | |
| 888 | // main function for the plugin |
| 889 | void |
| 890 | TSPluginInit(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 | } |
nothing calls this directly
no test coverage detected