chore(proto): update import path

Signed-off-by: GiteaBot <teabot@gitea.io>
This commit is contained in:
GiteaBot
2022-08-17 15:01:10 +08:00
committed by Jason Song
parent b84aa84a0f
commit 257ba77e8d
4 changed files with 627 additions and 30 deletions

View File

@ -7,11 +7,11 @@ package bots
import (
"context"
"fmt"
"log"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/web"
v1 "gitea.com/gitea/proto/gen/proto/v1"
"gitea.com/gitea/proto/gen/proto/v1/v1connect"
pingv1 "gitea.com/gitea/proto-go/ping/v1"
"gitea.com/gitea/proto-go/ping/v1/pingv1connect"
"github.com/bufbuild/connect-go"
grpchealth "github.com/bufbuild/connect-grpchealth-go"
@ -22,11 +22,12 @@ type PingService struct{}
func (s *PingService) Ping(
ctx context.Context,
req *connect.Request[v1.PingRequest],
) (*connect.Response[v1.PingResponse], error) {
log.Println("Content-Type: ", req.Header().Get("Content-Type"))
log.Println("User-Agent: ", req.Header().Get("User-Agent"))
res := connect.NewResponse(&v1.PingResponse{
req *connect.Request[pingv1.PingRequest],
) (*connect.Response[pingv1.PingResponse], error) {
log.Info("Content-Type: %s", req.Header().Get("Content-Type"))
log.Info("User-Agent: %s", req.Header().Get("User-Agent"))
log.Info("X-Gitea-Token: %s", req.Header().Get("X-Gitea-Token"))
res := connect.NewResponse(&pingv1.PingResponse{
Data: fmt.Sprintf("Hello, %s!", req.Msg.Data),
})
res.Header().Set("Gitea-Version", "v1")
@ -37,26 +38,26 @@ func pingServiceRoute(r *web.Route) {
compress1KB := connect.WithCompressMinBytes(1024)
pingService := &PingService{}
connectPath, connecthandler := v1connect.NewPingServiceHandler(
connectPath, connecthandler := pingv1connect.NewPingServiceHandler(
pingService,
compress1KB,
)
// grpcV1
grpcPath, gHandler := grpcreflect.NewHandlerV1(
grpcreflect.NewStaticReflector(v1connect.PingServiceName),
grpcreflect.NewStaticReflector(pingv1connect.PingServiceName),
compress1KB,
)
// grpcV1Alpha
grpcAlphaPath, gAlphaHandler := grpcreflect.NewHandlerV1Alpha(
grpcreflect.NewStaticReflector(v1connect.PingServiceName),
grpcreflect.NewStaticReflector(pingv1connect.PingServiceName),
compress1KB,
)
// grpcHealthCheck
grpcHealthPath, gHealthHandler := grpchealth.NewHandler(
grpchealth.NewStaticChecker(v1connect.PingServiceName),
grpchealth.NewStaticChecker(pingv1connect.PingServiceName),
compress1KB,
)