2020-10-21 08:18:34 +00:00
|
|
|
package grpc
|
|
|
|
|
2023-05-07 14:47:43 +00:00
|
|
|
import (
|
|
|
|
"path"
|
|
|
|
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
"google.golang.org/grpc/reflection/grpc_reflection_v1alpha"
|
|
|
|
)
|
|
|
|
|
2020-10-21 08:18:34 +00:00
|
|
|
const (
|
|
|
|
Healthz = "/Healthz"
|
|
|
|
Readiness = "/Ready"
|
|
|
|
Validation = "/Validate"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
Probes = []string{Healthz, Readiness, Validation}
|
|
|
|
)
|
2023-05-07 14:47:43 +00:00
|
|
|
|
|
|
|
func init() {
|
|
|
|
Probes = append(Probes, AllPaths(grpc_reflection_v1alpha.ServerReflection_ServiceDesc)...)
|
|
|
|
}
|
|
|
|
|
|
|
|
func AllPaths(sd grpc.ServiceDesc) []string {
|
|
|
|
paths := make([]string, 0, len(sd.Methods)+len(sd.Streams))
|
|
|
|
for _, method := range sd.Methods {
|
|
|
|
paths = append(paths, path.Join("/", sd.ServiceName, method.MethodName))
|
|
|
|
}
|
|
|
|
for _, stream := range sd.Streams {
|
|
|
|
paths = append(paths, path.Join("/", sd.ServiceName, stream.StreamName))
|
|
|
|
}
|
|
|
|
return paths
|
|
|
|
}
|