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:
Bo-Yi.Wu
2022-08-20 11:53:19 +08:00
committed by Jason Song
parent 257ba77e8d
commit 2cba8fafd8
6 changed files with 65 additions and 46 deletions

View File

@ -13,8 +13,6 @@ import (
"gitea.com/gitea/proto-go/runner/v1/runnerv1connect"
"github.com/bufbuild/connect-go"
grpchealth "github.com/bufbuild/connect-grpchealth-go"
grpcreflect "github.com/bufbuild/connect-grpcreflect-go"
)
type RunnerService struct{}
@ -55,26 +53,5 @@ func runnerServiceRoute(r *web.Route) {
compress1KB,
)
// grpcV1
grpcPath, gHandler := grpcreflect.NewHandlerV1(
grpcreflect.NewStaticReflector(runnerv1connect.RunnerServiceName),
compress1KB,
)
// grpcV1Alpha
grpcAlphaPath, gAlphaHandler := grpcreflect.NewHandlerV1Alpha(
grpcreflect.NewStaticReflector(runnerv1connect.RunnerServiceName),
compress1KB,
)
// grpcHealthCheck
grpcHealthPath, gHealthHandler := grpchealth.NewHandler(
grpchealth.NewStaticChecker(runnerv1connect.RunnerServiceName),
compress1KB,
)
r.Post(connectPath+"{name}", grpcHandler(connecthandler))
r.Post(grpcPath+"{name}", grpcHandler(gHandler))
r.Post(grpcAlphaPath+"{name}", grpcHandler(gAlphaHandler))
r.Post(grpcHealthPath+"{name}", grpcHandler(gHealthHandler))
}