Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions internal/infrastructure/messaging/messaging_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,20 +461,20 @@ func (r *MessagingRepository) HealthCheck(ctx context.Context) error {

// Check basic connection state
if r.conn == nil {
r.logger.Error("NATS health check failed: connection is nil")
r.logger.Warn("NATS health check failed: connection is nil")
return fmt.Errorf("%s: NATS connection is nil", constants.ErrHealthCheck)
}

r.logger.Debug("NATS connection diagnostics", "status", r.conn.Status().String(), "connected", r.conn.IsConnected())

if !r.conn.IsConnected() {
r.logger.Error("NATS health check failed: connection not connected", "status", r.conn.Status().String())
r.logger.Warn("NATS health check failed: connection not connected", "status", r.conn.Status().String())
return fmt.Errorf("%s: NATS connection is not connected", constants.ErrHealthCheck)
}

// Check if we can get server info
if r.conn.Status() != nats.CONNECTED {
r.logger.Error("NATS health check failed: connection status not connected",
r.logger.Warn("NATS health check failed: connection status not connected",
"status", r.conn.Status().String(),
"expected", nats.CONNECTED.String())
return fmt.Errorf("%s: NATS connection status is not connected: %s", constants.ErrHealthCheck, r.conn.Status())
Expand Down
4 changes: 2 additions & 2 deletions internal/infrastructure/storage/storage_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,13 +431,13 @@ func (r *StorageRepository) HealthCheck(ctx context.Context) error {

res, err := req.Do(ctx, r.client)
if err != nil {
logger.Error("Failed to execute health check request", "error", err.Error())
logger.Warn("OpenSearch health check failed", "error", err.Error())
return fmt.Errorf("%s: %w", constants.ErrHealthCheck, err)
}
defer res.Body.Close()

if res.IsError() {
logger.Error("Health check request failed", "status", res.Status())
logger.Warn("OpenSearch health check returned error status", "status", res.Status())
return fmt.Errorf("%s: %s", constants.ErrHealthCheck, res.Status())
}

Expand Down
Loading