sk1007
sk1007

Reputation: 581

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?

Upvotes: 6

Views: 13118

Answers (1)

Cal
Cal

Reputation: 734

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

Upvotes: 6

Related Questions