github.com/kyma-incubator/compass/components/director@v0.0.0-20230623144113-d764f56ff805/internal/healthz/db_indicator.go (about)

     1  package healthz
     2  
     3  import (
     4  	"context"
     5  )
     6  
     7  // DBIndicatorName missing godoc
     8  const DBIndicatorName = "database"
     9  
    10  // Pinger missing godoc
    11  //go:generate mockery --name=Pinger --output=automock --outpkg=automock --case=underscore --disable-version-string
    12  type Pinger interface {
    13  	PingContext(ctx context.Context) error
    14  }
    15  
    16  // NewDBIndicatorFunc missing godoc
    17  func NewDBIndicatorFunc(p Pinger) IndicatorFunc {
    18  	return func(ctx context.Context) Status {
    19  		if err := p.PingContext(ctx); err != nil {
    20  			return &status{
    21  				error:   err,
    22  				details: "Error pinging database",
    23  			}
    24  		}
    25  
    26  		return &status{
    27  			error:   nil,
    28  			details: "",
    29  		}
    30  	}
    31  }