akka / akka-grpc

Akka gRPC
https://doc.akka.io/docs/akka-grpc/
Other
431 stars 123 forks source link

Add gRPC reflection support #380

Closed ds-kibalchish closed 4 years ago

ds-kibalchish commented 6 years ago

Can't figure out how easily enable gRPC reflection in akka-grpc. Please provide documentation if it's possible to do now or add this feature.

@see https://github.com/grpc/grpc-java/blob/master/documentation/server-reflection-tutorial.md

johanandren commented 6 years ago

There is nothing like that in Akka-gRPC right now/yet.

jasoncarreira commented 5 years ago

+1 for adding

viktorklang commented 5 years ago

Feel free to adapt and PR this into akka-grpc: https://github.com/cloudstateio/cloudstate/blob/master/proxy/core/src/main/scala/io/cloudstate/proxy/Reflection.scala

On Fri, 26 Jul 2019 at 21:03, Jason Carreira notifications@github.com wrote:

+1 for adding

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/akka/akka-grpc/issues/380?email_source=notifications&email_token=AAACU56WG5SEZRXJIMQSNDTQBNDAJA5CNFSM4FS2T4HKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD25OO4Y#issuecomment-515565427, or mute the thread https://github.com/notifications/unsubscribe-auth/AAACU57YMOOSJQ5PWMJHRULQBNDAJANCNFSM4FS2T4HA .

-- Cheers, √

jasoncarreira commented 5 years ago

I think the Reflection class could be bundled with Akka-grpc and any projects using Akka-grpc could include it as a PartialFunction to enable it, but I'm not sure how to do the code gen as part of the SBT build to build out the classes generated from reflection.proto. Any tips?

raboof commented 5 years ago

I think the Reflection class could be bundled with Akka-grpc

Sounds good!

I'm not sure how to do the code gen as part of the SBT build to build out the classes generated from reflection.proto. Any tips?

That's a good question. I suppose we could use the Akka gRPC plugin in the Akka gRPC project, but that might make changes to the runtime library harder to make. I wonder if it would make sense to use the ReflectiveCodeGen for this, which so far we have only been using for integration tests. This would need some more experimentation.

jasoncarreira commented 5 years ago

Any help would be appreciated. The sbt build for akka-grpc is significantly more complicated than I'm used to.

jasoncarreira commented 5 years ago

Messing with this more, I'm not sure the Reflection class can be easily unbound from cloudstate. I'm at a bit of a loss for how to implement this.

viktorklang commented 5 years ago

@jasoncarreira The Reflection class does not depend on CloudState at all, afaik?

jasoncarreira commented 5 years ago

@viktorklang Ah... Just one in Names.splitNext, but I just copied that function over. I was confused by the references to other proto generated classes outside of the reflection.proto. Still not sure how to get it to generate classes as part of the build of Akka-grpc. It's ugly, but we could check them in and change them if the proto changes? Hacking the build to make it work might be just as ugly.

Anyway, I copied it over to see how it would work in the Akka-grpc helloworld example, and it's a bit clunky:

` val service = GreeterServiceHandler.partial(new GreeterServiceImpl(mat, system.log))

val reflection = Reflection.serve(
  Seq(HelloworldProto.javaDescriptor, ReflectionProto.javaDescriptor),
  Seq(GreeterService.name, ServerReflection.name))

val bound = Http2().bindAndHandleAsync(
  ServiceHandler.concatOrNotFound(service, reflection),
  interface = "0.0.0.0",
  port = 8080,
  HttpConnectionContext(http2 = Always)
)`

Kinda think it might be better to have the framework do this stuff in the generated code based on a flag, but I haven't dug into the code gen stuff of Akka-grpc to know if that would work.

viktorklang commented 5 years ago

@jasoncarreira It might be worth adding it as a permutation to the generation of GreeterServiceHandler.partial so you can get a route which optionally already includes reflection support.

jasoncarreira commented 5 years ago

I'm a little lost in the code generation code in Akka-grpc. You'd also only want one Reflection object for all of the services if it's generating multiple.

viktorklang commented 5 years ago

@jasoncarreira True, perhaps it is indeed better to have to construct it manually by passing in a set of GeneratedFileObject that you want to have exposed via Reflection.

jasoncarreira commented 5 years ago

Who would know enough about the code gen in Akka-grpc to help with this?

raboof commented 5 years ago

I did some initial work on this in https://github.com/akka/akka-grpc/pull/654 - this is just the codegen and service implementation (based on the cloudstate one), we'd still need to figure out a nice API to be able to actually add it, both for Java and for Scala.

I have to do switch to some other tasks now, feel free to continue on that PR!

jasoncarreira commented 5 years ago

Here's the project I've got where I got gRPC reflection and Swagger for REST working:

https://github.com/jasoncarreira/akka-grpc-sample-kubernetes-scala

ennru commented 4 years ago

Implemented with #654

Fur further discussions see #850