cjihrig/grpc-server-js

Support for hapi?

burgerboydaddy opened this issue ยท 8 comments

Hello,
this is not an issue in the first place. Just question did you managed to integrate (create) gRPC server using hapi?
I watched your video from Node+JS Interactive, and you mentioned hapi a few times. Any success integrating with it?
Thanks in advance

If I'm remembering that talk correctly, I think I was talking about using hapi as a proxy for gRPC-Web. Is that what you're referring to?

No, I'm interested in is it possible to use gRPC inside hapi?
Right now, I'm even not sure is that a good idea at all.

I'm not sure what the state of the art in hapi is regarding http2 support. Beyond that, gRPC adds its own protocol on top of http2. I think it could be done with some limitations, but I don't know that it would be worth it.

I agree, after reviewing I found it is much better to keep them separated.
Thanks for answers. I will close this ticket (question).

For what it's worth, hapi is a solid framework for writing applications in general, and just because you're not using hapi's HTTP listener doesn't mean you can't write a gRPC application on top of hapi! Consider checking-out nes (websockets), lalalambda (serverless functions), susie (eventstreams), and underdog (http2 with push) for examples of how alternate transports can be supported via hapi. The most relevant in this case are likely nes and lalalambda.

I did know that you could pass in a custom listener, but I had a couple concerns around that:

  • One gRPC server can listen on multiple Node http/2 servers. I'm assuming we'd have to limit it to one http/2 server to integrate with hapi.
  • What would the routing to gRPC handlers look like? Currently, this is the extent of the router required for gRPC itself.
  • Would using a gRPC http/2 server impact routing for other plugins at all? If I were going to integrate gRPC with hapi, I'd only want to do so if I could use gRPC within a larger application. Otherwise, why not just use gRPC directly on its own.
  • Kind of a meta-issue, but worth calling out: a hapi plugin would need to exist in a separate repo from this one.

I'm willing to work with anyone that interested in making this happen.

I was actually meaning/trying to advocate for not using hapi's listener, and instead creating your own special gRPC listener then tying it to the hapi server's lifecycle. That would mean not using hapi routes, instead creating some new server decoration for registering handlers. I am not familiar enough with gRPC to know if all those routing concepts have natural analogs to gRPC.

just because you're not using hapi's HTTP listener

Sorry, I totally misinterpreted that as "you're not using hapi's HTTP listener because you're providing your own" ๐Ÿ˜Š