mirror of
https://github.com/go-gitea/gitea.git
synced 2025-08-24 01:24:08 +09:00
chore(proto): Add ping service
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
@ -6,47 +6,13 @@ package bots
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
"gitea.com/gitea/proto/gen/proto/v1/v1connect"
|
||||
|
||||
"github.com/bufbuild/connect-go"
|
||||
grpchealth "github.com/bufbuild/connect-grpchealth-go"
|
||||
grpcreflect "github.com/bufbuild/connect-grpcreflect-go"
|
||||
)
|
||||
|
||||
func Routes(r *web.Route) {
|
||||
compress1KB := connect.WithCompressMinBytes(1024)
|
||||
|
||||
service := &RunnerService{}
|
||||
path, handler := v1connect.NewBuildServiceHandler(
|
||||
service,
|
||||
compress1KB,
|
||||
)
|
||||
|
||||
// grpcV1
|
||||
grpcPath, gHandler := grpcreflect.NewHandlerV1(
|
||||
grpcreflect.NewStaticReflector(v1connect.BuildServiceName),
|
||||
compress1KB,
|
||||
)
|
||||
|
||||
// grpcV1Alpha
|
||||
grpcAlphaPath, gAlphaHandler := grpcreflect.NewHandlerV1Alpha(
|
||||
grpcreflect.NewStaticReflector(v1connect.BuildServiceName),
|
||||
compress1KB,
|
||||
)
|
||||
|
||||
// grpcHealthCheck
|
||||
grpcHealthPath, gHealthHandler := grpchealth.NewHandler(
|
||||
grpchealth.NewStaticChecker(v1connect.BuildServiceName),
|
||||
compress1KB,
|
||||
)
|
||||
|
||||
// socket connection
|
||||
r.Get("/socket", socketServe)
|
||||
// restful connection
|
||||
r.Post(path+"{name}", giteaHandler(handler))
|
||||
// grpc connection
|
||||
r.Post(grpcPath+"{name}", giteaHandler(gHandler))
|
||||
r.Post(grpcAlphaPath+"{name}", giteaHandler(gAlphaHandler))
|
||||
// healthy check connection
|
||||
r.Post(grpcHealthPath+"{name}", giteaHandler(gHealthHandler))
|
||||
// runner service
|
||||
runnerServiceRoute(r)
|
||||
// ping service
|
||||
pingServiceRoute(r)
|
||||
}
|
||||
|
Reference in New Issue
Block a user