Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Serve gRPC and REST requests on the same external port #489

Merged
merged 3 commits into from
Oct 22, 2020

Conversation

vchudnov-g
Copy link
Contributor

@vchudnov-g vchudnov-g commented Oct 22, 2020

This PR uses the cmux package to expose a single external port that selects incoming connections to route to the gRPC endpoint or the REST endpoint.
(ref: https://medium.com/@drgarcia1986/listen-grpc-and-http-requests-on-the-same-port-263c40cb45ff and https://github.com/soheilhy/cmux)

I define an Endpoint interface wrapping both the gRPC and the REST endpoints, as well as the cmux multiplexer that does the redirection. This infrastructure will also allow future endpoints to be easily added when we need them.

This also sets up the infrastructure for graceful shutdown upon receipt of a signal, though we are waiting for a PR in the cmux dependency for that to work fully. (The issue is described in soheilhy/cmux#69 (comment).)

Implementation/review notes:

  • the gRPC server set-up code is now in cmd/gapic-showcase/endpoint.go. It is split between setting up the server and running it.
  • the REST server (also in endpoint.go) is currently a stub that simply responds to /hello requests. It will be expanded with auto-generated handlers.

This is in preparation for creating httpServe
This creates an Endpoint interface wrapping both the gRPC and the
REST endpoints, as well as the cmux multiplexer that redirects from
the external port to either of those.

This also sets up the infrastructure for graceful shutdown upon
receipt of a signal, though we are waiting for a PR in a dependency
for that to work fully.
@vchudnov-g vchudnov-g added the automerge Summon MOG for automerging label Oct 22, 2020
@vchudnov-g vchudnov-g requested a review from a team as a code owner October 22, 2020 21:20
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Oct 22, 2020
@codecov
Copy link

codecov bot commented Oct 22, 2020

Codecov Report

Merging #489 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #489   +/-   ##
=======================================
  Coverage   97.81%   97.81%           
=======================================
  Files          14       14           
  Lines        1007     1007           
=======================================
  Hits          985      985           
  Misses         15       15           
  Partials        7        7           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4b94fba...ebc7634. Read the comment docs.

@gcf-merge-on-green gcf-merge-on-green bot merged commit d2ce150 into googleapis:master Oct 22, 2020
@gcf-merge-on-green gcf-merge-on-green bot removed the automerge Summon MOG for automerging label Oct 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants