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:9d539dca-0a40-1872-8b46-a1ae58633f8e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E632:243A4F:533AC8:7436A2:697B4766 |
| html-safe-nonce | 307a3617d6418547f6148e9d8972d3b8118482fed512f752e141ef4b886e9135 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNjMyOjI0M0E0Rjo1MzNBQzg6NzQzNkEyOjY5N0I0NzY2IiwidmlzaXRvcl9pZCI6IjY4NzU1MDU4MDY2NjYzMTk3MTgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 7a5d9845a1e245d1f862b77f47841dad92af071c03a8316da0146327e42e53f8 |
| 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 | 6fe64d94889230be19a900846cfc91707e7dd4206878d6c208922b46a6b0735d |
| 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 | 35925b5d54d957e7d3b7f55916450a693827ca42 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width