mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
cluster: Add None backend
Mostly so we have the CLUSTER_BACKEND_NONE value available, but potentially useful for testing, too.
This commit is contained in:
parent
69b7bcc323
commit
a501c35d8d
3 changed files with 60 additions and 0 deletions
|
@ -17,3 +17,5 @@ if (ENABLE_CLUSTER_BACKEND_ZEROMQ)
|
|||
|
||||
add_subdirectory(zeromq)
|
||||
endif ()
|
||||
|
||||
add_subdirectory(none)
|
||||
|
|
3
src/cluster/backend/none/CMakeLists.txt
Normal file
3
src/cluster/backend/none/CMakeLists.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
zeek_add_plugin(
|
||||
Zeek Cluster_Backend_None
|
||||
SOURCES Plugin.cc)
|
55
src/cluster/backend/none/Plugin.cc
Normal file
55
src/cluster/backend/none/Plugin.cc
Normal file
|
@ -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<EventSerializer> es, std::unique_ptr<LogSerializer> ls,
|
||||
std::unique_ptr<detail::EventHandlingStrategy> ehs)
|
||||
: ThreadedBackend("None", std::move(es), std::move(ls), std::move(ehs)) {}
|
||||
|
||||
static std::unique_ptr<Backend> Instantiate(std::unique_ptr<EventSerializer> es, std::unique_ptr<LogSerializer> ls,
|
||||
std::unique_ptr<detail::EventHandlingStrategy> ehs) {
|
||||
return std::make_unique<NoneBackend>(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
|
Loading…
Add table
Add a link
Reference in a new issue