Add grpc health check service
Fixes: #615 Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
This commit is contained in:
parent
a160a6a068
commit
e663cbddf5
6 changed files with 281 additions and 0 deletions
31
services/healthcheck/service.go
Normal file
31
services/healthcheck/service.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
package healthcheck
|
||||
|
||||
import (
|
||||
"github.com/docker/containerd/plugin"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/health"
|
||||
"google.golang.org/grpc/health/grpc_health_v1"
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
serve *health.Server
|
||||
}
|
||||
|
||||
func init() {
|
||||
plugin.Register("healthcheck-grpc", &plugin.Registration{
|
||||
Type: plugin.GRPCPlugin,
|
||||
Init: NewService,
|
||||
})
|
||||
}
|
||||
|
||||
func NewService(ic *plugin.InitContext) (interface{}, error) {
|
||||
return &Service{
|
||||
health.NewServer(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *Service) Register(server *grpc.Server) error {
|
||||
grpc_health_v1.RegisterHealthServer(server, s.serve)
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue