Skip to content
This repository was archived by the owner on Oct 13, 2025. It is now read-only.

Commit 2a8c7da

Browse files
committed
broker/cluster: Changes for auto_publish() deprecation
1 parent a06a267 commit 2a8c7da

File tree

4 files changed

+16
-34
lines changed

4 files changed

+16
-34
lines changed

frameworks/broker.rst

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -276,19 +276,11 @@ define any event handlers for events that peers will send.
276276
:linenos:
277277
:tab-width: 4
278278

279-
There are two different ways to send events.
280-
281-
The first is to call the :zeek:see:`Broker::publish` function which you can
279+
To send an event, call the :zeek:see:`Broker::publish` function which you can
282280
supply directly with the event and its arguments or give it the return value of
283281
:zeek:see:`Broker::make_event` in case you need to send the same event/args
284282
multiple times. When publishing events like this, local event handlers for
285-
the event are not called.
286-
287-
The second option is to call the :zeek:see:`Broker::auto_publish` function where
288-
you specify a particular event that will be automatically sent to peers
289-
whenever the event is called locally via the normal event invocation syntax.
290-
When auto-publishing events, local event handlers for the event are called
291-
in addition to sending the event to any subscribed peers.
283+
the event are not called, even if a matching subscription exists.
292284

293285
.. literalinclude:: broker/events-connector.zeek
294286
:caption: events-connector.zeek
@@ -301,6 +293,20 @@ to the ``zeek/events`` topic prefix you would receive events that are published
301293
to topic names ``zeek/events/foo`` and ``zeek/events/bar`` but not
302294
``zeek/misc``.
303295

296+
297+
.. note::
298+
299+
In prior Zeek versions, :zeek:see:`Broker::auto_publish` was available to
300+
automatically send events to peers whenever the events were called locally via
301+
the normal event invocation syntax. When auto-publishing events, local
302+
event handlers for the event were called in addition to sending the
303+
event to any subscribed peers.
304+
305+
:zeek:see:`Broker::auto_publish` has been deprecated due to its
306+
`implicit nature <https://github.com/zeek/zeek/discussions/3637>`_.
307+
308+
.. deprecated:: 7.1
309+
304310
Remote Logging
305311
--------------
306312

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
redef exit_only_after_terminate = T;
22
global my_event: event(msg: string, c: count);
3-
global my_auto_event: event(msg: string, c: count);
43

54
event zeek_init()
65
{
76
Broker::peer("127.0.0.1");
8-
Broker::auto_publish("zeek/event/my_auto_event", my_auto_event);
97
}
108

119
event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string)
1210
{
1311
print "peer added", endpoint;
1412
Broker::publish("zeek/event/my_event", my_event, "hi", 0);
15-
event my_auto_event("stuff", 88);
1613
Broker::publish("zeek/event/my_event", my_event, "...", 1);
17-
event my_auto_event("more stuff", 51);
1814
local e = Broker::make_event(my_event, "bye", 2);
1915
Broker::publish("zeek/event/my_event", e);
2016
}
@@ -28,8 +24,3 @@ event my_event(msg: string, c: count)
2824
{
2925
print "got my_event", msg, c;
3026
}
31-
32-
event my_auto_event(msg: string, c: count)
33-
{
34-
print "got my_auto_event", msg, c;
35-
}

frameworks/broker/events-listener.zeek

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,3 @@ event my_event(msg: string, c: count)
2222
if ( msg_count == 5 )
2323
terminate();
2424
}
25-
26-
event my_auto_event(msg: string, c: count)
27-
{
28-
++msg_count;
29-
print "got my_auto_event", msg, c;
30-
31-
if ( msg_count == 5 )
32-
terminate();
33-
}

frameworks/cluster.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -334,12 +334,6 @@ function to publish events, including:
334334
- Standard function to send an event to all nodes subscribed to a given
335335
topic
336336

337-
* - :zeek:see:`Broker::auto_publish`
338-
- Automatically send an otherwise generated Zeek event to any interested
339-
peers whenever it is locally dispatched.
340-
- Avoid, since it is somewhat “magical”, unless you’ve got code
341-
compartmentalization running with ``@ifdef`` directives.
342-
343337
* - :zeek:see:`Cluster::publish_hrw`
344338
- Publishes an event to a node within a pool according to
345339
Highest Random Weight (HRW) hashing strategy; see details below

0 commit comments

Comments
 (0)