bug: grpc client code has checker specific logic #48

Closed
opened 2026-03-28 04:20:45 +00:00 by mfreeman451 · 0 comments
Owner

Imported from GitHub.

Original GitHub issue: #90
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/issues/90
Original created: 2025-01-21T17:43:22Z


// CheckHealth checks the health of a specific service.
func (c *ClientConn) CheckHealth(ctx context.Context, service string) (bool, error) {
	var header metadata.MD

	resp, err := c.healthClient.Check(ctx, &grpc_health_v1.HealthCheckRequest{
		Service: service,
	}, grpc.Header(&header))
	if err != nil {
		return false, fmt.Errorf("health check failed: %w", err)
	}

	c.mu.Lock()

	// Store any block details we received
	if details := header.Get("block-details"); len(details) > 0 {
		c.lastHealthDetails = details[0]
		c.lastHealthCheck = time.Now()
		log.Printf("Health check details updated for %s: %s", c.addr, details[0])
	}
	c.mu.Unlock()

	return resp.Status == grpc_health_v1.HealthCheckResponse_SERVING, nil
}
Imported from GitHub. Original GitHub issue: #90 Original author: @mfreeman451 Original URL: https://github.com/carverauto/serviceradar/issues/90 Original created: 2025-01-21T17:43:22Z --- ```golang // CheckHealth checks the health of a specific service. func (c *ClientConn) CheckHealth(ctx context.Context, service string) (bool, error) { var header metadata.MD resp, err := c.healthClient.Check(ctx, &grpc_health_v1.HealthCheckRequest{ Service: service, }, grpc.Header(&header)) if err != nil { return false, fmt.Errorf("health check failed: %w", err) } c.mu.Lock() // Store any block details we received if details := header.Get("block-details"); len(details) > 0 { c.lastHealthDetails = details[0] c.lastHealthCheck = time.Now() log.Printf("Health check details updated for %s: %s", c.addr, details[0]) } c.mu.Unlock() return resp.Status == grpc_health_v1.HealthCheckResponse_SERVING, nil } ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
carverauto/serviceradar#48
No description provided.