*: golint
This commit is contained in:
@ -6,6 +6,7 @@ go:
|
||||
|
||||
before_install:
|
||||
- go get golang.org/x/tools/cmd/goimports
|
||||
- go get github.com/golang/lint/golint
|
||||
- go get github.com/axw/gocov/gocov
|
||||
- go get github.com/mattn/goveralls
|
||||
- go get golang.org/x/tools/cmd/cover
|
||||
@ -17,4 +18,5 @@ install:
|
||||
script:
|
||||
- '! gofmt -s -d -l . 2>&1 | read'
|
||||
- '! goimports -l . | read'
|
||||
- '! golint ./... | grep -vE "(_string|\.pb)\.go:"'
|
||||
- make test testrace
|
||||
|
@ -11,19 +11,22 @@ import (
|
||||
healthpb "google.golang.org/grpc/health/grpc_health_v1"
|
||||
)
|
||||
|
||||
type HealthServer struct {
|
||||
// Server implements `service Health`.
|
||||
type Server struct {
|
||||
mu sync.Mutex
|
||||
// statusMap stores the serving status of the services this HealthServer monitors.
|
||||
// statusMap stores the serving status of the services this Server monitors.
|
||||
statusMap map[string]healthpb.HealthCheckResponse_ServingStatus
|
||||
}
|
||||
|
||||
func NewHealthServer() *HealthServer {
|
||||
return &HealthServer{
|
||||
// NewServer returns a new Server.
|
||||
func NewServer() *Server {
|
||||
return &Server{
|
||||
statusMap: make(map[string]healthpb.HealthCheckResponse_ServingStatus),
|
||||
}
|
||||
}
|
||||
|
||||
func (s *HealthServer) Check(ctx context.Context, in *healthpb.HealthCheckRequest) (*healthpb.HealthCheckResponse, error) {
|
||||
// Check implements `service Health`.
|
||||
func (s *Server) Check(ctx context.Context, in *healthpb.HealthCheckRequest) (*healthpb.HealthCheckResponse, error) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
if in.Service == "" {
|
||||
@ -42,7 +45,7 @@ func (s *HealthServer) Check(ctx context.Context, in *healthpb.HealthCheckReques
|
||||
|
||||
// SetServingStatus is called when need to reset the serving status of a service
|
||||
// or insert a new service entry into the statusMap.
|
||||
func (s *HealthServer) SetServingStatus(service string, status healthpb.HealthCheckResponse_ServingStatus) {
|
||||
func (s *Server) SetServingStatus(service string, status healthpb.HealthCheckResponse_ServingStatus) {
|
||||
s.mu.Lock()
|
||||
s.statusMap[service] = status
|
||||
s.mu.Unlock()
|
||||
|
@ -371,7 +371,7 @@ type test struct {
|
||||
|
||||
// Configurable knobs, after newTest returns:
|
||||
testServer testpb.TestServiceServer // nil means none
|
||||
healthServer *health.HealthServer // nil means disabled
|
||||
healthServer *health.Server // nil means disabled
|
||||
maxStream uint32
|
||||
userAgent string
|
||||
clientCompression bool
|
||||
@ -748,7 +748,7 @@ func TestHealthCheckOnSuccess(t *testing.T) {
|
||||
|
||||
func testHealthCheckOnSuccess(t *testing.T, e env) {
|
||||
te := newTest(t, e)
|
||||
hs := health.NewHealthServer()
|
||||
hs := health.NewServer()
|
||||
hs.SetServingStatus("grpc.health.v1.Health", 1)
|
||||
te.healthServer = hs
|
||||
te.startServer(&testServer{security: e.security})
|
||||
@ -774,7 +774,7 @@ func testHealthCheckOnFailure(t *testing.T, e env) {
|
||||
"Failed to dial ",
|
||||
"grpc: the client connection is closing; please retry",
|
||||
)
|
||||
hs := health.NewHealthServer()
|
||||
hs := health.NewServer()
|
||||
hs.SetServingStatus("grpc.health.v1.HealthCheck", 1)
|
||||
te.healthServer = hs
|
||||
te.startServer(&testServer{security: e.security})
|
||||
@ -818,7 +818,7 @@ func TestHealthCheckServingStatus(t *testing.T) {
|
||||
|
||||
func testHealthCheckServingStatus(t *testing.T, e env) {
|
||||
te := newTest(t, e)
|
||||
hs := health.NewHealthServer()
|
||||
hs := health.NewServer()
|
||||
te.healthServer = hs
|
||||
te.startServer(&testServer{security: e.security})
|
||||
defer te.tearDown()
|
||||
|
Reference in New Issue
Block a user