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 io.grpc.examples.helloworld
when I try to import anything using import io.grpc.examples.helloworld.helloworld.{foo}
.
My build.sbt file:
name := "Distributed sorting"
version := "0.1"
scalaVersion := "2.13.7"
libraryDependencies ++= Seq(
"io.grpc" % "grpc-netty" % scalapb.compiler.Version.grpcJavaVersion,
"com.thesamet.scalapb" %% "scalapb-runtime-grpc" % scalapb.compiler.Version.scalapbVersion
)
Compile / PB.targets := Seq(
scalapb.gen() -> (Compile / sourceManaged).value / "scalapb"
)
My files look like this:
├── build.sbt
├── project
│ ├── build.properties
│ ├── scalapb.sbt
│ └── target
├── ...
└── src/main
├── protobuf
├── hello.proto
└── scala/io/grpc/examples/helloworld
├── HelloWorldClient.scala
└── HelloWorldServer.scala
Firstly, I recommend using Akka gRPC rather than using ScalaPB directly. The documentation is pretty clear and there is a giter8 config that can be used to create a sample project using sbt new
.
Secondly, the code in that gitHub does not look like official sample code. It says it has been "translated from grpc java" which is probably not what you want.
Finally, on the specific issue you are seeing, the stubs generated by scalaPB are in a package whose name is given in the proto
file. The example file has
package com.example.protos
So the stubs will be in com.example.protos.Greeter
.