diff --git a/src/cluster/serializer/broker/Serializer.cc b/src/cluster/serializer/broker/Serializer.cc index 11a7ed86c0..f2308cb627 100644 --- a/src/cluster/serializer/broker/Serializer.cc +++ b/src/cluster/serializer/broker/Serializer.cc @@ -20,15 +20,7 @@ using namespace zeek::cluster; -namespace { - -/** - * Convert a cluster::detail::Event to a broker::zeek::Event. - * - * @param ev The cluster::detail::Event - * @return A broker::zeek::Event to be serialized, or nullopt in case of errors. - */ -std::optional to_broker_event(const detail::Event& ev) { +std::optional detail::to_broker_event(const detail::Event& ev) { broker::vector xs; xs.reserve(ev.args.size()); @@ -51,15 +43,7 @@ std::optional to_broker_event(const detail::Event& ev) { return broker::zeek::Event(ev.HandlerName(), xs, broker::to_timestamp(ev.timestamp)); } -/** - * Convert a broker::zeek::Event to cluster::detail::Event by looking - * it up in Zeek's event handler registry and converting event arguments - * to the appropriate Val instances. - * - * @param broker_ev The broker side event. - * @returns A zeek::cluster::detail::Event instance, or std::nullopt if the conversion failed. - */ -std::optional to_zeek_event(const broker::zeek::Event& ev) { +std::optional detail::to_zeek_event(const broker::zeek::Event& ev) { auto&& name = ev.name(); auto&& args = ev.args(); @@ -117,8 +101,6 @@ std::optional to_zeek_event(const broker::zeek::Event& ev) { return detail::Event{handler, std::move(vl), ts}; } -} // namespace - bool detail::BrokerBinV1_Serializer::SerializeEvent(detail::byte_buffer& buf, const detail::Event& event) { auto ev = to_broker_event(event); if ( ! ev ) diff --git a/src/cluster/serializer/broker/Serializer.h b/src/cluster/serializer/broker/Serializer.h index 00973b90c1..4b9adae241 100644 --- a/src/cluster/serializer/broker/Serializer.h +++ b/src/cluster/serializer/broker/Serializer.h @@ -4,8 +4,30 @@ #include "zeek/cluster/Serializer.h" +namespace broker::zeek { +class Event; +} + namespace zeek::cluster::detail { +/** + * Convert a broker::zeek::Event to cluster::detail::Event by looking + * it up in Zeek's event handler registry and converting event arguments + * to the appropriate Val instances. + * + * @param ev The broker side event. + * @returns A zeek::cluster::detail::Event instance, or std::nullopt if the conversion failed. + */ +std::optional to_zeek_event(const broker::zeek::Event& ev); + +/** + * Convert a cluster::detail::Event to a broker::zeek::Event. + * + * @param ev The cluster::detail::Event + * @return A broker::zeek::Event to be serialized, or nullopt in case of errors. + */ +std::optional to_broker_event(const detail::Event& ev); + // Implementation of the EventSerializer using the existing broker::detail::val_to_data() // and broker::format::bin::v1::encode(). class BrokerBinV1_Serializer : public EventSerializer {