awakesecurity / gRPC-haskell

Haskell gRPC support
https://hackage.haskell.org/package/grpc-haskell
Apache License 2.0
238 stars 75 forks source link

Running multiple different gRPC services on the same port/endpoint? #120

Open tim2CF opened 3 years ago

tim2CF commented 3 years ago

Is it possible? Any examples?

Gabriella439 commented 3 years ago

@tim2CF: It is possible, albeit very awkward using the current API. The way you could do it in theory is to essentially implement something similar to the code that is generated by compile-proto-file for running a server.

Specifically, when you create a service named Foo, then compile-proto-file will generate a fooServer :: Foo ServerRequest ServerResponse -> ServiceOptions -> IO () that unpacks the service methods and repacks them into the server handlers to run a server on a single port. You could similar unpack the methods of multiple services and pack them into the handlers for a server in the same way as the generated code, but it would not be very ergonomic.

tim2CF commented 3 years ago

Thanks for reply, @Gabriel439 It's not critical issue at the moment, but in the future it will be very handy