mirror of
https://github.com/go-gitea/gitea.git
synced 2025-08-22 08:34:05 +09:00
chore(grpc): add health check and grpc v1, alpha version
Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
This commit is contained in:
32
routers/api/bots/grpc.go
Normal file
32
routers/api/bots/grpc.go
Normal file
@ -0,0 +1,32 @@
|
||||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package bots
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
"gitea.com/gitea/proto-go/ping/v1/pingv1connect"
|
||||
|
||||
"github.com/bufbuild/connect-go"
|
||||
grpcreflect "github.com/bufbuild/connect-grpcreflect-go"
|
||||
)
|
||||
|
||||
func grpcServiceRoute(r *web.Route) {
|
||||
compress1KB := connect.WithCompressMinBytes(1024)
|
||||
|
||||
// grpcV1
|
||||
grpcPath, gHandler := grpcreflect.NewHandlerV1(
|
||||
grpcreflect.NewStaticReflector(pingv1connect.PingServiceName),
|
||||
compress1KB,
|
||||
)
|
||||
|
||||
// grpcV1Alpha
|
||||
grpcAlphaPath, gAlphaHandler := grpcreflect.NewHandlerV1Alpha(
|
||||
grpcreflect.NewStaticReflector(pingv1connect.PingServiceName),
|
||||
compress1KB,
|
||||
)
|
||||
|
||||
r.Post(grpcPath+"{name}", grpcHandler(gHandler))
|
||||
r.Post(grpcAlphaPath+"{name}", grpcHandler(gAlphaHandler))
|
||||
}
|
Reference in New Issue
Block a user