Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate protobuf in scala?

Here is what my proto file looks like :

option java_package = "com.test.report";

message ClientRecord
 {
optional string cust_id           = 1;
optional double tx_bytes          = 2;
optional double rx_bytes          = 3;
optional string source_id         = 4;
optional string dest_id           = 5;
}

message ClientRecords
{
repeated ClientRecord record       = 1;
}

I am able to write protobuf generator/decoder in python, but how do I write it in Scala/Java. Can anyone help me to write a generator in Scala for my example?

like image 740
sk1007 Avatar asked Feb 25 '16 18:02

sk1007


1 Answers

Check out ScalaPB

More specifically, check out this section which shows an example of how generate a Scala case class for a given proto file. It will generate parsers and serializers as well. Hope this helps you

like image 66
Cal Avatar answered Nov 01 '22 00:11

Cal