Skip to content

Latest commit

 

History

History
37 lines (30 loc) · 1.46 KB

README.md

File metadata and controls

37 lines (30 loc) · 1.46 KB

protoc-decode-lenprefix

Wrapper around protobuf's protoc --decode utility. Adds support for length-prefixed messages.

Usage

cat PROTOBUF_MESSAGE_FILE | \
  protoc-decode-lenprefix -d mesos.internal.StatusUpdateRecord \
    -I MESOS_CODE/src -I MESOS_CODE/include \
    PROTO_FILE \

e.g., say you have a task.updates file generated by Mesos, and say you have downloaded the Mesos source code to the MESOS_CODE dir.

cat task.updates | \
  protoc-decode-lenprefix \
    --decode mesos.internal.StatusUpdateRecord \
    -I MESOS_CODE/src -I MESOS_CODE/include \
    MESOS_CODE/src/messages/messages.proto

This results in all of the StatusUpdateRecord messages in the task.updates input file being written to stdout.

Note how the parameters for protoc-decode-lenprefix are identical to those passed to protoc, assuming you don't have the length-prefix header. e.g., taking a task.info file, we use dd to strip off the 1st 4 bytes and then have protoc decode the embedded message:

dd bs=1 skip=4 if=task.info | \
  protoc \
    --decode=mesos.internal.Task \
    -I MESOS_CODE/src -I MESOS_CODE/include \
    MESOS_CODE/src/messages/messages.proto