mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
cluster/Backend: Pass node_id via Init()
This commit is contained in:
parent
0b7a660a34
commit
769044e8e1
3 changed files with 20 additions and 4 deletions
|
@ -585,7 +585,7 @@ function log(msg: string)
|
||||||
|
|
||||||
function init(): bool
|
function init(): bool
|
||||||
{
|
{
|
||||||
return Cluster::Backend::__init();
|
return Cluster::Backend::__init(Cluster::node_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
function subscribe(topic: string): bool
|
function subscribe(topic: string): bool
|
||||||
|
|
|
@ -149,8 +149,14 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method invoked from the Cluster::Backend::__init() bif.
|
* Method invoked from the Cluster::Backend::__init() bif.
|
||||||
|
*
|
||||||
|
* @param nid The node identifier to use.
|
||||||
*/
|
*/
|
||||||
bool Init() { return DoInit(); }
|
bool Init(std::string nid) {
|
||||||
|
node_id = std::move(nid);
|
||||||
|
|
||||||
|
return DoInit();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook invoked when Zeek is about to terminate.
|
* Hook invoked when Zeek is about to terminate.
|
||||||
|
@ -209,6 +215,11 @@ public:
|
||||||
return DoPublishLogWrites(header, records);
|
return DoPublishLogWrites(header, records);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return This backend's node identifier.
|
||||||
|
*/
|
||||||
|
const std::string& NodeId() const { return node_id; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
|
@ -362,6 +373,11 @@ private:
|
||||||
std::unique_ptr<EventSerializer> event_serializer;
|
std::unique_ptr<EventSerializer> event_serializer;
|
||||||
std::unique_ptr<LogSerializer> log_serializer;
|
std::unique_ptr<LogSerializer> log_serializer;
|
||||||
std::unique_ptr<detail::EventHandlingStrategy> event_handling_strategy;
|
std::unique_ptr<detail::EventHandlingStrategy> event_handling_strategy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The backend's instance cluster node identifier.
|
||||||
|
*/
|
||||||
|
std::string node_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -64,9 +64,9 @@ function Cluster::__unsubscribe%(topic_prefix: string%): bool
|
||||||
## Initialize the global cluster backend.
|
## Initialize the global cluster backend.
|
||||||
##
|
##
|
||||||
## Returns: true on success.
|
## Returns: true on success.
|
||||||
function Cluster::Backend::__init%(%): bool
|
function Cluster::Backend::__init%(nid: string%): bool
|
||||||
%{
|
%{
|
||||||
auto rval = zeek::cluster::backend->Init();
|
auto rval = zeek::cluster::backend->Init(nid->ToStdString());
|
||||||
return zeek::val_mgr->Bool(rval);
|
return zeek::val_mgr->Bool(rval);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue