[Bro-Dev] [Bro-Commits] [git/broker] topic/actor-system: Add broker::bro::RelayEvent message type. (ce86016)

Robin Sommer robin at icir.org
Thu Dec 14 12:07:28 PST 2017


Hi Jon,

I'm curious what's the use case for this? Generally I think it's best
to use a combination of Broker-internal forwarding and topics to
control where messages get propagated too, as that will better
generalize to larger topologies later. The less of the routing we
control manually at the Bro level, the better I'd say. But that's not
an absolute rule of course, and I may just be missing what this is
aiming at.

Robin

On Thu, Dec 14, 2017 at 12:55 -0600, Jonathan Siwek wrote:

> Repository : ssh://git@bro-ids.icir.org/broker
> On branch  : topic/actor-system
> 
> >---------------------------------------------------------------
> 
> commit ce860168961285c6d961973aa9e1ef6b7de87887
> Author: Jon Siwek <jsiwek at corelight.com>
> Date:   Thu Dec 14 12:55:52 2017 -0600
> 
>     Add broker::bro::RelayEvent message type.
>     
>     This is meant to be a more convenient/controlled/explicit way of doing
>     simple one-hop message forwarding.
> 
> 
> >---------------------------------------------------------------
> 
> ce860168961285c6d961973aa9e1ef6b7de87887
>  broker/bro.hh | 36 ++++++++++++++++++++++++++++++++----
>  1 file changed, 32 insertions(+), 4 deletions(-)
> 
> diff --git a/broker/bro.hh b/broker/bro.hh
> index 0d7f0e7..0ec93f2 100644
> --- a/broker/bro.hh
> +++ b/broker/bro.hh
> @@ -18,6 +18,7 @@ public:
>      LogWrite = 3,
>      IdentifierUpdate = 4,
>      Batch = 5,
> +    RelayEvent = 6,
>    };
>  
>    Type type() const {
> @@ -50,7 +51,7 @@ protected:
>  class Event : public Message {
>    public:
>    Event(std::string name, vector args)
> -    : Message(Message::Type::Event, {name, std::move(args)}) {}
> +    : Message(Message::Type::Event, {std::move(name), std::move(args)}) {}
>    Event(data msg) : Message(std::move(msg)) {}
>  
>    const std::string& name() const {
> @@ -62,6 +63,30 @@ class Event : public Message {
>    }
>  };
>  
> +/// A Bro relayed event (automatically republished after a single hop).
> +class RelayEvent : public Message {
> +  public:
> +  RelayEvent(set relay_topics, std::string name, vector args)
> +    : Message(Message::Type::RelayEvent, {std::move(relay_topics),
> +    		                              std::move(name),
> +    		                              std::move(args)})
> +    	{}
> +  RelayEvent(data msg) : Message(std::move(msg)) {}
> +
> +  const set& topics() const {
> +    return get<set>(get<vector>(msg_[2])[0]);
> +  }
> +
> +  const std::string& name() const {
> +    return get<std::string>(get<vector>(msg_[2])[1]);
> +  }
> +
> +  const vector& args() const {
> +    return get<vector>(get<vector>(msg_[2])[2]);
> +  }
> +};
> +
> +
>  /// A batch of other messages.
>  class Batch : public Message {
>    public:
> @@ -81,7 +106,8 @@ public:
>    LogCreate(enum_value stream_id, enum_value writer_id, data writer_info,
>              data fields_data)
>      : Message(Message::Type::LogCreate,
> -              {stream_id, writer_id, writer_info, fields_data}) {
> +              {std::move(stream_id), std::move(writer_id),
> +               std::move(writer_info), std::move(fields_data)}) {
>    }
>  
>    LogCreate(data msg) : Message(std::move(msg)) {
> @@ -108,7 +134,8 @@ public:
>    LogWrite(enum_value stream_id, enum_value writer_id, data path,
>  	   data vals_data)
>      : Message(Message::Type::LogWrite,
> -              {stream_id, writer_id, path, vals_data}) {
> +              {std::move(stream_id), std::move(writer_id),
> +               std::move(path), std::move(vals_data)}) {
>    }
>  
>    LogWrite(data msg) : Message(std::move(msg)) {
> @@ -131,7 +158,8 @@ public:
>  class IdentifierUpdate : public Message {
>  public:
>    IdentifierUpdate(std::string id_name, data id_value)
> -    : Message(Message::Type::IdentifierUpdate, {id_name, id_value}) {
> +    : Message(Message::Type::IdentifierUpdate, {std::move(id_name),
> +    		                                    std::move(id_value)}) {
>    }
>  
>    IdentifierUpdate(data msg) : Message(std::move(msg)) {
> 
> 
> 
> _______________________________________________
> bro-commits mailing list
> bro-commits at bro.org
> http://mailman.icsi.berkeley.edu/mailman/listinfo/bro-commits
> 




-- 
Robin Sommer * ICSI/LBNL * robin at icir.org * www.icir.org/robin


More information about the bro-dev mailing list