mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
cluster: Add Cluster scoped bifs
... and a broker based test using Cluster::publish() and Cluster::subscribe().
This commit is contained in:
parent
27e6d87331
commit
ef04a199c8
17 changed files with 591 additions and 1 deletions
|
@ -281,7 +281,30 @@ export {
|
|||
## a given cluster node.
|
||||
global nodeid_topic: function(id: string): string;
|
||||
|
||||
## Initialize the cluster backend.
|
||||
##
|
||||
## Cluster backends usually invoke this from a :zeek:see:`zeek_init` handler.
|
||||
##
|
||||
## Returns: T on success, else F.
|
||||
global init: function(): bool;
|
||||
|
||||
## Subscribe to the given topic.
|
||||
##
|
||||
## topic: The topic to subscribe to.
|
||||
##
|
||||
## Returns: T on success, else F.
|
||||
global subscribe: function(topic: string): bool;
|
||||
|
||||
## Unsubscribe from the given topic.
|
||||
##
|
||||
## topic: The topic to unsubscribe from.
|
||||
##
|
||||
## Returns: T on success, else F.
|
||||
global unsubscribe: function(topic: string): bool;
|
||||
|
||||
## An event instance for cluster pub/sub.
|
||||
##
|
||||
## See :zeek:see:`Cluster::publish` and :zeek:see:`Cluster::make_event`.
|
||||
type Event: record {
|
||||
## The event handler to be invoked on the remote node.
|
||||
ev: any;
|
||||
|
@ -290,6 +313,10 @@ export {
|
|||
};
|
||||
}
|
||||
|
||||
# Needs declaration of Cluster::Event type.
|
||||
@load base/bif/cluster.bif
|
||||
|
||||
|
||||
# Track active nodes per type.
|
||||
global active_node_ids: table[NodeType] of set[string];
|
||||
|
||||
|
@ -528,3 +555,18 @@ function log(msg: string)
|
|||
{
|
||||
Log::write(Cluster::LOG, [$ts = network_time(), $node = node, $message = msg]);
|
||||
}
|
||||
|
||||
function init(): bool
|
||||
{
|
||||
return Cluster::Backend::__init();
|
||||
}
|
||||
|
||||
function subscribe(topic: string): bool
|
||||
{
|
||||
return Cluster::__subscribe(topic);
|
||||
}
|
||||
|
||||
function unsubscribe(topic: string): bool
|
||||
{
|
||||
return Cluster::__unsubscribe(topic);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue