From 220019f9a26a43ec216c67592a554368fad8edee Mon Sep 17 00:00:00 2001 From: henryzhx8 Date: Thu, 19 Oct 2023 10:26:04 +0800 Subject: [PATCH] add plugin creator (#1189) * add plugin creator --- core/pipeline/CMakeLists.txt | 2 +- core/plugin/CMakeLists.txt | 2 +- core/plugin/PluginRegistry.cpp | 66 ++++++++++++++----- core/plugin/PluginRegistry.h | 47 ++++++++----- core/plugin/creator/CMakeLists.txt | 2 +- core/plugin/creator/CProcessor.h | 18 ++++- .../creator/DynamicCProcessorCreator.cpp | 4 +- .../plugin/creator/DynamicCProcessorCreator.h | 4 +- core/plugin/creator/PluginCreator.h | 5 +- core/plugin/creator/StaticFlusherCreator.h | 34 ++++++++++ core/plugin/creator/StaticInputCreator.h | 34 ++++++++++ core/plugin/creator/StaticProcessorCreator.h | 5 +- core/plugin/instance/CMakeLists.txt | 2 +- core/plugin/instance/FlusherInstance.cpp | 15 +++++ core/plugin/instance/FlusherInstance.h | 18 +++++ core/plugin/instance/InputInstance.cpp | 15 +++++ core/plugin/instance/InputInstance.h | 18 +++++ core/plugin/instance/PluginInstance.h | 4 +- core/plugin/instance/ProcessorInstance.cpp | 2 +- core/plugin/instance/ProcessorInstance.h | 4 +- core/plugin/interface/CMakeLists.txt | 2 +- core/plugin/interface/Flusher.h | 17 +++++ core/plugin/interface/Input.h | 18 +++++ core/plugin/interface/Plugin.h | 18 +++++ 24 files changed, 302 insertions(+), 54 deletions(-) create mode 100644 core/plugin/creator/StaticFlusherCreator.h create mode 100644 core/plugin/creator/StaticInputCreator.h diff --git a/core/pipeline/CMakeLists.txt b/core/pipeline/CMakeLists.txt index ed0ee6310f..d042b8b99a 100644 --- a/core/pipeline/CMakeLists.txt +++ b/core/pipeline/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2022 iLogtail Authors +# Copyright 2023 iLogtail Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/core/plugin/CMakeLists.txt b/core/plugin/CMakeLists.txt index a7029e4be8..7812f76824 100644 --- a/core/plugin/CMakeLists.txt +++ b/core/plugin/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2022 iLogtail Authors +# Copyright 2023 iLogtail Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/core/plugin/PluginRegistry.cpp b/core/plugin/PluginRegistry.cpp index 28c51cded4..7a2053494d 100644 --- a/core/plugin/PluginRegistry.cpp +++ b/core/plugin/PluginRegistry.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2022 iLogtail Authors + * Copyright 2023 iLogtail Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,9 +26,17 @@ #include #include "app_config/AppConfig.h" +// #include "flusher/FlusherSLS.h" +// #include "input/InputFile.h" +// #include "input/InputObserverNetwork.h" +#ifdef __ENTERPRISE__ +#include "input/InputStream.h" +#endif #include "logger/Logger.h" #include "plugin/creator/CProcessor.h" #include "plugin/creator/DynamicCProcessorCreator.h" +#include "plugin/creator/StaticFlusherCreator.h" +#include "plugin/creator/StaticInputCreator.h" #include "plugin/creator/StaticProcessorCreator.h" #include "processor/ProcessorDesensitizeNative.h" #include "processor/ProcessorFilterNative.h" @@ -43,9 +51,8 @@ namespace logtail { -PluginRegistry* PluginRegistry::GetInstance() { - static PluginRegistry instance; - return &instance; +PluginRegistry::PluginRegistry() { + mGoPlugins = {""}; } void PluginRegistry::LoadPlugins() { @@ -68,23 +75,32 @@ void PluginRegistry::UnloadPlugins() { mPluginDict.clear(); } +std::unique_ptr PluginRegistry::CreateInput(const std::string& name, const std::string& pluginId) { + return std::unique_ptr(static_cast(Create(INPUT_PLUGIN, name, pluginId).release())); +} + std::unique_ptr PluginRegistry::CreateProcessor(const std::string& name, const std::string& pluginId) { return std::unique_ptr( static_cast(Create(PROCESSOR_PLUGIN, name, pluginId).release())); } -std::unique_ptr -PluginRegistry::Create(PluginCat cat, const std::string& name, const std::string& pluginId) { - std::unique_ptr ins; - auto creatorEntry = mPluginDict.find(PluginKey(cat, name)); - if (creatorEntry != mPluginDict.end()) { - ins = creatorEntry->second->Create(pluginId); - } - return ins; +std::unique_ptr PluginRegistry::CreateFlusher(const std::string& name, const std::string& pluginId) { + return std::unique_ptr( + static_cast(Create(FLUSHER_PLUGIN, name, pluginId).release())); +} + +bool PluginRegistry::IsValidGoPlugin(const std::string& name) { + return mGoPlugins.find(name) != mGoPlugins.end(); } void PluginRegistry::LoadStaticPlugins() { + // RegisterInputCreator(new StaticInputCreator()); + // RegisterInputCreator(new StaticInputCreator()); +#ifdef __ENTERPRISE__ + RegisterInputCreator(new StaticInputCreator()); +#endif + RegisterProcessorCreator(new StaticProcessorCreator()); RegisterProcessorCreator(new StaticProcessorCreator()); RegisterProcessorCreator(new StaticProcessorCreator()); @@ -96,7 +112,7 @@ void PluginRegistry::LoadStaticPlugins() { RegisterProcessorCreator(new StaticProcessorCreator()); RegisterProcessorCreator(new StaticProcessorCreator()); - /* more native plugin registers here */ + // RegisterFlusherCreator(new StaticFlusherCreator()); } void PluginRegistry::LoadDynamicPlugins(const std::set& plugins) { @@ -119,6 +135,18 @@ void PluginRegistry::LoadDynamicPlugins(const std::set& plugins) { } } +void PluginRegistry::RegisterInputCreator(PluginCreator* creator) { + RegisterCreator(INPUT_PLUGIN, creator); +} + +void PluginRegistry::RegisterProcessorCreator(PluginCreator* creator) { + RegisterCreator(PROCESSOR_PLUGIN, creator); +} + +void PluginRegistry::RegisterFlusherCreator(PluginCreator* creator) { + RegisterCreator(FLUSHER_PLUGIN, creator); +} + PluginCreator* PluginRegistry::LoadProcessorPlugin(DynamicLibLoader& loader, const std::string pluginName) { std::string error; processor_interface_t* plugin = (processor_interface_t*)loader.LoadMethod("processor_interface", error); @@ -148,8 +176,14 @@ void PluginRegistry::RegisterCreator(PluginCat cat, PluginCreator* creator) { mPluginDict.emplace(PluginKey(cat, creator->Name()), std::shared_ptr(creator)); } -void PluginRegistry::RegisterProcessorCreator(PluginCreator* creator) { - RegisterCreator(PROCESSOR_PLUGIN, creator); +std::unique_ptr +PluginRegistry::Create(PluginCat cat, const std::string& name, const std::string& pluginId) { + std::unique_ptr ins; + auto creatorEntry = mPluginDict.find(PluginKey(cat, name)); + if (creatorEntry != mPluginDict.end()) { + ins = creatorEntry->second->Create(pluginId); + } + return ins; } -} // namespace logtail \ No newline at end of file +} // namespace logtail diff --git a/core/plugin/PluginRegistry.h b/core/plugin/PluginRegistry.h index d6d8d665c7..92bb83a227 100644 --- a/core/plugin/PluginRegistry.h +++ b/core/plugin/PluginRegistry.h @@ -1,5 +1,5 @@ /* - * Copyright 2022 iLogtail Authors + * Copyright 2023 iLogtail Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,8 @@ #include "common/DynamicLibHelper.h" #include "plugin/creator/PluginCreator.h" +#include "plugin/instance/FlusherInstance.h" +#include "plugin/instance/InputInstance.h" #include "plugin/instance/PluginInstance.h" #include "plugin/instance/ProcessorInstance.h" @@ -32,29 +34,24 @@ namespace logtail { class PluginRegistry { public: - static PluginRegistry* GetInstance(); - // 加载所有插件 - void LoadPlugins(); + PluginRegistry(const PluginRegistry&) = delete; + PluginRegistry& operator=(const PluginRegistry&) = delete; - // 卸载所有插件 - void UnloadPlugins(); + static PluginRegistry* GetInstance() { + static PluginRegistry instance; + return &instance; + } - // std::unique_ptr CreateInput(const std::string& name, const std::string& pluginId); + void LoadPlugins(); + void UnloadPlugins(); + std::unique_ptr CreateInput(const std::string& name, const std::string& pluginId); std::unique_ptr CreateProcessor(const std::string& name, const std::string& pluginId); - // std::unique_ptr CreateFlusher(const std::string& name, const std::string& pluginId); + std::unique_ptr CreateFlusher(const std::string& name, const std::string& pluginId); + bool IsValidGoPlugin(const std::string& name); private: enum PluginCat { INPUT_PLUGIN, PROCESSOR_PLUGIN, FLUSHER_PLUGIN }; - void LoadStaticPlugins(); - void LoadDynamicPlugins(const std::set& plugins); - // void RegisterInputCreator(PluginCreator* creator); - void RegisterProcessorCreator(PluginCreator* creator); - // void RegisterFlusherCreator(PluginCreator* creator); - PluginCreator* LoadProcessorPlugin(DynamicLibLoader& loader, const std::string pluginName); - void RegisterCreator(PluginCat cat, PluginCreator* creator); - std::unique_ptr Create(PluginCat cat, const std::string& name, const std::string& pluginId); - struct PluginKey { PluginCat cat; std::string name; @@ -67,11 +64,25 @@ class PluginRegistry { return std::hash()(obj.cat) ^ std::hash()(obj.name); } }; + + PluginRegistry(); + ~PluginRegistry() = default; + + void LoadStaticPlugins(); + void LoadDynamicPlugins(const std::set& plugins); + void RegisterInputCreator(PluginCreator* creator); + void RegisterProcessorCreator(PluginCreator* creator); + void RegisterFlusherCreator(PluginCreator* creator); + PluginCreator* LoadProcessorPlugin(DynamicLibLoader& loader, const std::string pluginName); + void RegisterCreator(PluginCat cat, PluginCreator* creator); + std::unique_ptr Create(PluginCat cat, const std::string& name, const std::string& pluginId); + std::unordered_map, PluginKeyHash> mPluginDict; + std::unordered_set mGoPlugins; #ifdef APSARA_UNIT_TEST_MAIN friend class PluginRegistryUnittest; #endif }; -} // namespace logtail \ No newline at end of file +} // namespace logtail diff --git a/core/plugin/creator/CMakeLists.txt b/core/plugin/creator/CMakeLists.txt index 1f1457b52d..61d72a409e 100644 --- a/core/plugin/creator/CMakeLists.txt +++ b/core/plugin/creator/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2022 iLogtail Authors +# Copyright 2023 iLogtail Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/core/plugin/creator/CProcessor.h b/core/plugin/creator/CProcessor.h index 865279f2cc..4c19a19630 100644 --- a/core/plugin/creator/CProcessor.h +++ b/core/plugin/creator/CProcessor.h @@ -1,3 +1,19 @@ +/* + * Copyright 2023 iLogtail Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #ifdef __cplusplus @@ -30,4 +46,4 @@ typedef struct processor_instance_t { #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/core/plugin/creator/DynamicCProcessorCreator.cpp b/core/plugin/creator/DynamicCProcessorCreator.cpp index a89294e1eb..291daa7683 100644 --- a/core/plugin/creator/DynamicCProcessorCreator.cpp +++ b/core/plugin/creator/DynamicCProcessorCreator.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2022 iLogtail Authors + * Copyright 2023 iLogtail Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,4 +38,4 @@ std::unique_ptr DynamicCProcessorCreator::Create(const std::stri return std::unique_ptr(new ProcessorInstance(plugin, pluginId)); } -} // namespace logtail \ No newline at end of file +} // namespace logtail diff --git a/core/plugin/creator/DynamicCProcessorCreator.h b/core/plugin/creator/DynamicCProcessorCreator.h index fba59b1b96..5ccd460202 100644 --- a/core/plugin/creator/DynamicCProcessorCreator.h +++ b/core/plugin/creator/DynamicCProcessorCreator.h @@ -1,5 +1,5 @@ /* - * Copyright 2022 iLogtail Authors + * Copyright 2023 iLogtail Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,4 +34,4 @@ class DynamicCProcessorCreator : public PluginCreator { void* _handle; }; -} // namespace logtail \ No newline at end of file +} // namespace logtail diff --git a/core/plugin/creator/PluginCreator.h b/core/plugin/creator/PluginCreator.h index c2b1cda700..00ab019c36 100644 --- a/core/plugin/creator/PluginCreator.h +++ b/core/plugin/creator/PluginCreator.h @@ -1,5 +1,5 @@ /* - * Copyright 2022 iLogtail Authors + * Copyright 2023 iLogtail Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,4 +30,5 @@ class PluginCreator { virtual bool IsDynamic() = 0; virtual std::unique_ptr Create(const std::string& pluginId) = 0; }; -} // namespace logtail \ No newline at end of file + +} // namespace logtail diff --git a/core/plugin/creator/StaticFlusherCreator.h b/core/plugin/creator/StaticFlusherCreator.h new file mode 100644 index 0000000000..64db5c2240 --- /dev/null +++ b/core/plugin/creator/StaticFlusherCreator.h @@ -0,0 +1,34 @@ +/* + * Copyright 2023 iLogtail Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "plugin/creator/PluginCreator.h" +#include "plugin/instance/FlusherInstance.h" + +namespace logtail { + +template +class StaticFlusherCreator : public PluginCreator { +public: + const char* Name() override { return T::sName.c_str(); } + bool IsDynamic() override { return false; } + std::unique_ptr Create(const std::string& pluginId) override { + return std::unique_ptr(new FlusherInstance(new T, pluginId)); + } +}; + +} // namespace logtail diff --git a/core/plugin/creator/StaticInputCreator.h b/core/plugin/creator/StaticInputCreator.h new file mode 100644 index 0000000000..68c842a33c --- /dev/null +++ b/core/plugin/creator/StaticInputCreator.h @@ -0,0 +1,34 @@ +/* + * Copyright 2023 iLogtail Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "plugin/creator/PluginCreator.h" +#include "plugin/instance/InputInstance.h" + +namespace logtail { + +template +class StaticInputCreator : public PluginCreator { +public: + const char* Name() override { return T::sName.c_str(); } + bool IsDynamic() override { return false; } + std::unique_ptr Create(const std::string& pluginId) override { + return std::unique_ptr(new InputInstance(new T, pluginId)); + } +}; + +} // namespace logtail diff --git a/core/plugin/creator/StaticProcessorCreator.h b/core/plugin/creator/StaticProcessorCreator.h index f4dc4e0442..9840768d2c 100644 --- a/core/plugin/creator/StaticProcessorCreator.h +++ b/core/plugin/creator/StaticProcessorCreator.h @@ -1,5 +1,5 @@ /* - * Copyright 2022 iLogtail Authors + * Copyright 2023 iLogtail Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,11 +20,10 @@ #include "plugin/instance/ProcessorInstance.h" namespace logtail { - + template class StaticProcessorCreator : public PluginCreator { public: - StaticProcessorCreator() {} const char* Name() override { return T::sName.c_str(); } bool IsDynamic() override { return false; } std::unique_ptr Create(const std::string& pluginId) override { diff --git a/core/plugin/instance/CMakeLists.txt b/core/plugin/instance/CMakeLists.txt index e33e9f7673..79be446ccb 100644 --- a/core/plugin/instance/CMakeLists.txt +++ b/core/plugin/instance/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2022 iLogtail Authors +# Copyright 2023 iLogtail Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/core/plugin/instance/FlusherInstance.cpp b/core/plugin/instance/FlusherInstance.cpp index c8a6092cc5..16fd745719 100644 --- a/core/plugin/instance/FlusherInstance.cpp +++ b/core/plugin/instance/FlusherInstance.cpp @@ -1,3 +1,17 @@ +// Copyright 2023 iLogtail Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + #include "plugin/instance/FlusherInstance.h" namespace logtail { @@ -9,4 +23,5 @@ bool FlusherInstance::Init(const Json::Value& config, PipelineContext& context) } return true; } + } // namespace logtail diff --git a/core/plugin/instance/FlusherInstance.h b/core/plugin/instance/FlusherInstance.h index 646c9f9249..4d292a8549 100644 --- a/core/plugin/instance/FlusherInstance.h +++ b/core/plugin/instance/FlusherInstance.h @@ -1,3 +1,19 @@ +/* + * Copyright 2023 iLogtail Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include @@ -7,6 +23,7 @@ // #include "table/Table.h" namespace logtail { + class FlusherInstance: public PluginInstance { public: FlusherInstance(Flusher* plugin, const std::string& pluginId) : PluginInstance(pluginId), mPlugin(plugin) {} @@ -20,4 +37,5 @@ class FlusherInstance: public PluginInstance { private: std::unique_ptr mPlugin; }; + } diff --git a/core/plugin/instance/InputInstance.cpp b/core/plugin/instance/InputInstance.cpp index a127f485c8..7628567057 100644 --- a/core/plugin/instance/InputInstance.cpp +++ b/core/plugin/instance/InputInstance.cpp @@ -1,3 +1,17 @@ +// Copyright 2023 iLogtail Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + #include "plugin/instance/InputInstance.h" namespace logtail { @@ -9,4 +23,5 @@ bool InputInstance::Init(const Json::Value& config, PipelineContext& context) { } return true; } + } // namespace logtail diff --git a/core/plugin/instance/InputInstance.h b/core/plugin/instance/InputInstance.h index fd6ef8bec4..7297fa1e1e 100644 --- a/core/plugin/instance/InputInstance.h +++ b/core/plugin/instance/InputInstance.h @@ -1,3 +1,19 @@ +/* + * Copyright 2023 iLogtail Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include @@ -7,6 +23,7 @@ // #include "table/Table.h" namespace logtail { + class InputInstance : public PluginInstance { public: InputInstance(Input* plugin, const std::string& pluginId) : PluginInstance(pluginId), mPlugin(plugin) {} @@ -20,4 +37,5 @@ class InputInstance : public PluginInstance { private: std::unique_ptr mPlugin; }; + } // namespace logtail diff --git a/core/plugin/instance/PluginInstance.h b/core/plugin/instance/PluginInstance.h index 548cb9a1fd..2db3ccc780 100644 --- a/core/plugin/instance/PluginInstance.h +++ b/core/plugin/instance/PluginInstance.h @@ -1,5 +1,5 @@ /* - * Copyright 2022 iLogtail Authors + * Copyright 2023 iLogtail Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,4 +40,4 @@ class PluginInstance { const std::string mId; }; -} // namespace logtail \ No newline at end of file +} // namespace logtail diff --git a/core/plugin/instance/ProcessorInstance.cpp b/core/plugin/instance/ProcessorInstance.cpp index 765d0953be..a46d54cb37 100644 --- a/core/plugin/instance/ProcessorInstance.cpp +++ b/core/plugin/instance/ProcessorInstance.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2022 iLogtail Authors + * Copyright 2023 iLogtail Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/plugin/instance/ProcessorInstance.h b/core/plugin/instance/ProcessorInstance.h index 9bf4a0351d..baca3b55cd 100644 --- a/core/plugin/instance/ProcessorInstance.h +++ b/core/plugin/instance/ProcessorInstance.h @@ -1,5 +1,5 @@ /* - * Copyright 2022 iLogtail Authors + * Copyright 2023 iLogtail Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,4 +52,4 @@ class ProcessorInstance : public PluginInstance { #endif }; -} // namespace logtail \ No newline at end of file +} // namespace logtail diff --git a/core/plugin/interface/CMakeLists.txt b/core/plugin/interface/CMakeLists.txt index 288061d8f9..353b559d5b 100644 --- a/core/plugin/interface/CMakeLists.txt +++ b/core/plugin/interface/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2022 iLogtail Authors +# Copyright 2023 iLogtail Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/core/plugin/interface/Flusher.h b/core/plugin/interface/Flusher.h index 103e524ec8..6699bdc987 100644 --- a/core/plugin/interface/Flusher.h +++ b/core/plugin/interface/Flusher.h @@ -1,3 +1,19 @@ +/* + * Copyright 2023 iLogtail Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include "plugin/interface/Plugin.h" @@ -16,4 +32,5 @@ class Flusher : public Plugin { // 独立flusher:停止线程 virtual bool Stop(bool isPipelineRemoving) = 0; }; + } // namespace logtail diff --git a/core/plugin/interface/Input.h b/core/plugin/interface/Input.h index 6b1ee00f40..0ee4b01348 100644 --- a/core/plugin/interface/Input.h +++ b/core/plugin/interface/Input.h @@ -1,3 +1,19 @@ +/* + * Copyright 2023 iLogtail Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include "plugin/interface/Plugin.h" @@ -5,6 +21,7 @@ #include "json/json.h" namespace logtail { + class Input : public Plugin { public: virtual ~Input() = default; @@ -14,4 +31,5 @@ class Input : public Plugin { virtual bool Start() = 0; virtual bool Stop(bool isPipelineRemoving) = 0; }; + } // namespace logtail diff --git a/core/plugin/interface/Plugin.h b/core/plugin/interface/Plugin.h index 08df17d663..f1a4ea0d76 100644 --- a/core/plugin/interface/Plugin.h +++ b/core/plugin/interface/Plugin.h @@ -1,3 +1,19 @@ +/* + * Copyright 2023 iLogtail Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include @@ -8,6 +24,7 @@ #include "monitor/LogtailMetric.h" namespace logtail { + class Plugin { public: virtual ~Plugin() = default; @@ -33,4 +50,5 @@ class Plugin { PipelineContext* mContext = nullptr; MetricsRecordRef mMetricsRecordRef; }; + } // namespace logtail