mirror of
https://github.com/outbackdingo/kubernetes.git
synced 2026-01-27 10:19:35 +00:00
HealthChecker has a List method
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
This commit is contained in:
@@ -44,6 +44,16 @@ func TestNew(t *testing.T) {
|
||||
type successServerMock struct {
|
||||
}
|
||||
|
||||
func (s successServerMock) List(ctx context.Context, request *grpchealth.HealthListRequest) (*grpchealth.HealthListResponse, error) {
|
||||
return &grpchealth.HealthListResponse{
|
||||
Statuses: map[string]*grpchealth.HealthCheckResponse{
|
||||
"grpc": {
|
||||
Status: grpchealth.HealthCheckResponse_SERVING,
|
||||
},
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s successServerMock) Check(context.Context, *grpchealth.HealthCheckRequest) (*grpchealth.HealthCheckResponse, error) {
|
||||
return &grpchealth.HealthCheckResponse{
|
||||
Status: grpchealth.HealthCheckResponse_SERVING,
|
||||
@@ -59,6 +69,16 @@ func (s successServerMock) Watch(_ *grpchealth.HealthCheckRequest, stream grpche
|
||||
type errorTimeoutServerMock struct {
|
||||
}
|
||||
|
||||
func (e errorTimeoutServerMock) List(ctx context.Context, request *grpchealth.HealthListRequest) (*grpchealth.HealthListResponse, error) {
|
||||
return &grpchealth.HealthListResponse{
|
||||
Statuses: map[string]*grpchealth.HealthCheckResponse{
|
||||
"grpc": {
|
||||
Status: grpchealth.HealthCheckResponse_SERVING,
|
||||
},
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (e errorTimeoutServerMock) Check(context.Context, *grpchealth.HealthCheckRequest) (*grpchealth.HealthCheckResponse, error) {
|
||||
time.Sleep(time.Second * 4)
|
||||
return &grpchealth.HealthCheckResponse{
|
||||
@@ -76,6 +96,16 @@ func (e errorTimeoutServerMock) Watch(_ *grpchealth.HealthCheckRequest, stream g
|
||||
type errorNotServeServerMock struct {
|
||||
}
|
||||
|
||||
func (e errorNotServeServerMock) List(ctx context.Context, request *grpchealth.HealthListRequest) (*grpchealth.HealthListResponse, error) {
|
||||
return &grpchealth.HealthListResponse{
|
||||
Statuses: map[string]*grpchealth.HealthCheckResponse{
|
||||
"grpc": {
|
||||
Status: grpchealth.HealthCheckResponse_NOT_SERVING,
|
||||
},
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (e errorNotServeServerMock) Check(context.Context, *grpchealth.HealthCheckRequest) (*grpchealth.HealthCheckResponse, error) {
|
||||
return &grpchealth.HealthCheckResponse{
|
||||
Status: grpchealth.HealthCheckResponse_NOT_SERVING,
|
||||
|
||||
@@ -70,6 +70,10 @@ type HealthChecker struct {
|
||||
started time.Time
|
||||
}
|
||||
|
||||
func (s *HealthChecker) List(ctx context.Context, request *grpc_health_v1.HealthListRequest) (*grpc_health_v1.HealthListResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "unimplemented")
|
||||
}
|
||||
|
||||
func (s *HealthChecker) Check(ctx context.Context, req *grpc_health_v1.HealthCheckRequest) (*grpc_health_v1.HealthCheckResponse, error) {
|
||||
log.Printf("Serving the Check request for health check, started at %v", s.started)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user