tapir icon indicating copy to clipboard operation
tapir copied to clipboard

Add support for gRPC endpoints

Open mbore opened this issue 3 years ago • 1 comments

In the scope of this PR, I'm going to

  • add support for generating a proto file from tapir endpoint definitions ~* add support for generating Akka services from the proto file.~ out of the scope for the tapir integration, but I'm going to provide an example of how it can be implemented
  • integration for the pbdirect library

~With these changes building a new gRPC endpoint with tapir will involve:~ ~* defining a new tapir endpoint (with all data classes)~ ~* running an SBT command to generate a proto file and based on it generate Scala classes for the new service~ ~* implementing the new service methods~ Defining a new gRPC endpoint can be done the same way we define http endpoints (with json body).

For building proto definition this library might be useful -> https://github.com/RafalSumislawski/scala-first-protobuf For generating scala classes I think I'm going to use ScalaPB

TODO

  • [ ] generate proto from code (PoC done, we need to extend the implementation) ~- [ ] generate services from proto~ (out of the scope) ~- [ ] link these steps in a single SBT command~ (not relevant anymore)
  • [ ] add support for data frames (HTTP/2)
  • [ ] expose or store generated proto file
  • [ ] make tapir endpoint definition API more gRPC friendly
  • [ ] add examples
  • [ ] update documentation

mbore avatar Aug 01 '22 11:08 mbore

How to deal with HTTP methods defined for tapir's endpoint? I'm going to ignore them for now, but later on, we may want to use them to add a prefix to the method name or disable them somehow for grpc endpoints.

mbore avatar Aug 02 '22 09:08 mbore