Questions tagged [scalapb]

ScalaPB is a protocol buffer compiler (protoc) plugin for Scala. It generates Scala case classes, parsers and serializers for protocol buffers.

Main features:

Built on top of Google’s protocol buffer compiler to ensure perfect compatibility with the language specification.

Nested updates are easy by using lenses:

val newOrder = order.update(_.creditCard.expirationYear := 2015)

Generated case classes can co-exist alongside the Java-generated code (the class names will not clash). This allows gradual transition from Java to Scala.

Can optionally generate conversion methods between the Java generated version of Protocol Buffers to the Scala generated version. This makes it possible to migrate your project gradually.

Supports for Oneof’s that were introduced in Protocol Buffers 2.6.0.

Learn more here: https://scalapb.github.io/index.html

Source code: https://github.com/scalapb/ScalaPB

104 questions
0
votes
2 answers

How to write google protobuf messages in java?

I am using google protobuf library to write messages in a file. However these messages do not look binary messages to me. The proto I am using is simple it has Name, Email and Cell No. The file I get is: * bilalÈÇbilal@gmail.com" 12345678 If I read…
Bilal Shafqat
  • 689
  • 2
  • 14
  • 26
0
votes
2 answers

scalapb with maven not generating any grpc service classes

I am trying to create a simple gRPC service with ScalaPB and Maven. Following is my directory structure : ├── main │   ├── proto │   │   └── simple.proto │   ├── resources │   └── scala │   └── me │   ├── protogrpc │   │   └──…
TheNormalGuy
  • 371
  • 3
  • 16
0
votes
1 answer

Parsing Protobuf ByteString in Spark not working after creating Encoder

I'm trying to parse protobuf (protobuf3) data in spark 2.4 and I'm having some trouble with the ByteString type. I've created the case class using the ScalaPB library and loaded the jar into a spark shell. I've also tried creating a implicit encoder…
0
votes
1 answer

deserialize json object from protobuf return empty

I am parsing the bahir mqtt payload serialized via protobuf using scalapb in spark scala but the parsed json only contains first json object and others are empty. Spark version: 2.3.0 Scala version: 2.11.8 Protobuf version: 2 sparksql-scalapb…
0
votes
1 answer

ScalaPB TypeMapper for custom primitive wrappers not found

I am using addSbtPlugin("com.thesamet" % "sbt-protoc" % "0.99.23") libraryDependencies += "com.thesamet.scalapb" %% "compilerplugin" % "0.9.0-M7" I have some custom primitive wrappers (we are not using google wrappers) syntax = "proto3"; package…
fpopic
  • 1,756
  • 3
  • 28
  • 40
0
votes
1 answer

Writing TypeMapper for map with scalapb

I would like to make map in case class generated from protobuf wrapped in Option case class Foo(aMap: Option[Map[String, String]]) For that I am trying to use scalapb.TypeMapper package some.wrapper import scalapb.TypeMapper case class…
Artem Petrov
  • 772
  • 4
  • 17
0
votes
3 answers

Derive Avro schema from Scala case class generated by ScalaPB

I'm trying to derive Avro Schema from ScalaPB generated case class (from Protobuf definition) using Avro4s, but couldn't succeed. The example below shows the problem. My protobuf file test.proto: message Test { // Unix timestamp in…
mmziyad
  • 298
  • 1
  • 4
  • 16
0
votes
2 answers

Scala/Akka/Protobuf: Failed to serialize and deserialize message

we are trying to using protobuf with Akka and serialize all Akka messages via protobuf. For Scala, we have a library called ScalaPB which help us to generate the class, which includes methods like parseFrom, toByteArray etc for serializing or…
Harmeet Singh Taara
  • 6,483
  • 20
  • 73
  • 126
0
votes
2 answers

Issue while sbt compile with scalapb

I am trying to use scalapb to generate case classes from my protobuf. But, I am currently compilation errors. I have my scalapb.sbt as follows: addSbtPlugin("com.trueaccord.scalapb" % "sbt-scalapb" % "0.5.26") libraryDependencies ++= Seq( …
PankajK
  • 187
  • 3
  • 14
0
votes
1 answer

How to import firestore's RPC api/definitions in a .proto file?

Wrt a scala application for interacting with firestore's RPC apis, and using scalapb proto compiler /akka-grpc middleware, how to import the firestore RPC API's definitions in the .proto files? Eg. how to import the Document definition? Trying to…
sidnt
  • 170
  • 10
0
votes
1 answer

Is it possible to overwrite and use the same value in multiple build.sbt files?

I have the following dummy project structure: |───employee-uService | ├───backend | | ├───employee-api | | ├───project | | ├───src | | │ └───main | | │ ├───protobuf | | │ └───scala | …
Iamtazy
  • 5
  • 2
0
votes
1 answer

Creating a function with generic type with ScalaPB

I have the following function (which works on a protobuf object MyRequest def createRequestFromJson(requestJson: String): MyRequest = { val protoJson = getResource(requestJson) JsonFormat.fromJsonString[MyRequest](protoJson) } I want to…
Nick Ginanto
  • 31,090
  • 47
  • 134
  • 244
0
votes
2 answers

Object Proto already defined

I'm using Scala 2.11.8 and trying to add protobuf. Here is my log : [info] Protoc target directory: /home/user/Git/tortle/target/src_managed/main [info] Protoc target directory: /home/user/Git/tortle/target/src_managed/main [...] [error]…
Laurie Ma
  • 35
  • 1
  • 5
0
votes
0 answers

Protobuf input validation and model translation

I'm at a company where we're currently using protobuf3 (with scalapb in my case) for a lot of our internal communication. This version of protobuf does away with the optional and required labels from previous versions due to the 'required is…
tjarvstrand
  • 836
  • 9
  • 20
0
votes
1 answer

It is possible to run recent version of ScalaPB (0.6.x) with protobuf 2.5.0?

did anyone try it? I need to generate scala classes for protobuf 2.5.0 Seems like ScalaPB supports protobuf 3.x and not 2.5.0
Capacytron
  • 3,425
  • 6
  • 47
  • 80