Wire: grpc: use ServiceServer generated stubs out of cashapp/misk

Created on 1 Oct 2020  Â·  11Comments  Â·  Source: square/wire

Is it possible ServiceServer generated stubs to be used out of cashapp/misk?

As I looked into examples, they are using cashapp/misk which is using internally WebActionsServlet to dispatch gRPC calls to the proper method of the service stub.

Most helpful comment

@mgenov @swankjesse with the latest version, can it resolve this issue:

Code generation for plain gRPC server. The Kotlin target now has a new grpcServerCompatible option which if set to true will generate gRPC server-compatible classes.

All 11 comments

Or is this request about using Wire on a different server framework?

Yes, using wire with different server framework.

My current issue is that I have a kotlin backend that is using sparkjava for REST and I'm trying to expose some of it's existing REST services as gRPC ones.

Other ideas for similar transition are also welcome.

@mgenov can you fork the gRPC servlet code from Misk in your application? It's _almost_ a standard servlet with one exception; we need to configure this in Jetty:

https://github.com/cashapp/misk/blob/c7e51cbb1ff6947f17839b6cb21c797c8d397593/misk/src/main/kotlin/misk/web/jetty/JettyService.kt#L335

Unfortunately it's likely necessary to configure this into each Java web framework independently, or to build a single servlet that doesn't hook into those frameworks’ authentication, management, and observability systems.

Thanks @swankjesse . I'll look into it.

In grpc-java the API is really simple and the gRPC services could be served directly using usePlainText without any complexity. I know that it's a security issue, but envoy could do the SSL offloading which could simplify the application code. What I saw in misk is that WebConfig.ssl is used when starting jetty and I suppose jetty is doing the SSL stuff on it's own but I'll take a deeper look into it.

Here is an example API with grpc-java

  val gRpcServer = ServerBuilder.forPort(50051)
            .addService(MyService())
            .intercept(InternalServerSecurityInterceptor())
            .build()
  gRpcServer.start()

with grpc-java client code is able to pass service implementations and interceptors (security checks and etc).

is it possible to have an adapter to map wire Service to io.grpc BindableService?

So did it go thru

On Mon, Nov 30, 2020, 9:54 PM iTanChi notifications@github.com wrote:

is it possible to have an adapter to map wire Service to io.grpc
BindableService?

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/square/wire/issues/1814#issuecomment-736183571, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AR26MFDNOBEQQGONS3HDYU3SSRLGHANCNFSM4SAAVCUQ
.

@iTanChi nothing built in but you could create one.

@mgenov @swankjesse with the latest version, can it resolve this issue:

Code generation for plain gRPC server. The Kotlin target now has a new grpcServerCompatible option which if set to true will generate gRPC server-compatible classes.

@iTanChi Thank you for referencing this, I was looking for exactly that.

Only thing is that the output has an error for me:

  public abstract class GreeterImplBase : BindableService {
    public open fun sayHello(request: HelloRequest, response: StreamObserver<HelloReply>) = throw
        UnsupportedOperationException()

Producing this error:

'Nothing' return type needs to be specified explicitly

Any clue how to solve this?

Also seems to lack a class like GreetersayHelloBlockingServer

Edit; I decided to open another issue for this #1903 I'll leave this for reference.

Was this page helpful?
0 / 5 - 0 ratings