api/internal/rpc/health_server.go
Peter Kurfer 49e58ac2e4 Add advanced matching options to HTTP handler
- move to Gitlab
- make code better testable
- create app abstraction for server
- cleanup
2020-12-26 13:11:49 +00:00

30 lines
645 B
Go

package rpc
import (
"context"
app2 "gitlab.com/inetmock/inetmock/internal/app"
)
type healthServer struct {
UnimplementedHealthServer
app app2.App
}
func (h healthServer) GetHealth(_ context.Context, _ *HealthRequest) (resp *HealthResponse, err error) {
checker := h.app.Checker()
result := checker.IsHealthy()
resp = &HealthResponse{
OverallHealthState: HealthState(result.Status),
ComponentsHealth: map[string]*ComponentHealth{}}
for component, status := range result.Components {
resp.ComponentsHealth[component] = &ComponentHealth{
State: HealthState(status.Status),
Message: status.Message,
}
}
return
}