fix indent
This commit is contained in:
@ -9,7 +9,7 @@ message HealthCheckRequest {
|
|||||||
|
|
||||||
message HealthCheckResponse {
|
message HealthCheckResponse {
|
||||||
enum ServingStatus {
|
enum ServingStatus {
|
||||||
UNKNOWN = 0;
|
UNKNOWN = 0;
|
||||||
SERVING = 1;
|
SERVING = 1;
|
||||||
NOT_SERVING = 2;
|
NOT_SERVING = 2;
|
||||||
}
|
}
|
||||||
|
@ -12,9 +12,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type HealthServer struct {
|
type HealthServer struct {
|
||||||
// statusMap stores the serving status of the services this HealthServer monitors
|
mu sync.Mutex
|
||||||
|
// statusMap stores the serving status of the services this HealthServer monitors.
|
||||||
statusMap map[string]int32
|
statusMap map[string]int32
|
||||||
mu sync.Mutex
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewHealthServer() *HealthServer {
|
func NewHealthServer() *HealthServer {
|
||||||
@ -23,9 +23,8 @@ func NewHealthServer() *HealthServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *HealthServer) Check(ctx context.Context, in *healthpb.HealthCheckRequest) (out *healthpb.HealthCheckResponse, err error) {
|
func (s *HealthServer) Check(ctx context.Context, in *healthpb.HealthCheckRequest) (*healthpb.HealthCheckResponse, error) {
|
||||||
service := in.Host + ":" + in.Service
|
service := in.Host + ":" + in.Service
|
||||||
out = new(healthpb.HealthCheckResponse)
|
|
||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
defer s.mu.Unlock()
|
defer s.mu.Unlock()
|
||||||
if status, ok := s.statusMap[service]; ok {
|
if status, ok := s.statusMap[service]; ok {
|
||||||
@ -37,7 +36,7 @@ func (s *HealthServer) Check(ctx context.Context, in *healthpb.HealthCheckReques
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetServingStatus is called when need to reset the serving status of a service
|
// SetServingStatus is called when need to reset the serving status of a service
|
||||||
// or insert a new service entry into the statusMap
|
// or insert a new service entry into the statusMap.
|
||||||
func (s *HealthServer) SetServingStatus(host string, service string, status int32) {
|
func (s *HealthServer) SetServingStatus(host string, service string, status int32) {
|
||||||
service = host + ":" + service
|
service = host + ":" + service
|
||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
|
Reference in New Issue
Block a user