1 /** @file 2 3 Plugin init declarations 4 5 @section license License 6 7 Licensed to the Apache Software Foundation (ASF) under one 8 or more contributor license agreements. See the NOTICE file 9 distributed with this work for additional information 10 regarding copyright ownership. The ASF licenses this file 11 to you under the Apache License, Version 2.0 (the 12 "License"); you may not use this file except in compliance 13 with the License. You may obtain a copy of the License at 14 15 http://www.apache.org/licenses/LICENSE-2.0 16 17 Unless required by applicable law or agreed to in writing, software 18 distributed under the License is distributed on an "AS IS" BASIS, 19 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 See the License for the specific language governing permissions and 21 limitations under the License. 22 */ 23 24 #pragma once 25 26 #include <string> 27 #include "tscore/List.h" 28 29 typedef enum { RELOAD_OFF, RELOAD_ON, RELOAD_COUNT } PluginDynamicReloadMode; 30 31 // read records.config to parse plugin related configs 32 void parsePluginConfig(); 33 34 bool isPluginDynamicReloadEnabled(); 35 36 struct PluginRegInfo { 37 PluginRegInfo(); 38 ~PluginRegInfo(); 39 40 bool plugin_registered = false; 41 char *plugin_path = nullptr; 42 43 char *plugin_name = nullptr; 44 char *vendor_name = nullptr; 45 char *support_email = nullptr; 46 47 void *dlh = nullptr; 48 49 LINK(PluginRegInfo, link); 50 }; 51 52 // Plugin registration vars 53 extern DLL<PluginRegInfo> plugin_reg_list; 54 extern PluginRegInfo *plugin_reg_current; 55 56 bool plugin_init(bool validateOnly = false); 57 bool plugin_dso_load(const char *path, void *&handle, void *&init, std::string &error); 58 59 /** Abstract interface class for plugin based continuations. 60 61 The primary intended use of this is for logging so that continuations 62 that generate logging messages can generate plugin local data in a 63 generic way. 64 65 The core will at appropriate times dynamically cast the continuation 66 to this class and if successful access the plugin data via these 67 methods. 68 69 Plugins should mix this in to continuations for which it is useful. 70 The default implementations return empty / invalid responses and should 71 be overridden by the plugin. 72 */ 73 class PluginIdentity 74 { 75 public: 76 /// Make sure destructor is virtual. ~PluginIdentity()77 virtual ~PluginIdentity() {} 78 /** Get the plugin tag. 79 The returned string must have a lifetime at least as long as the plugin. 80 @return A string identifying the plugin or @c NULL. 81 */ 82 virtual char const * getPluginTag()83 getPluginTag() const 84 { 85 return nullptr; 86 } 87 /** Get the plugin instance ID. 88 A plugin can create multiple subsidiary instances. This is used as the 89 identifier for those to distinguish the instances. 90 */ 91 virtual int64_t getPluginId()92 getPluginId() const 93 { 94 return 0; 95 } 96 }; 97