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-11-25 17:48:44 +08:00
committed by Jason Song
parent 257ba77e8d
commit 2cba8fafd8
6 changed files with 65 additions and 46 deletions
+29
View File
@@ -0,0 +1,29 @@
// 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"
"gitea.com/gitea/proto-go/runner/v1/runnerv1connect"
"github.com/bufbuild/connect-go"
grpchealth "github.com/bufbuild/connect-grpchealth-go"
)
func healthServiceRoute(r *web.Route) {
compress1KB := connect.WithCompressMinBytes(1024)
// grpcHealthCheck
grpcHealthPath, gHealthHandler := grpchealth.NewHandler(
grpchealth.NewStaticChecker(
runnerv1connect.RunnerServiceName,
pingv1connect.PingServiceName,
),
compress1KB,
)
r.Post(grpcHealthPath+"{name}", grpcHandler(gHealthHandler))
}