[nanomsg] Re: publish/subscribe keys

  • From: Yursen Kim <kyursen@xxxxxxxxx>
  • To: nanomsg@xxxxxxxxxxxxx
  • Date: Thu, 14 Aug 2014 20:15:23 +0400

2014-08-14 16:08 GMT+04:00 John Carneiro <johncarneiro@xxxxxxxxxxx>:

> This makes it a little more difficult as I use google protobufs
> to serialize the messages in binary prior to being sent, but
> if I understand it correctly, I could prefix the binary serialization with
> the ascii text subscription tag.
>

Subscription key is not necessarily an ascii text.
It can be any binary data with fixed length, so there is no need in
mixing text prefix with binary payload.

For example, protocol buffers message can be prefixed with a 32-bit unsigned
integer that can be encoded/decoded in little-endian order with protobuf
functions CodedOutputStream::WriteLittleEndian32() and
CodedInputStream::ReadLittleEndian32().

Also, there is struct nn_msghdr that can be used to explicitly split
message envelope into two parts: header (prefix) and payload
(serialized protobuf).

Other related posts: