gRPC-haskell icon indicating copy to clipboard operation
gRPC-haskell copied to clipboard

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

Open tim2CF opened this issue 4 years ago • 2 comments
trafficstars

Is it possible? Any examples?

tim2CF avatar Mar 29 '21 09:03 tim2CF

@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.

Gabriella439 avatar Mar 29 '21 17:03 Gabriella439

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

tim2CF avatar Mar 30 '21 07:03 tim2CF