Integration of Play Framework 2.6 with gRPC and Netty

At the time I am writing this post, the Play Framework is in v2.6.0-M4 . The framework version v2.5 had a hard time working with gRPC due to Netty conflicts (see https://stackoverflow.com/a/16620/ ... ).

I am starting to learn gRPC and protobufs. A project has already been migrated from Play Framework 2.5> 2.6.0-M4 in anticipation of the actual release. I currently have some questions regarding gRPC integration. I am wondering how to let the gRPC server work well with the Play Framework. I know that v2.6 switched to Akka HTTP server instead of Netty, while I use the dependency grpc-nettyin sbt, so maybe I will have to switch the project to Netty again (here's how ).

For testing purposes, I created a quick and dirty class GrpcServer.scalathat starts a thread listening to GrpcServer. I managed to add ScalaPB using gRPC and generate / compile my protobuf. It works great for communicating with a small testing NodeJS application, but I have to run this server application regardless of the main project:

private def start(): Unit = {
    server = ServerBuilder.forPort(GrpcServer.port).addService(GreeterGrpc.bindService(new GreeterImpl, executionContext)).build.start
    GrpcServer.logger.info("Server started, listening on " + GrpcServer.port)
    sys.addShutdownHook {
        System.err.println("*** shutting down gRPC server")
        self.stop()
        System.err.println("*** server shut down")
    }
}

Possible solutions for integrating gRPC into the Play Framework

Now for real integration in the Play Framework v2.6, I'm looking for suggestions. Here are some things I can do:

  • module gRPC Play Framework, qaru.site/questions/416620/.... , gRPC (HTTP- Akka Play Framework 2.6).
  • Scala . , , gRPC, .
  • Akka HTTP Netty Play Framework v2.6 gRPC Netty, Netty , . , , . , , http.

/ , Play Framework gRPC , , 2.5...

+4

Source: https://habr.com/ru/post/1674787/


All Articles