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
14
votes
0 answers

Integrating Play Framework 2.6 with gRPC and Netty

At the time I write this post, Play Framework is at v2.6.0-M4. The v2.5 version of the framework had difficulties to work with gRPC because of Netty conflicts (see this stackoverflow answer). I'm starting to look into gRPC and protobufs. Already…
Jesse
  • 879
  • 1
  • 12
  • 26
9
votes
1 answer

Scala (java) grpc async interceptor state propagation

The question title is probably not so informative, because i am trying to implement a mix of features. I want to authorize caller based on headers he sent and propagate this information to an gRPC method handler. The problem is in the async nature…
zw0rk
  • 1,406
  • 1
  • 12
  • 15
5
votes
2 answers

How to serialize/deserialize a protobuf message that uses 'oneof' with ScalaPB?

I'm using ScalaPB to compile my Scala case classes for serializing my protobuf messages. I have a .proto file with the following messages: message WrapperMessage { oneof msg { Login login = 1; Register register = 2; …
Edward Maxedon
  • 1,151
  • 2
  • 11
  • 17
4
votes
0 answers

Avoid inner classes in ScalaPB compiler

I have proto files and generated Scala classes using ScalaPB. The output looks like: @SerialVersionUID(0L) final case class MetaData extends scalapb.GeneratedMessage { object HeightReferencePointEnum extends…
Andriy Budzinskyy
  • 1,971
  • 22
  • 28
4
votes
1 answer

Manually invoke ScalaPB compiler in an SBT task

I'm using ScalaPB to synthesize Scala classes for converting my data to and from Protobuf representation. By default, the SBT setup hooks into sbt compile to generate the files under the target folder. Because I expect my .proto files to change…
acjay
  • 34,571
  • 6
  • 57
  • 100
3
votes
1 answer

Accessing GRPC context of request in scala

I can't find any example in scala/java where the server side is accessing the context of a grpc request (with scalapb / grpc.io). I can find many examples in golang. I found some of with akka grpc but I am using scalapb and grpc.io If anyone knows…
Nick Ginanto
  • 31,090
  • 47
  • 134
  • 244
3
votes
2 answers

Error when decoding the Proto Buf messages in Spark Streaming , using scalapb

This is a Spark Streaming app that consumes Kafka messages encoded in Proto Buf. Using scalapb library. I am getting the following error. Please help. > com.google.protobuf.InvalidProtocolBufferException: While parsing a > protocol message, the…
3
votes
1 answer

Add Multiple scalapb Source Directories to Multi-Project SBT Build

I'm having some difficulties understanding the syntax for scalapb, specifically I'm trying to add multiple .proto source directories for a multi-project SBT build. My project structure is as…
dthagard
  • 823
  • 7
  • 23
2
votes
1 answer

object is not a member of package

Im trying to implement the simple server-client application using scalaPB's official example. The scala code is found on their gitHub However, when I try to run it, I keep getting the error object helloworld is not a member of package…
Bassusour
  • 175
  • 6
  • 14
2
votes
0 answers

High latency of grpc service using grpc client in kubernetes

I have services (both writtenin scala) deployed in kubernetes cluster, lets name them as external service and internal service External service - 5 pods, expose REST API, consume internal service grpc API thru grpc client Internal service 1 pod,…
Abhay
  • 928
  • 1
  • 10
  • 28
2
votes
1 answer

How to generate algebraic data types in scala using scalaPB

I want to generate below algebraic data types in scala using scalaPB. trait MyEventCmd case class MyEvent(mytype: Int, cp: Option[Double], value: Option[String] = None, id: Option[String] = None) extends MyEventCmd case object Flush extends…
user51
  • 8,843
  • 21
  • 79
  • 158
2
votes
1 answer

Spark structured streaming of Kafka protobuf

I'm trying to create a Spark Streaming that consumes Kafka messages encoded in ProtoBuf. Here is what I tried for the last few days import spark.implicits._ def parseLine (str: Array[Byte]): ProtoSchema = ProtoSchema.parseFrom(str) …
2
votes
1 answer

In ScalaPb, How to create a case object and case class extending from the same trait?

All of my case classes and case objects should be in protobuf. Now I need for them to belong to a single trait. Sadly this is how I have done: message WGCommand { oneof sealed_value { EnqueueWorkDone enq = 1; OpenWorkgroup oWg =…
Jitterbug
  • 302
  • 1
  • 11
2
votes
1 answer

ScalaPB not working when trying to compile SBT project. Compilation fails with "object gen is not a member of package scalapb"

I want to use the ScalaPB plugin in my SBT project. But when I try to compile the project I get an error that states the "object gen is not a member of package scalapb". So how do I configure this plugin to work with my project? I followed the…
TheRealRave
  • 373
  • 1
  • 8
  • 21
2
votes
1 answer

scalapb how to generate code from protobuf files in test directory?

I'd like to generate code from protobuf files in test directory. project/test/protobuf/myproto.proto This doesn't work. PB.targets in Test := Seq( scalapb.gen() -> (sourceManaged in Test).value ) Looks like scalapb only generates files for…
nau
  • 1,145
  • 8
  • 20
1
2 3 4 5 6 7