From a501c35d8db1313fc1e9f76b06d10d8ff66d9df5 Mon Sep 17 00:00:00 2001 From: Arne Welzel Date: Tue, 23 Sep 2025 15:46:15 +0200 Subject: [PATCH] cluster: Add None backend Mostly so we have the CLUSTER_BACKEND_NONE value available, but potentially useful for testing, too. --- src/cluster/backend/CMakeLists.txt | 2 + src/cluster/backend/none/CMakeLists.txt | 3 ++ src/cluster/backend/none/Plugin.cc | 55 +++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 src/cluster/backend/none/CMakeLists.txt create mode 100644 src/cluster/backend/none/Plugin.cc diff --git a/src/cluster/backend/CMakeLists.txt b/src/cluster/backend/CMakeLists.txt index c5a6d1b4a2..c312395c16 100644 --- a/src/cluster/backend/CMakeLists.txt +++ b/src/cluster/backend/CMakeLists.txt @@ -17,3 +17,5 @@ if (ENABLE_CLUSTER_BACKEND_ZEROMQ) add_subdirectory(zeromq) endif () + +add_subdirectory(none) diff --git a/src/cluster/backend/none/CMakeLists.txt b/src/cluster/backend/none/CMakeLists.txt new file mode 100644 index 0000000000..60b3dff0cb --- /dev/null +++ b/src/cluster/backend/none/CMakeLists.txt @@ -0,0 +1,3 @@ +zeek_add_plugin( + Zeek Cluster_Backend_None + SOURCES Plugin.cc) diff --git a/src/cluster/backend/none/Plugin.cc b/src/cluster/backend/none/Plugin.cc new file mode 100644 index 0000000000..eaf09a8446 --- /dev/null +++ b/src/cluster/backend/none/Plugin.cc @@ -0,0 +1,55 @@ +// See the file "COPYING" in the main distribution directory for copyright. + +#include "zeek/plugin/Plugin.h" + +#include "zeek/cluster/Backend.h" +#include "zeek/cluster/Component.h" +#include "zeek/cluster/Serializer.h" + +namespace { + +using namespace zeek::cluster; + +/** + * A backend that does nothing. + */ +class NoneBackend : public ThreadedBackend { +private: + void DoInitPostScript() override {}; + bool DoPublishLogWrites(const zeek::logging::detail::LogWriteHeader& header, const std::string& format, + zeek::byte_buffer& buf) override { + return true; + } + bool DoPublishEvent(const std::string& topic, const std::string& format, const zeek::byte_buffer& buf) override { + return true; + }; + bool DoSubscribe(const std::string& topic_prefix, SubscribeCallback cb) override { return true; }; + bool DoUnsubscribe(const std::string& topic_prefix) override { return true; }; + +public: + NoneBackend(std::unique_ptr es, std::unique_ptr ls, + std::unique_ptr ehs) + : ThreadedBackend("None", std::move(es), std::move(ls), std::move(ehs)) {} + + static std::unique_ptr Instantiate(std::unique_ptr es, std::unique_ptr ls, + std::unique_ptr ehs) { + return std::make_unique(std::move(es), std::move(ls), std::move(ehs)); + } +}; +} // namespace + + +namespace zeek::plugin::Zeek_Cluster_None { + +class Plugin : public zeek::plugin::Plugin { + zeek::plugin::Configuration Configure() override { + AddComponent(new cluster::BackendComponent("None", NoneBackend::Instantiate)); + + zeek::plugin::Configuration config; + config.name = "Zeek::Cluster_Backend_None"; + config.description = "Cluster backend none"; + return config; + } +} plugin; + +} // namespace zeek::plugin::Zeek_Cluster_None