Title: [Discuss] Use gRPC gateway to generate REST endpoints · Issue #20 · feast-dev/feast-java-old · GitHub
Open Graph Title: [Discuss] Use gRPC gateway to generate REST endpoints · Issue #20 · feast-dev/feast-java-old
X Title: [Discuss] Use gRPC gateway to generate REST endpoints · Issue #20 · feast-dev/feast-java-old
Description: Introduction Right now, feast-java uses RestController (example code) to implement REST endpoints for both feast-core and feast-serving. However, this approach will increase maintenance cost. Therefore, generating REST endpoint from prot...
Open Graph Description: Introduction Right now, feast-java uses RestController (example code) to implement REST endpoints for both feast-core and feast-serving. However, this approach will increase maintenance cost. There...
X Description: Introduction Right now, feast-java uses RestController (example code) to implement REST endpoints for both feast-core and feast-serving. However, this approach will increase maintenance cost. There...
Opengraph URL: https://github.com/feast-dev/feast-java-old/issues/20
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Discuss] Use gRPC gateway to generate REST endpoints","articleBody":"## Introduction\r\n\r\nRight now, feast-java uses `RestController` ([example code](https://github.com/feast-dev/feast-java/blob/8541f36ecf28569db7ece35e936b5e9d83db3cde/serving/src/main/java/feast/serving/controller/ServingServiceRestController.java)) to implement REST endpoints for both feast-core and feast-serving. However, this approach will increase maintenance cost. Therefore, generating REST endpoint from proto definitions is a cleaner way.\r\n\r\n## Proposed Change\r\n\r\nUse [grpc-gateway](https://github.com/grpc-ecosystem/grpc-gateway) to generate the REST endpoint. \r\n\r\n### Steps\r\n#### 1. Add gateway server to translate REST call into gRPC call to another process inside the container\r\nThe example gateway server will look like:\r\n\r\n```\r\npackage main\r\n\r\nimport (\r\n\t\"context\"\r\n\t\"flag\"\r\n\t\"fmt\"\r\n\t\"net/http\"\r\n\r\n\t\"github.com/golang/glog\"\r\n\t\"github.com/grpc-ecosystem/grpc-gateway/v2/runtime\"\r\n\t\"google.golang.org/grpc\"\r\n\r\n\tcoreGateWay \"pkg/gateway/generated/feast/core\"\r\n\tservingGateWay \"pkg/gateway/generated/feast/serving\"\r\n)\r\n\r\n// gRPC serving endpoint\r\nvar servingServerEndpoint = flag.String(\"serving-server-endpoint\", \"localhost:6566\", \"gRPC server endpoint\")\r\n\r\nfunc run() error {\r\n\tctx := context.Background()\r\n\tctx, cancel := context.WithCancel(ctx)\r\n\tdefer cancel()\r\n\r\n\tmux := runtime.NewServeMux()\r\n\topts := []grpc.DialOption{grpc.WithInsecure()}\r\n\r\n\t// Register ServingServing endpoint\r\n\terr = servingGateWay.RegisterServingServiceHandlerFromEndpoint(ctx, mux, *servingServerEndpoint, opts)\r\n\tif err != nil {\r\n\t\treturn err\r\n\t}\r\n\r\n\t// Start HTTP server (and proxy calls to gRPC server endpoint)\r\n\treturn http.ListenAndServe(\":8000\", mux)\r\n}\r\n\r\nfunc main() {\r\n\tflag.Parse()\r\n\tdefer glog.Flush()\r\n\r\n\tif err := run(); err != nil {\r\n\t\tfmt.Println(err)\r\n\t\tglog.Fatal(err)\r\n\t}\r\n}\r\n```\r\n\r\n#### 2. Use [supervisord](http://supervisord.org/) to start two processes inside a container\r\n\r\nWe can provide instructions to use different entry points. Here's an example config:\r\n\r\n```\r\n[supervisord]\r\nnodaemon=true\r\n\r\n[program:serving]\r\ndirectory=/\r\nuser=root\r\ncommand=java -jar /opt/feast/feast-serving.jar --spring.config.location=classpath:/application.yml,file:/etc/feast/%(ENV_FEAST_SERVING_YML_NAME)s \r\n\r\n[program:gateway]\r\ndirectory=/\r\nuser=root\r\ncommand=/opt/feast/gateway_server \r\n --serving-server-endpoint=%(ENV_FEAST_SERVING_URL)s\r\nnumprocs=1\r\n```\r\n\r\n#### 3. Remove existing REST controllers' code\r\n\r\nAs titled.","author":{"url":"https://github.com/randxie","@type":"Person","name":"randxie"},"datePublished":"2021-04-04T17:51:44.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/20/feast-java-old/issues/20"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d860007f-86c9-66cc-0b8d-6001f5718283 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E3E8:371948:2B7E9BA:3A42B3B:697AD8CC |
| html-safe-nonce | e54aab87b83de9f249126c762021b63a0164e3679e15b77f9d7a7aad1e9faa03 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFM0U4OjM3MTk0ODoyQjdFOUJBOjNBNDJCM0I6Njk3QUQ4Q0MiLCJ2aXNpdG9yX2lkIjoiMTg0NTgwMzg4NDE3ODIzMzU0OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 5e0c3b6a29bcd45acdf6edef0e19902660bad099306a5f68d62731b15945638a |
| hovercard-subject-tag | issue:849926156 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/feast-dev/feast-java-old/20/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4606c61f0e9c0efa70f0fdc18529cd4657fe65f8a42ce713176cb61ab7ddd4a5/feast-dev/feast-java-old/issues/20 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4606c61f0e9c0efa70f0fdc18529cd4657fe65f8a42ce713176cb61ab7ddd4a5/feast-dev/feast-java-old/issues/20 |
| og:image:alt | Introduction Right now, feast-java uses RestController (example code) to implement REST endpoints for both feast-core and feast-serving. However, this approach will increase maintenance cost. There... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | randxie |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4af1ba0e68200258a80b0c5ab34f12a78bf48372a377a11e14eb668863c03b3a |
| turbo-cache-control | no-preview |
| go-import | github.com/feast-dev/feast-java-old git https://github.com/feast-dev/feast-java-old.git |
| octolytics-dimension-user_id | 57027613 |
| octolytics-dimension-user_login | feast-dev |
| octolytics-dimension-repository_id | 333248009 |
| octolytics-dimension-repository_nwo | feast-dev/feast-java-old |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 333248009 |
| octolytics-dimension-repository_network_root_nwo | feast-dev/feast-java-old |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 353b231ffaec2de44db15b2e82887804ede7c21e |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width