playframework / play-grpc

Play + Pekko gRPC
Apache License 2.0
35 stars 29 forks source link

Server code generated by RouterUsingActions does not compile #292

Closed drZoid closed 4 years ago

drZoid commented 4 years ago

Context - I am trying to generate a play router stub which uses Actions. (as described in this issue https://github.com/akka/akka-grpc/issues/420)

Problem - The code generated using the twirl template for RouterUsingActions has compile time errors.

/AbstractRouter.scala:22:223: type mismatch;
[error]  found   : PartialFunction[Throwable,akka.grpc.Trailers]
[error]  required: PartialFunction[Throwable,io.grpc.Status]
[error]   abstract class AbstractUserServiceRouter(mat: Materializer, system: ActorSystem, parsers: PlayBodyParsers, actionBuilder: ActionBuilder[Request, AnyContent], eHandler: ActorSystem => PartialFunction[Throwable, Status] = defaultMapper) extends PlayRouterUsingActions(mat, GreeterService.name, parsers, actionBuilder) with GreeterService {

and

/AbstractRouter.scala:31:59: type mismatch;
[error]  found   : akka.actor.ActorSystem => PartialFunction[Throwable,io.grpc.Status]
[error]  required: akka.actor.ActorSystem => PartialFunction[Throwable,akka.grpc.Trailers]
[error]       val handler = GreeterServiceHandler(this, serviceName, eHandler)(mat, system)

Solution I was able to modify the twirl template to eliminate the compilation errors and was able to use it to serve grpc via play's EssentialActions. The injected Actions and filters are working with this RouterUsingActions.

I've added a pull request that fixes this issue on top of play-grpc version 0.8.2. Apparently fixing this on latest master will take some more effort. It appears to have another issue apart from this one. I am looking into it and will open another pull request against master if I am successful.

raboof commented 4 years ago

Thanks for testing and fixing this!

Would it be useful to you to do another 0.8.x release with these changes or would it be enough to just do a 0.9.x one from master?

drZoid commented 4 years ago

@raboof - Thank you! Another 0.8.x release is what I need to get unblocked at the moment.

raboof commented 4 years ago

0.8.3 should be on its way to maven central now!