mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 17:18:20 +00:00
cluster/Backend: Add name and lookup component tag
This adds two new accessors on Backend, Name() and Tag() that can be used for introspection of a Backend instance.
This commit is contained in:
parent
214629e054
commit
3946856f06
5 changed files with 37 additions and 12 deletions
|
@ -10,6 +10,7 @@
|
|||
#include "zeek/Func.h"
|
||||
#include "zeek/Reporter.h"
|
||||
#include "zeek/Type.h"
|
||||
#include "zeek/cluster/Manager.h"
|
||||
#include "zeek/cluster/OnLoop.h"
|
||||
#include "zeek/cluster/Serializer.h"
|
||||
#include "zeek/logging/Manager.h"
|
||||
|
@ -69,9 +70,16 @@ std::optional<zeek::Args> detail::check_args(const zeek::FuncValPtr& handler, ze
|
|||
return result;
|
||||
}
|
||||
|
||||
Backend::Backend(std::unique_ptr<EventSerializer> es, std::unique_ptr<LogSerializer> ls,
|
||||
Backend::Backend(std::string_view arg_name, std::unique_ptr<EventSerializer> es, std::unique_ptr<LogSerializer> ls,
|
||||
std::unique_ptr<detail::EventHandlingStrategy> ehs)
|
||||
: event_serializer(std::move(es)), log_serializer(std::move(ls)), event_handling_strategy(std::move(ehs)) {}
|
||||
: name(arg_name),
|
||||
event_serializer(std::move(es)),
|
||||
log_serializer(std::move(ls)),
|
||||
event_handling_strategy(std::move(ehs)) {
|
||||
tag = zeek::cluster::manager->Backends().GetComponentTag(name);
|
||||
if ( ! tag )
|
||||
reporter->InternalError("unknown cluster backend name '%s'; mismatch with tag component?", name.c_str());
|
||||
}
|
||||
|
||||
std::optional<detail::Event> Backend::MakeClusterEvent(FuncValPtr handler, ArgsSpan args, double timestamp) const {
|
||||
auto checked_args = detail::check_args(handler, args);
|
||||
|
@ -158,10 +166,10 @@ bool ThreadedBackend::ProcessBackendMessage(int tag, detail::byte_buffer_span pa
|
|||
return DoProcessBackendMessage(tag, payload);
|
||||
}
|
||||
|
||||
ThreadedBackend::ThreadedBackend(std::unique_ptr<EventSerializer> es, std::unique_ptr<LogSerializer> ls,
|
||||
std::unique_ptr<detail::EventHandlingStrategy> ehs)
|
||||
: Backend(std::move(es), std::move(ls), std::move(ehs)) {
|
||||
onloop = new zeek::detail::OnLoopProcess<ThreadedBackend, QueueMessage>(this, "ThreadedBackend");
|
||||
ThreadedBackend::ThreadedBackend(std::string_view name, std::unique_ptr<EventSerializer> es,
|
||||
std::unique_ptr<LogSerializer> ls, std::unique_ptr<detail::EventHandlingStrategy> ehs)
|
||||
: Backend(name, std::move(es), std::move(ls), std::move(ehs)) {
|
||||
onloop = new zeek::detail::OnLoopProcess<ThreadedBackend, QueueMessage>(this, Name());
|
||||
onloop->Register(true); // Register as don't count first
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue