Detecting modifications to Protobuf messages

977 views
Skip to first unread message

Jordan Kaye

unread,
Sep 15, 2016, 1:33:02 PM9/15/16
to Protocol Buffers
Hello all,

I've been searching for the better part of a day without finding much information on this topic, so I figured I'd go ahead and ask here.

I'm looking for a way to receive notifications of changes to individual Protobuf message instances. I have an application that would like to persist the changes of a message through time (event sourcing), and it would make things extremely clean if there were some way to accomplish this.

If I were working in C++, it seems that there would at least be the possibility of using the message differencer for this (I could copy a message before applying some logic to it then run the differencer on the the copy and the message after the modification), but the code that I currently have is in Python.

I understand that this is probably a very specific use case, but is there any way for me to achieve something like this?

Thanks,
Jordan

Adam Cozzette

unread,
Sep 16, 2016, 7:47:43 PM9/16/16
to Jordan Kaye, Protocol Buffers
I have to admit that I'm not very familiar with the protocol buffers API for Python, so hopefully someone more knowledgeable can chime in. But given that Python does not have a message differencer, I think your best bet would be to try to use the reflection API to implement something similar. It should allow you to iterate over the fields for a particular message type and check for differences between two protos. On this page under "Advanced Usage" there are some hints about how to do this.

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscribe@googlegroups.com.
To post to this group, send email to prot...@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages