Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[Discuss] Use gRPC gateway to generate REST endpoints

未关闭
#20 8 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

@woop 已经在做这个了。

开始于 2021年4月4日。

评估

这个 Issue 还没有评估数据。

描述

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 proto definitions is a cleaner way.

Proposed Change

Use grpc-gateway to generate the REST endpoint.

Steps
1. Add gateway server to translate REST call into gRPC call to another process inside the container

The example gateway server will look like:

package main

import (
	"context"
	"flag"
	"fmt"
	"net/http"

	"github.com/golang/glog"
	"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
	"google.golang.org/grpc"

	coreGateWay "pkg/gateway/generated/feast/core"
	servingGateWay "pkg/gateway/generated/feast/serving"
)

// gRPC serving endpoint
var servingServerEndpoint = flag.String("serving-server-endpoint", "localhost:6566", "gRPC server endpoint")

func run() error {
	ctx := context.Background()
	ctx, cancel := context.WithCancel(ctx)
	defer cancel()

	mux := runtime.NewServeMux()
	opts := []grpc.DialOption{grpc.WithInsecure()}

	// Register ServingServing endpoint
	err = servingGateWay.RegisterServingServiceHandlerFromEndpoint(ctx, mux, *servingServerEndpoint, opts)
	if err != nil {
		return err
	}

	// Start HTTP server (and proxy calls to gRPC server endpoint)
	return http.ListenAndServe(":8000", mux)
}

func main() {
	flag.Parse()
	defer glog.Flush()

	if err := run(); err != nil {
		fmt.Println(err)
		glog.Fatal(err)
	}
}
2. Use supervisord to start two processes inside a container

We can provide instructions to use different entry points. Here's an example config:

[supervisord]
nodaemon=true

[program:serving]
directory=/
user=root
command=java -jar /opt/feast/feast-serving.jar --spring.config.location=classpath:/application.yml,file:/etc/feast/%(ENV_FEAST_SERVING_YML_NAME)s 

[program:gateway]
directory=/
user=root
command=/opt/feast/gateway_server 
            --serving-server-endpoint=%(ENV_FEAST_SERVING_URL)s
numprocs=1
3. Remove existing REST controllers' code

As titled.

主要语言
Java
星标
12
派生
26
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

feast-dev/feast-java-old 的其他 Issue

查看 feast-dev/feast-java-old 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。