diff --git a/NEWS b/NEWS index 0098c11e951..c4b4e7dc00f 100644 --- a/NEWS +++ b/NEWS @@ -109,6 +109,10 @@ Removed Functionality Deprecated Functionality ------------------------ +* The ``Broker::auto_publish()`` function has been deprecated and should + be replaced with explicit ``Broker::publish()`` invocations that are + potentially guarded with appropriate ``@if`` or ``@ifdef`` directives. + Zeek 7.0.0 ========== diff --git a/scripts/base/frameworks/broker/main.zeek b/scripts/base/frameworks/broker/main.zeek index 0dd61f9139a..d41f64ab2ef 100644 --- a/scripts/base/frameworks/broker/main.zeek +++ b/scripts/base/frameworks/broker/main.zeek @@ -395,7 +395,7 @@ export { ## ev: a Zeek event value. ## ## Returns: true if automatic event sending is now enabled. - global auto_publish: function(topic: string, ev: any): bool; + global auto_publish: function(topic: string, ev: any): bool &deprecated="Remove in v8.1. Switch to explicit Broker::publish() calls. Auto-publish won't work with all cluster backends."; ## Stop automatically sending an event to peers upon local dispatch. ## @@ -405,7 +405,7 @@ export { ## ## Returns: true if automatic events will not occur for the topic/event ## pair. - global auto_unpublish: function(topic: string, ev: any): bool; + global auto_unpublish: function(topic: string, ev: any): bool &deprecated="Remove in v8.1. See Broker::auto_publish()"; } @load base/bif/comm.bif diff --git a/src/EventHandler.h b/src/EventHandler.h index 0fbd5c1282f..9291bda8093 100644 --- a/src/EventHandler.h +++ b/src/EventHandler.h @@ -35,9 +35,15 @@ class EventHandler { void SetFunc(FuncPtr f); - void AutoPublish(std::string topic) { auto_publish.insert(std::move(topic)); } + [[deprecated("Remove in v8.1, use explicit Publish().")]] + void AutoPublish(std::string topic) { + auto_publish.insert(std::move(topic)); + } - void AutoUnpublish(const std::string& topic) { auto_publish.erase(topic); } + [[deprecated("Remove in v8.1.")]] + void AutoUnpublish(const std::string& topic) { + auto_publish.erase(topic); + } void Call(zeek::Args* vl, bool no_remote = false, double ts = run_state::network_time); diff --git a/src/broker/Manager.cc b/src/broker/Manager.cc index 44c6c407a0a..270f57c4c1c 100644 --- a/src/broker/Manager.cc +++ b/src/broker/Manager.cc @@ -811,7 +811,10 @@ bool Manager::AutoPublishEvent(string topic, Val* event) { } DBG_LOG(DBG_BROKER, "Enabling auto-publishing of event %s to topic %s", handler->Name(), topic.c_str()); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" handler->AutoPublish(std::move(topic)); +#pragma GCC diagnostic pop return true; } @@ -837,7 +840,10 @@ bool Manager::AutoUnpublishEvent(const string& topic, Val* event) { } DBG_LOG(DBG_BROKER, "Disabling auto-publishing of event %s to topic %s", handler->Name(), topic.c_str()); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" handler->AutoUnpublish(topic); +#pragma GCC diagnostic pop return true; } diff --git a/src/broker/Manager.h b/src/broker/Manager.h index 412fa764ae8..297d7a5f05d 100644 --- a/src/broker/Manager.h +++ b/src/broker/Manager.h @@ -243,6 +243,7 @@ class Manager : public iosource::IOSource { * @param event a Zeek event value. * @return true if automatic event sending is now enabled. */ + [[deprecated("Remove in v8.1, use explicit Publish().")]] bool AutoPublishEvent(std::string topic, Val* event); /** @@ -251,6 +252,7 @@ class Manager : public iosource::IOSource { * @param event an event originally given to zeek::Broker::Manager::AutoPublish(). * @return true if automatic events will no occur for the topic/event pair. */ + [[deprecated("Remove in v8.1.")]] bool AutoUnpublishEvent(const std::string& topic, Val* event); /** @@ -483,7 +485,7 @@ class Manager : public iosource::IOSource { telemetry::CounterPtr num_logs_outgoing_metric; telemetry::CounterPtr num_ids_incoming_metric; telemetry::CounterPtr num_ids_outgoing_metric; -}; +}; // namespace zeek } // namespace Broker diff --git a/src/broker/messaging.bif b/src/broker/messaging.bif index 92bb625dd83..632cf06ce53 100644 --- a/src/broker/messaging.bif +++ b/src/broker/messaging.bif @@ -136,14 +136,20 @@ function Broker::__publish_id%(topic: string, id: string%): bool function Broker::__auto_publish%(topic: string, ev: any%): bool %{ zeek::Broker::Manager::ScriptScopeGuard ssg; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" auto rval = zeek::broker_mgr->AutoPublishEvent(topic->CheckString(), ev); +#pragma GCC diagnostic pop return zeek::val_mgr->Bool(rval); %} function Broker::__auto_unpublish%(topic: string, ev: any%): bool %{ zeek::Broker::Manager::ScriptScopeGuard ssg; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" auto rval = zeek::broker_mgr->AutoUnpublishEvent(topic->CheckString(), ev); +#pragma GCC diagnostic pop return zeek::val_mgr->Bool(rval); %}